List of usage examples for javax.swing JButton setHorizontalAlignment
@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER", "SwingConstants.RIGHT", "SwingConstants.LEADING", "SwingConstants.TRAILING" }, description = "The horizontal alignment of the icon and text.") public void setHorizontalAlignment(int alignment)
From source file:op.care.sysfiles.PnlFiles.java
private void tblFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblFilesMousePressed Point p = evt.getPoint();/*from w ww . j a v a2 s .c o m*/ ListSelectionModel lsm = tblFiles.getSelectionModel(); Point p2 = evt.getPoint(); SwingUtilities.convertPointToScreen(p2, tblFiles); final Point screenposition = p2; boolean singleRowSelected = lsm.getMaxSelectionIndex() == lsm.getMinSelectionIndex(); final int row = tblFiles.rowAtPoint(p); final int col = tblFiles.columnAtPoint(p); if (singleRowSelected) { lsm.setSelectionInterval(row, row); } final TMSYSFiles tm = (TMSYSFiles) tblFiles.getModel(); final SYSFiles sysfile = tm.getRow(tblFiles.convertRowIndexToModel(row)); if (SwingUtilities.isRightMouseButton(evt)) { SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); // SELECT JMenuItem itemPopupShow = new JMenuItem(SYSTools.xx("misc.commands.show"), SYSConst.icon22magnify1); itemPopupShow.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }); menu.add(itemPopupShow); if (col == TMSYSFiles.COL_DESCRIPTION && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JMenuItem itemPopupEdit = new JMenuItem(SYSTools.xx("misc.commands.edit"), SYSConst.icon22edit3); itemPopupEdit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { final JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); final JComponent editor = new JTextArea(sysfile.getBeschreibung(), 10, 40); ((JTextArea) editor).setLineWrap(true); ((JTextArea) editor).setWrapStyleWord(true); ((JTextArea) editor).setEditable(true); popup.getContentPane().add(new JScrollPane(editor)); final JButton saveButton = new JButton(SYSConst.icon22apply); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); popup.hidePopup(); SYSFiles mySysfile = em.merge(sysfile); mySysfile.setBeschreibung(((JTextArea) editor).getText().trim()); em.getTransaction().commit(); tm.setSYSFile(tblFiles.convertRowIndexToModel(row), mySysfile); } catch (Exception e) { em.getTransaction().rollback(); OPDE.fatal(e); } finally { em.close(); } } }); saveButton.setHorizontalAlignment(SwingConstants.RIGHT); JPanel pnl = new JPanel(new BorderLayout(10, 10)); JScrollPane pnlEditor = new JScrollPane(editor); pnl.add(pnlEditor, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(saveButton); pnl.setBorder(new EmptyBorder(10, 10, 10, 10)); pnl.add(buttonPanel, BorderLayout.SOUTH); popup.setOwner(tblFiles); popup.removeExcludedComponent(tblFiles); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(editor); popup.showPopup(screenposition.x, screenposition.y); } }); menu.add(itemPopupEdit); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete); itemPopupDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><b>" + sysfile.getFilename() + "</b><br/>" + SYSTools.xx("misc.questions.delete2"), new ImageIcon(getClass().getResource("/artwork/48x48/bw/trashcan_empty.png")), new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { SYSFilesTools.deleteFile(sysfile); reloadTable(); } } }); } }); menu.add(itemPopupDelete); itemPopupDelete.setEnabled(singleRowSelected); } menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY()); } else if (evt.getClickCount() == 2) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }
From source file:org.apache.marmotta.splash.common.ui.SelectionDialog.java
public static int select(String title, String message, String description, List<Option> options, int defaultOption) { final JDialog dialog = new JDialog((Frame) null, title); dialog.setModal(true);/*from ww w .j av a 2s . c o m*/ dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); final AtomicInteger result = new AtomicInteger(Math.max(defaultOption, -1)); JButton defaultBtn = null; final JPanel root = new JPanel(new GridBagLayout()); root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); dialog.getRootPane().setContentPane(root); JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>")); lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f)); GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridx = 0; cLabel.gridy = 0; cLabel.fill = GridBagConstraints.BOTH; cLabel.weightx = 1; cLabel.weighty = 0.5; cLabel.insets = new Insets(5, 5, 5, 5); root.add(lblMsg, cLabel); JLabel lblDescr = new JLabel( "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>")); cLabel.gridy++; cLabel.insets = new Insets(0, 5, 5, 5); root.add(lblDescr, cLabel); // All the options cLabel.ipadx = 10; cLabel.ipady = 10; cLabel.insets = new Insets(5, 15, 0, 15); for (int i = 0; i < options.size(); i++) { cLabel.gridy++; final Option o = options.get(i); final JButton btn = new JButton( "<html>" + StringEscapeUtils.escapeHtml3(o.label).replaceAll("\\n", "<br>"), MessageDialog.loadIcon(o.icon)); if (StringUtils.isNotBlank(o.info)) { btn.setToolTipText("<html>" + StringEscapeUtils.escapeHtml3(o.info).replaceAll("\\n", "<br>")); } btn.setHorizontalAlignment(AbstractButton.LEADING); btn.setVerticalTextPosition(AbstractButton.CENTER); btn.setHorizontalTextPosition(AbstractButton.TRAILING); final int myAnswer = i; btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result.set(myAnswer); dialog.setVisible(false); } }); root.add(btn, cLabel); if (i == defaultOption) { dialog.getRootPane().setDefaultButton(btn); defaultBtn = btn; } } final Icon icon = MessageDialog.loadIcon(); if (icon != null) { JLabel lblIcn = new JLabel(icon); GridBagConstraints cIcon = new GridBagConstraints(); cIcon.gridx = 1; cIcon.gridy = 0; cIcon.gridheight = 2 + options.size(); cIcon.fill = GridBagConstraints.NONE; cIcon.weightx = 0; cIcon.weighty = 1; cIcon.anchor = GridBagConstraints.NORTH; cIcon.insets = new Insets(10, 5, 5, 0); root.add(lblIcn, cIcon); } final JButton close = new JButton("Cancel"); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result.set(-1); dialog.setVisible(false); } }); GridBagConstraints cClose = new GridBagConstraints(); cClose.gridx = 0; cClose.gridy = 2 + options.size(); cClose.gridwidth = 2; cClose.weightx = 1; cClose.weighty = 0; cClose.insets = new Insets(15, 5, 5, 5); root.add(close, cClose); if (defaultOption < 0) { dialog.getRootPane().setDefaultButton(close); defaultBtn = close; } dialog.pack(); dialog.setLocationRelativeTo(null); defaultBtn.requestFocusInWindow(); dialog.setVisible(true); dialog.dispose(); return result.get(); }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private JButton createButton(String text, String icon, AbstractAction action) { JButton button = new JButton(text, Main.IMAGELOADER.getIcon(icon)); button.setPreferredSize(new Dimension(BUTTON_WIDTH, COMP_HEIGHT)); button.setHorizontalAlignment(SwingConstants.LEFT); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); button.addActionListener(action);/*from w ww .j a va2 s . c o m*/ return button; }
From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java
public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration, final OpenAnalysisJobActionListener openAnalysisJobActionListener) { super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT); _file = file;/* w w w. j av a 2 s.c o m*/ _openAnalysisJobActionListener = openAnalysisJobActionListener; setLayout(new BorderLayout()); setBorder(WidgetUtils.BORDER_LIST_ITEM); final AnalysisJobMetadata metadata = getMetadata(configuration); final String jobName = metadata.getJobName(); final String jobDescription = metadata.getJobDescription(); final String datastoreName = metadata.getDatastoreName(); final boolean isDemoJob = isDemoJob(metadata); final DCPanel labelListPanel = new DCPanel(); labelListPanel.setLayout(new VerticalLayout(4)); labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final String title; final String filename = file.getName().getBaseName(); if (Strings.isNullOrEmpty(jobName)) { final String extension = FileFilters.ANALYSIS_XML.getExtension(); if (filename.toLowerCase().endsWith(extension)) { title = filename.substring(0, filename.length() - extension.length()); } else { title = filename; } } else { title = jobName; } final JButton titleButton = new JButton(title); titleButton.setFont(WidgetUtils.FONT_HEADER1); titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM); titleButton.setHorizontalAlignment(SwingConstants.LEFT); titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM)); titleButton.setToolTipText("Open job"); titleButton.setOpaque(false); titleButton.setMargin(new Insets(0, 0, 0, 0)); titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); titleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { _openAnalysisJobActionListener.openFile(_file); } } }); final JButton executeButton = new JButton(executeIcon); executeButton.setOpaque(false); executeButton.setToolTipText("Execute job directly"); executeButton.setMargin(new Insets(0, 0, 0, 0)); executeButton.setBorderPainted(false); executeButton.setHorizontalAlignment(SwingConstants.RIGHT); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE); final String question = "Are you sure you want to execute the job\n'" + title + "'?"; final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge); if (choice == JOptionPane.YES_OPTION) { final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file); if (injector != null) { final ResultWindow resultWindow = injector.getInstance(ResultWindow.class); resultWindow.open(); resultWindow.startAnalysis(); } } } } }); final DCPanel titlePanel = new DCPanel(); titlePanel.setLayout(new BorderLayout()); titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER); titlePanel.add(executeButton, BorderLayout.EAST); labelListPanel.add(titlePanel); if (!Strings.isNullOrEmpty(jobDescription)) { String desc = StringUtils.replaceWhitespaces(jobDescription, " "); desc = StringUtils.replaceAll(desc, " ", " "); final JLabel label = new JLabel(desc); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); } final Icon icon; { if (!StringUtils.isNullOrEmpty(datastoreName)) { final JLabel label = new JLabel(" " + datastoreName); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (isDemoJob) { icon = demoBadgeIcon; } else { icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore); } } else { icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE); } } final JLabel iconLabel = new JLabel(icon); iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); add(iconLabel, BorderLayout.WEST); add(labelListPanel, BorderLayout.CENTER); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.BilanPanel.java
public BilanPanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel("Vous allez gnrer le fichier result_2033A.pdf contenant le bilan simplifi."), c); c.gridy++;//from w w w. jav a2 s . c o m try { this.add(new JLabel("Il se trouvera dans le dossier " + new File(TemplateNXProps.getInstance().getStringProperty("Location2033APDF")) .getCanonicalPath()), c); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /* * PdfGenerator_2033A p = new PdfGenerator_2033A(); p.generateFrom(new * Map2033A().getMap2033A()); */ JButton buttonFermer = new JButton("Fermer"); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(BilanPanel.this)).dispose(); } }); JButton buttonOuvrirDossier = new JButton("Ouvrir dossier"); buttonOuvrirDossier.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String file = TemplateNXProps.getInstance().getStringProperty("Location2033APDF"); File f = new File(file); FileUtils.browseFile(f); }; }); // FIXME impossible de gnrer si le fichier est ouvert JButton buttonGenerer = new JButton("Gnrer"); buttonGenerer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Map2033A map = new Map2033A(new JProgressBar()); map.generateMap2033A(); }; }); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.NONE; this.add(buttonOuvrirDossier, c); c.gridy++; c.anchor = GridBagConstraints.EAST; c.weightx = 1; buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT); this.add(buttonGenerer, c); c.weightx = 0; this.add(buttonFermer, c); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;/*from ww w . ja v a 2s . c om*/ c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
private JPanel creerComptePanel(final Compte compte) { final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = GridBagConstraints.RELATIVE; c.gridy = 0;/* w w w .jav a 2s . c o m*/ c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; // Intitul du compte final JPanel panelCompte = new JPanel(); panelCompte.setOpaque(false); panelCompte.setLayout(new GridBagLayout()); panelCompte.setBorder(BorderFactory.createTitledBorder(compte.getNumero() + " " + compte.getNom())); // Bouton Dtails +/- du compte JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.RIGHT); // Total du Compte JLabel labelCompteDebit = new JLabel( "Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit())); JLabel labelCompteCredit = new JLabel( " Credit : " + GestionDevise.currencyToString(compte.getTotalCredit())); // labelCompte.setFont(new Font(labelCompte.getFont().getFontName(), Font.BOLD, 12)); labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT); labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT); JLabel labelTmp = new JLabel(compte.getNumero() + " " + compte.getNom()); labelTmp.setHorizontalAlignment(SwingUtilities.LEFT); panelCompte.add(labelTmp, c); panelCompte.add(labelCompteDebit, c); panelCompte.add(labelCompteCredit, c); c.weightx = 1; c.anchor = GridBagConstraints.NORTHEAST; panelCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private JScrollPane scroll = null; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { // if (this.scroll == null) { System.err.println(compte); JTable tableCpt = createJTableCompte(compte); this.scroll = new JScrollPane(tableCpt); // calcul de la taille du JScrollPane Dimension d; System.err.println(tableCpt); if (tableCpt.getPreferredSize().height > 200) { d = new Dimension(this.scroll.getPreferredSize().width, 200); } else { d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30); } this.scroll.setPreferredSize(d); c.gridy++; c.gridwidth = 4; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; panelCompte.add(this.scroll, c); /* * } else { this.scroll.setVisible(true); } */ } else { // if (this.scroll != null) { panelCompte.remove(this.scroll); System.out.println("Hide scrollPane"); // this.scroll.setVisible(false); // this.scroll.repaint(); panelCompte.repaint(); panelCompte.revalidate(); // } } this.isShow = !this.isShow; SwingUtilities.getRoot(panelCompte).repaint(); } }); return panelCompte; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.ResultatPanel.java
public ResultatPanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel("Vous allez gnrer le fichier result_2033B.pdf contenant le rsultat."), c); c.gridy++;/*w w w .j av a2 s. c o m*/ try { this.add(new JLabel("Il se trouvera dans le dossier " + new File(TemplateNXProps.getInstance().getStringProperty("Location2033BPDF")) .getCanonicalPath()), c); } catch (IOException e1) { e1.printStackTrace(); } final JButton buttonFermer = new JButton("Fermer"); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { ((JFrame) SwingUtilities.getRoot(ResultatPanel.this)).dispose(); } }); final JButton buttonOuvrir = new JButton("Ouvrir dossier"); buttonOuvrir.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"); File f = new File(file); FileUtils.browseFile(f); } }); // FIXME impossible de gnrer si le fichier est ouvert final JButton buttonGenerer = new JButton("Gnrer"); buttonGenerer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final Map2033B map = new Map2033B(new JProgressBar()); map.generateMap(); } }); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.NONE; this.add(buttonOuvrir, c); c.gridy++; c.anchor = GridBagConstraints.EAST; c.weightx = 1; buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT); this.add(buttonGenerer, c); c.weightx = 0; this.add(buttonFermer, c); }
From source file:Provider.GoogleMapsStatic.TestUI.MySample.java
/** * @author Nazmul// w w w. ja v a 2 s .co m */ private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY // //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license ttfSizeW = new JTextField("512"); ttfLat = new JTextField("45.5"); btnGetMap = new JButton("Get Map"); btnQuit = new JButton("Quit"); ttfSizeH = new JTextField("512"); ttfLon = new JTextField("-73.55"); ttfZoom = new JTextField("14"); ttaStatus = new JTextArea(); checkboxRecvStatus = new JCheckBox(); checkboxSendStatus = new JCheckBox(); ttfProgressMsg = new JTextField(); progressBar = new JProgressBar(); imgLbl = new JLabel(); /*** * @author Dhgiang, jpmolinamatute * Created a slider, zoom in/out buttons, conbo box (drop down listbox) for city selection, * a panel to group the zoom buttons and the slider bar */ slider = new JSlider(0, 19, 14); controlPanel = new JPanel(new GridBagLayout()); // controlPanel was created by jpmolinamatute cities = new JComboBox<Object>(new String[] { "Montreal", "Toronto", // the place setting where the combo box is now used to be a text field "Vancouver", "New York City", "Caracas", "Hong Kong" }); // for license key, but it was removed to accommodate space for combo box // @author Dhgiang JPanel panel1 = new JPanel(); JPanel contentPanel = new JPanel(); JPanel btnPanel = new JPanel(); JPanel dialogPane = new JPanel(); JLabel label1 = new JLabel("Select City"); // this used to be the label for license key, it was changed to label as 'select city' JLabel label2 = new JLabel("Size Width"); JLabel label3 = new JLabel("Size Height"); JLabel label4 = new JLabel("Latitude"); JLabel label5 = new JLabel("Longitude"); JLabel label6 = new JLabel("Zoom"); JButton btnZoomIn = new JButton("-"); JButton btnZoomOut = new JButton("+"); /*** * @author jpmolinamatute * Created 8 cardinal points: N,NE,NW; S,SE,SW; E, W; */ JButton btnSE = new JButton("SE"); JButton btnS = new JButton("S"); JButton btnSW = new JButton("SW"); JButton btnE = new JButton("E"); JButton btnW = new JButton("W"); JButton btnNE = new JButton("NE"); JButton btnN = new JButton("N"); JButton btnNW = new JButton("NW"); /*** * @author JPMolinaMatute * Creaetd a spaceControl GridBagConstraints object to manage * the cardinal points, and add KeyListener so users can use the * 8 cardinal keys on the num pad; initialize dimensions * */ GridBagConstraints spaceControl = new GridBagConstraints(); spaceControl.insets = new Insets(5, 5, 5, 5); controlPanel.addKeyListener(this); controlPanel.setSize(new Dimension(512, 512)); // ---- My Combo Boxes for different city coordinates ----// // ======== this ======== setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("Google Static Maps"); setIconImage(null); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); // ======== dialogPane ======== { dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setOpaque(false); dialogPane.setLayout(new BorderLayout()); // ======== contentPanel ======== { contentPanel.setOpaque(false); contentPanel.setLayout(new TableLayout( new double[][] { { TableLayoutConstants.FILL }, { TableLayoutConstants.PREFERRED, TableLayoutConstants.FILL, TableLayoutConstants.PREFERRED } })); ((TableLayout) contentPanel.getLayout()).setHGap(5); ((TableLayout) contentPanel.getLayout()).setVGap(5); // ======== panel1 ======== { panel1.setOpaque(false); panel1.setBorder(new CompoundBorder( new TitledBorder("Configure the inputs to Google Static Maps"), Borders.DLU2_BORDER)); panel1.setLayout(new TableLayout( new double[][] { { 0.17, 0.17, 0.17, 0.17, 0.05, TableLayoutConstants.FILL }, { TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED } })); ((TableLayout) panel1.getLayout()).setHGap(5); ((TableLayout) panel1.getLayout()).setVGap(5); label1.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label1, new TableLayoutConstraints(0, 2, 0, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label2 ---- label2.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label2, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfSizeW ---- panel1.add(ttfSizeW, new TableLayoutConstraints(1, 0, 1, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label4 ---- label4.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label4, new TableLayoutConstraints(2, 0, 2, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfLat ---- panel1.add(ttfLat, new TableLayoutConstraints(3, 0, 3, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- btnGetMap ---- btnGetMap.setHorizontalAlignment(SwingConstants.LEFT); btnGetMap.setMnemonic('G'); btnGetMap.setActionCommand("getMap"); btnGetMap.addActionListener(this); panel1.add(btnGetMap, new TableLayoutConstraints(5, 0, 5, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label3 ---- label3.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label3, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfSizeH ---- panel1.add(ttfSizeH, new TableLayoutConstraints(1, 1, 1, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label5 ---- label5.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label5, new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfLon ---- panel1.add(ttfLon, new TableLayoutConstraints(3, 1, 3, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- btnQuit ---- btnQuit.setMnemonic('Q'); btnQuit.setHorizontalAlignment(SwingConstants.LEFT); btnQuit.setHorizontalTextPosition(SwingConstants.RIGHT); btnQuit.setActionCommand("quit"); btnQuit.addActionListener(this); panel1.add(btnQuit, new TableLayoutConstraints(5, 1, 5, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); /*** * @author Dhgiang * Added an anonymous inner class for ItemLister and event handling for the combo box * Used the switch case condition handling to set coordinates based on the city selected * Juan helped modified this method by adding the startTaskAction() at the end so * users don't have to click on Get Map button. */ cities.setSelectedIndex(0); // initialize the city selection item to 0 (or the first item) cities.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Integer z = cities.getSelectedIndex(); switch (z) { case 0: ttfLat.setText("45.5"); ttfLon.setText("-73.55"); break; case 1: ttfLat.setText("43.65"); ttfLon.setText("-79.38"); break; case 2: ttfLat.setText("49.2505"); ttfLon.setText("-123.1119"); break; case 3: ttfLat.setText("40.7142"); ttfLon.setText("-74.0064"); break; case 4: ttfLat.setText("10.4901"); ttfLon.setText("-66.9151"); break; case 5: ttfLat.setText("22.257"); ttfLon.setText("114.2"); break; default: break; } startTaskAction(); } }); /*** * @author Dhgiang * Added the combo box to the panel */ panel1.add(cities, new TableLayoutConstraints(1, 2, 1, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); // ---- label6 ---- label6.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label6, new TableLayoutConstraints(2, 2, 2, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfZoom ---- panel1.add(ttfZoom, new TableLayoutConstraints(3, 2, 3, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); } { btnPanel.setOpaque(false); btnPanel.setLayout(new GridLayout(0, 3)); /**** * @author Dhgiang * Initializing the zoom IN / OUT buttons with proper parameters and * adding them to the btnPanel of Panel1 (panel within a panel) */ // ---- btnZoomIn ---- btnZoomIn.setHorizontalAlignment(SwingConstants.LEFT); btnZoomIn.setHorizontalTextPosition(SwingConstants.RIGHT); btnZoomIn.setActionCommand("Zoomin"); btnZoomIn.addActionListener(this); btnPanel.add(btnZoomIn, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); // ---- btnZoomOut ---- btnZoomOut.setHorizontalAlignment(SwingConstants.RIGHT); btnZoomOut.setHorizontalTextPosition(SwingConstants.RIGHT); btnZoomOut.setActionCommand("Zoomout"); btnZoomOut.addActionListener(this); btnPanel.add(btnZoomOut, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); /*** * @author Dhgiang * Having created a new JSlider slider object, maximum & minimum values * are initialized along with incremental values * */ // ---- slider ----- slider.setMaximum(19); slider.setMinimum(0); slider.setPaintTicks(true); slider.setMajorTickSpacing(19); slider.setMinorTickSpacing(1); slider.setPaintTrack(false); slider.createStandardLabels(4, 0); /*** * @author Dhgiang * Added a ChangeListener to the slider so that * 1) the slider moves left if (-) button is clicked, slider moves right if (+) is clicked * 2) and zoom values will increase or decrease if slider bar is shifted left or right accordingly * 3) after the user releases the click button, the map will display automatically with the values * set by the slider bar, without having the user to click on get map button */ slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { Integer a = slider.getValue(); if (a >= 0 && a <= 19) { ttfZoom.setText(a.toString()); startTaskAction(); } } }); slider.setBorder(null); /*** * @author Dhgiang * Added the slider bar to the button panel */ btnPanel.add(slider, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); } /*** * @author Dhgiang * Adding the button panel to panel1 */ panel1.add(btnPanel, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); contentPanel.add(panel1, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); /*** * @author jpmolinamatute * Initializing coordinates for the cardinal points * Adding the cardinal points button to the control panel */ // ---- Cardinals points ----- btnNW.setActionCommand("Northwest"); btnNW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 0; controlPanel.add(btnNW, spaceControl); btnN.setActionCommand("North"); btnN.addActionListener(this); spaceControl.gridx = 3; spaceControl.gridy = 0; controlPanel.add(btnN, spaceControl); btnNE.setActionCommand("Northeast"); btnNE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 0; controlPanel.add(btnNE, spaceControl); btnW.setActionCommand("West"); btnW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 3; controlPanel.add(btnW, spaceControl); spaceControl.gridx = 3; spaceControl.gridy = 3; controlPanel.add(imgLbl, spaceControl); btnE.setActionCommand("East"); btnE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 3; controlPanel.add(btnE, spaceControl); btnSW.setActionCommand("Southwest"); btnSW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 6; controlPanel.add(btnSW, spaceControl); btnS.setActionCommand("South"); btnS.addActionListener(this); spaceControl.gridx = 3; spaceControl.gridy = 6; controlPanel.add(btnS, spaceControl); btnSE.setActionCommand("Southeast"); btnSE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 6; controlPanel.add(btnSE, spaceControl); contentPanel.add(controlPanel, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); } dialogPane.add(contentPanel, BorderLayout.CENTER); } contentPane.add(dialogPane, BorderLayout.CENTER); setSize(700, 800); setLocationRelativeTo(null); }
From source file:uk.chromis.pos.forms.JRootApp.java
private void listPeople() { try {/*from www .j av a2 s . c om*/ jScrollPane1.getViewport().setView(null); JFlowPanel jPeople = new JFlowPanel(); jPeople.applyComponentOrientation(getComponentOrientation()); java.util.List people = m_dlSystem.listPeopleVisible(); for (int i = 0; i < people.size(); i++) { AppUser user = (AppUser) people.get(i); JButton btn = new JButton(new AppUserAction(user)); btn.applyComponentOrientation(getComponentOrientation()); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setMaximumSize(new Dimension(130, 60)); btn.setPreferredSize(new Dimension(130, 60)); btn.setMinimumSize(new Dimension(130, 60)); btn.setHorizontalAlignment(SwingConstants.CENTER); btn.setHorizontalTextPosition(AbstractButton.CENTER); btn.setVerticalTextPosition(AbstractButton.BOTTOM); jPeople.add(btn); } jScrollPane1.getViewport().setView(jPeople); } catch (BasicException ee) { } }