List of usage examples for java.awt FlowLayout RIGHT
int RIGHT
To view the source code for java.awt FlowLayout RIGHT.
Click Source Link
From source file:org.owasp.jbrofuzz.update.StartUpdateChecker.java
/** * <p>//w w w . j av a 2 s. co m * Main constructor that displays a JDialog if a new version is identified * on the website.</p. * * @param parent * JBroFuzzwindow the main window * * @author subere@uncon.org * @version 1.7 * @since 1.3 */ protected StartUpdateChecker(final JBroFuzzWindow parent) { super(parent, " JBroFuzz - New Version Available ", true); // Version comparison to see if we will display or dispose final double latest = StartUpdateChecker.getWebsiteVersion(); if (latest == StartUpdateChecker.ZERO_VERSION) { StartUpdateChecker.this.dispose(); return; } double current; try { current = Double.parseDouble(JBroFuzzFormat.VERSION); } catch (final NumberFormatException e1) { current = StartUpdateChecker.ZERO_VERSION; } if (latest <= current) { StartUpdateChecker.this.dispose(); return; } final String text = "<html><b>A new version of JBroFuzz is available: " + latest + "<br><br>You are currently running version: " + current + "<br><br>Do you wish to download the <br>new version now?" + "</b></html>"; setIconImage(ImageCreator.IMG_FRAME.getImage()); setLayout(new BorderLayout()); setFont(new Font("Verdana", Font.PLAIN, 12)); final JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 15)); final JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15)); // The about editor label final JLabel mainLabel = new JLabel(text, ImageCreator.IMG_OWASP, SwingConstants.LEFT); mainLabel.setIconTextGap(20); mainLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); centerPanel.add(mainLabel); // Bottom buttons final JButton download = new JButton("Download"); final JButton close = new JButton("Close"); southPanel.add(download); southPanel.add(close); // Action Listeners download.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent even) { SwingUtilities.invokeLater(new Runnable() { public void run() { Browser.init(); try { Browser.displayURL(JBroFuzzFormat.URL_WEBSITE); } catch (final IOException e) { System.out.println("An IOException occurred."); } StartUpdateChecker.this.dispose(); } }); } }); close.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent even) { SwingUtilities.invokeLater(new Runnable() { public void run() { StartUpdateChecker.this.dispose(); } }); } }); // Add the panels to the dialog getContentPane().add(centerPanel, BorderLayout.CENTER); getContentPane().add(southPanel, BorderLayout.SOUTH); // Global frame issues final int xLocation = parent.getLocationOnScreen().x - (StartUpdateChecker.SIZE_X / 2) + (parent.getWidth() / 2); final int yLocation = parent.getLocationOnScreen().y - (StartUpdateChecker.SIZE_Y / 2) + (parent.getHeight() / 2); setSize(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y); setLocation(xLocation, yLocation); setMinimumSize(new Dimension(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y)); setResizable(true); setVisible(true); }
From source file:com.smart.aqimonitor.client.AqiSettingDialog.java
/** * Create the dialog./*from w ww. j a v a 2 s .c o m*/ */ public AqiSettingDialog(Frame owner, final AbstractAqiParser aqiParser) { super(owner); this.aqiParser = aqiParser; setTitle("\u8BBE\u7F6E"); setResizable(false); setBounds(100, 100, 450, 135); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 33, 48, 66, 41, 48, 66, 0, 0 }; gbl_contentPanel.rowHeights = new int[] { 21, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblRetryTimes = new JLabel("\u91CD\u8BD5\u6B21\u6570\uFF1A"); GridBagConstraints gbc_lblRetryTimes = new GridBagConstraints(); gbc_lblRetryTimes.anchor = GridBagConstraints.WEST; gbc_lblRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_lblRetryTimes.gridx = 1; gbc_lblRetryTimes.gridy = 0; contentPanel.add(lblRetryTimes, gbc_lblRetryTimes); } { tfRetryTimes = new JTextField(); tfRetryTimes.setPreferredSize(new Dimension(6, 29)); tfRetryTimes.setMinimumSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryTimes = new GridBagConstraints(); gbc_tfRetryTimes.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_tfRetryTimes.gridx = 2; gbc_tfRetryTimes.gridy = 0; contentPanel.add(tfRetryTimes, gbc_tfRetryTimes); tfRetryTimes.setColumns(10); } { JLabel lblRetryGap = new JLabel("\u91CD\u8BD5\u95F4\u9694\uFF1A"); GridBagConstraints gbc_lblRetryGap = new GridBagConstraints(); gbc_lblRetryGap.anchor = GridBagConstraints.WEST; gbc_lblRetryGap.insets = new Insets(0, 0, 5, 5); gbc_lblRetryGap.gridx = 4; gbc_lblRetryGap.gridy = 0; contentPanel.add(lblRetryGap, gbc_lblRetryGap); } { tfRetryGap = new JTextField(); tfRetryGap.setMinimumSize(new Dimension(60, 29)); tfRetryGap.setPreferredSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryGap = new GridBagConstraints(); gbc_tfRetryGap.insets = new Insets(0, 0, 5, 5); gbc_tfRetryGap.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryGap.gridx = 5; gbc_tfRetryGap.gridy = 0; contentPanel.add(tfRetryGap, gbc_tfRetryGap); tfRetryGap.setColumns(10); } { JLabel label = new JLabel("\u5206\u949F"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 0); gbc_label.gridx = 6; gbc_label.gridy = 0; contentPanel.add(label, gbc_label); } { JLabel lblExportPath = new JLabel("\u8F93\u51FA\u8DEF\u5F84\uFF1A"); GridBagConstraints gbc_lblExportPath = new GridBagConstraints(); gbc_lblExportPath.anchor = GridBagConstraints.EAST; gbc_lblExportPath.insets = new Insets(0, 0, 0, 5); gbc_lblExportPath.gridx = 1; gbc_lblExportPath.gridy = 1; contentPanel.add(lblExportPath, gbc_lblExportPath); } { tfExportPath = new JTextField(); tfExportPath.setEditable(false); tfExportPath.setPreferredSize(new Dimension(180, 29)); tfExportPath.setMinimumSize(new Dimension(180, 29)); GridBagConstraints gbc_tfExportPath = new GridBagConstraints(); gbc_tfExportPath.gridwidth = 4; gbc_tfExportPath.insets = new Insets(0, 0, 0, 5); gbc_tfExportPath.fill = GridBagConstraints.HORIZONTAL; gbc_tfExportPath.gridx = 2; gbc_tfExportPath.gridy = 1; contentPanel.add(tfExportPath, gbc_tfExportPath); tfExportPath.setColumns(10); } { JButton button = new JButton("..."); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fDialog = new JFileChooser(); // fDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = fDialog.showOpenDialog(contentPanel); if (result == JFileChooser.APPROVE_OPTION) { tfExportPath.setText(fDialog.getSelectedFile().getAbsolutePath()); } } }); GridBagConstraints gbc_button = new GridBagConstraints(); gbc_button.gridx = 6; gbc_button.gridy = 1; contentPanel.add(button, gbc_button); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("\u786E\u5B9A"); okButton.setName("settingOk"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String retryTimes = tfRetryTimes.getText(); if (StringUtils.isEmpty(retryTimes) || !isNumeric(retryTimes)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String retryGap = tfRetryGap.getText(); if (StringUtils.isEmpty(retryGap) || !isNumeric(retryGap)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String exportPath = tfExportPath.getText(); if (StringUtils.isEmpty(exportPath)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } File testFile = new File(exportPath); if (!testFile.exists()) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } props.put("query.retryTimes", retryTimes); props.put("query.retryGap", retryGap); props.put("result.path", exportPath); try { props.store(new FileOutputStream(propertiesResource.getFile()), ""); aqiParser.setRetryTimes(Integer.parseInt(retryTimes)); aqiParser.setRetryGap(Integer.parseInt(retryGap)); aqiParser.setFilePath(exportPath); } catch (IOException e1) { e1.printStackTrace(); } finally { dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("\u53D6\u6D88"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:misc.ModalityDemo.java
/** * Create the GUI and show it. For thread safety, * this method is invoked from the/*from w ww .java 2 s .c o m*/ * event-dispatching thread. */ private void createAndShowGUI() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); Insets ins = Toolkit.getDefaultToolkit().getScreenInsets(gc); int sw = gc.getBounds().width - ins.left - ins.right; int sh = gc.getBounds().height - ins.top - ins.bottom; // first document // frame f1 f1 = new JFrame("Book 1 (parent frame)"); f1.setBounds(32, 32, 300, 200); f1.addWindowListener(closeWindow); // create radio buttons rb11 = new JRadioButton("Biography", true); rb12 = new JRadioButton("Funny tale", false); rb13 = new JRadioButton("Sonnets", false); // place radio buttons into a single group ButtonGroup bg1 = new ButtonGroup(); bg1.add(rb11); bg1.add(rb12); bg1.add(rb13); JButton b1 = new JButton("OK"); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // get label of selected radiobutton String title = null; if (rb11.isSelected()) { title = rb11.getText(); } else if (rb12.isSelected()) { title = rb12.getText(); } else { title = rb13.getText(); } // prepend radio button label to dialogs' titles d2.setTitle(title + " (modeless dialog)"); d3.setTitle(title + " (document-modal dialog)"); d2.setVisible(true); } }); Container cp1 = f1.getContentPane(); // create three containers to improve layouting cp1.setLayout(new GridLayout(1, 3)); // an empty container Container cp11 = new Container(); // a container to layout components Container cp12 = new Container(); // an empty container Container cp13 = new Container(); // add a button into a separate panel JPanel p1 = new JPanel(); p1.setLayout(new FlowLayout()); p1.add(b1); // add radio buttons and the OK button one after another into a single column cp12.setLayout(new GridLayout(4, 1)); cp12.add(rb11); cp12.add(rb12); cp12.add(rb13); cp12.add(p1); // add three containers cp1.add(cp11); cp1.add(cp12); cp1.add(cp13); // dialog d2 d2 = new JDialog(f1); d2.setBounds(132, 132, 300, 200); d2.addWindowListener(closeWindow); JLabel l2 = new JLabel("Enter your name: "); l2.setHorizontalAlignment(SwingConstants.CENTER); tf2 = new JTextField(12); JButton b2 = new JButton("OK"); b2.setHorizontalAlignment(SwingConstants.CENTER); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //pass a name into the document modal dialog l3.setText("by " + tf2.getText()); d3.setVisible(true); } }); Container cp2 = d2.getContentPane(); // add label, text field and button one after another into a single column cp2.setLayout(new BorderLayout()); cp2.add(l2, BorderLayout.NORTH); cp2.add(tf2, BorderLayout.CENTER); JPanel p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.add(b2); cp2.add(p2, BorderLayout.SOUTH); // dialog d3 d3 = new JDialog(d2, "", Dialog.ModalityType.DOCUMENT_MODAL); d3.setBounds(232, 232, 300, 200); d3.addWindowListener(closeWindow); JTextArea ta3 = new JTextArea(); l3 = new JLabel(); l3.setHorizontalAlignment(SwingConstants.RIGHT); Container cp3 = d3.getContentPane(); cp3.setLayout(new BorderLayout()); cp3.add(new JScrollPane(ta3), BorderLayout.CENTER); JPanel p3 = new JPanel(); p3.setLayout(new FlowLayout(FlowLayout.RIGHT)); p3.add(l3); cp3.add(p3, BorderLayout.SOUTH); // second document // frame f4 f4 = new JFrame("Book 2 (parent frame)"); f4.setBounds(sw - 300 - 32, 32, 300, 200); f4.addWindowListener(closeWindow); // create radio buttons rb41 = new JRadioButton("Biography", true); rb42 = new JRadioButton("Funny tale", false); rb43 = new JRadioButton("Sonnets", false); // place radio buttons into a single group ButtonGroup bg4 = new ButtonGroup(); bg4.add(rb41); bg4.add(rb42); bg4.add(rb43); JButton b4 = new JButton("OK"); b4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // get label of selected radiobutton String title = null; if (rb41.isSelected()) { title = rb41.getText(); } else if (rb42.isSelected()) { title = rb42.getText(); } else { title = rb43.getText(); } // prepend radiobutton label to dialogs' titles d5.setTitle(title + " (modeless dialog)"); d6.setTitle(title + " (document-modal dialog)"); d5.setVisible(true); } }); Container cp4 = f4.getContentPane(); // create three containers to improve layouting cp4.setLayout(new GridLayout(1, 3)); Container cp41 = new Container(); Container cp42 = new Container(); Container cp43 = new Container(); // add the button into a separate panel JPanel p4 = new JPanel(); p4.setLayout(new FlowLayout()); p4.add(b4); // add radiobuttons and the OK button one after another into a single column cp42.setLayout(new GridLayout(4, 1)); cp42.add(rb41); cp42.add(rb42); cp42.add(rb43); cp42.add(p4); //add three containers cp4.add(cp41); cp4.add(cp42); cp4.add(cp43); // dialog d5 d5 = new JDialog(f4); d5.setBounds(sw - 400 - 32, 132, 300, 200); d5.addWindowListener(closeWindow); JLabel l5 = new JLabel("Enter your name: "); l5.setHorizontalAlignment(SwingConstants.CENTER); tf5 = new JTextField(12); tf5.setHorizontalAlignment(SwingConstants.CENTER); JButton b5 = new JButton("OK"); b5.setHorizontalAlignment(SwingConstants.CENTER); b5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //pass a name into the document modal dialog l6.setText("by " + tf5.getText()); d6.setVisible(true); } }); Container cp5 = d5.getContentPane(); // add label, text field and button one after another into a single column cp5.setLayout(new BorderLayout()); cp5.add(l5, BorderLayout.NORTH); cp5.add(tf5, BorderLayout.CENTER); JPanel p5 = new JPanel(); p5.setLayout(new FlowLayout()); p5.add(b5); cp5.add(p5, BorderLayout.SOUTH); // dialog d6 d6 = new JDialog(d5, "", Dialog.ModalityType.DOCUMENT_MODAL); d6.setBounds(sw - 500 - 32, 232, 300, 200); d6.addWindowListener(closeWindow); JTextArea ta6 = new JTextArea(); l6 = new JLabel(); l6.setHorizontalAlignment(SwingConstants.RIGHT); Container cp6 = d6.getContentPane(); cp6.setLayout(new BorderLayout()); cp6.add(new JScrollPane(ta6), BorderLayout.CENTER); JPanel p6 = new JPanel(); p6.setLayout(new FlowLayout(FlowLayout.RIGHT)); p6.add(l6); cp6.add(p6, BorderLayout.SOUTH); // third document // frame f7 f7 = new JFrame("Classics (excluded frame)"); f7.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE); f7.setBounds(32, sh - 200 - 32, 300, 200); f7.addWindowListener(closeWindow); JLabel l7 = new JLabel("Famous writers: "); l7.setHorizontalAlignment(SwingConstants.CENTER); // create radio buttons rb71 = new JRadioButton("Burns", true); rb72 = new JRadioButton("Dickens", false); rb73 = new JRadioButton("Twain", false); // place radio buttons into a single group ButtonGroup bg7 = new ButtonGroup(); bg7.add(rb71); bg7.add(rb72); bg7.add(rb73); Container cp7 = f7.getContentPane(); // create three containers to improve layouting cp7.setLayout(new GridLayout(1, 3)); Container cp71 = new Container(); Container cp72 = new Container(); Container cp73 = new Container(); // add the label into a separate panel JPanel p7 = new JPanel(); p7.setLayout(new FlowLayout()); p7.add(l7); // add a label and radio buttons one after another into a single column cp72.setLayout(new GridLayout(4, 1)); cp72.add(p7); cp72.add(rb71); cp72.add(rb72); cp72.add(rb73); // add three containers cp7.add(cp71); cp7.add(cp72); cp7.add(cp73); // fourth document // frame f8 f8 = new JFrame("Feedback (parent frame)"); f8.setBounds(sw - 300 - 32, sh - 200 - 32, 300, 200); f8.addWindowListener(closeWindow); JButton b8 = new JButton("Rate yourself"); b8.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showConfirmDialog(null, "I really like my book", "Question (application-modal dialog)", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); } }); Container cp8 = f8.getContentPane(); cp8.setLayout(new FlowLayout(FlowLayout.CENTER, 8, 8)); cp8.add(b8); }
From source file:org.opendatakit.briefcase.ui.CharsetConverterDialog.java
/** * Create the dialog.//from w ww .ja v a2 s.co m */ public CharsetConverterDialog(Window owner) { super(owner, ModalityType.DOCUMENT_MODAL); setTitle(DIALOG_TITLE); setBounds(100, 100, 600, 530); getContentPane().setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); contentPanel.setLayout(gbl_contentPanel); { JLabel lblNewLabel = new JLabel(SELECT_FILE_LABEL); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.WEST; gbc_lblNewLabel.gridwidth = 2; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 0; contentPanel.add(lblNewLabel, gbc_lblNewLabel); } { tfFile = new JTextField(); tfFile.setEditable(false); GridBagConstraints gbc_tfFile = new GridBagConstraints(); gbc_tfFile.weightx = 1.0; gbc_tfFile.insets = new Insets(0, 0, 5, 5); gbc_tfFile.fill = GridBagConstraints.HORIZONTAL; gbc_tfFile.gridx = 0; gbc_tfFile.gridy = 1; contentPanel.add(tfFile, gbc_tfFile); tfFile.setColumns(10); } { JButton btnBrowse = new JButton(SELECT_FILE_BUTTON); btnBrowse.setActionCommand(BROWSE_COMMAND); btnBrowse.addActionListener(this); GridBagConstraints gbc_btnBrowse = new GridBagConstraints(); gbc_btnBrowse.insets = new Insets(0, 0, 5, 0); gbc_btnBrowse.gridx = 1; gbc_btnBrowse.gridy = 1; contentPanel.add(btnBrowse, gbc_btnBrowse); } { JLabel lblEncoding = new JLabel(SELECT_SOURCE_ENCODING_LABEL); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.anchor = GridBagConstraints.WEST; gbc_lblEncoding.insets = new Insets(0, 0, 5, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 2; contentPanel.add(lblEncoding, gbc_lblEncoding); } { listCharset = new JList<CharsetEntry>(); listCharset.setVisibleRowCount(7); listCharset.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); GridBagConstraints gbc_cbCharset = new GridBagConstraints(); gbc_cbCharset.gridwidth = 2; gbc_cbCharset.insets = new Insets(0, 0, 5, 0); gbc_cbCharset.fill = GridBagConstraints.BOTH; gbc_cbCharset.gridx = 0; gbc_cbCharset.gridy = 3; JScrollPane listScrollPane = new JScrollPane(listCharset); contentPanel.add(listScrollPane, gbc_cbCharset); } { JLabel lblPreview = new JLabel(PREVIEW_LABEL); GridBagConstraints gbc_lblPreview = new GridBagConstraints(); gbc_lblPreview.anchor = GridBagConstraints.WEST; gbc_lblPreview.insets = new Insets(0, 0, 5, 5); gbc_lblPreview.gridx = 0; gbc_lblPreview.gridy = 4; contentPanel.add(lblPreview, gbc_lblPreview); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.weightx = 1.0; gbc_scrollPane.gridwidth = 2; gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 5; contentPanel.add(scrollPane, gbc_scrollPane); { previewArea = new JTextArea(); previewArea.setLineWrap(true); previewArea.setRows(10); previewArea.setFont(UIManager.getDefaults().getFont("Label.font").deriveFont(Font.PLAIN)); previewArea.setEditable(false); scrollPane.setViewportView(previewArea); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { cbOverride = new JCheckBox(REPLACE_EXISTING_FILE_LABEL); cbOverride.setSelected(false); buttonPane.add(cbOverride); } { JButton okButton = new JButton(CONVERT_BUTTON_LABEL); okButton.setActionCommand(CONVERT_COMMAND); okButton.addActionListener(this); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { cancelButton = new JButton(CANCEL_BUTTON_LABEL); cancelButton.setActionCommand(CANCEL_COMMAND); cancelButton.addActionListener(this); buttonPane.add(cancelButton); } } }
From source file:org.optaplanner.benchmark.impl.aggregator.swingui.BenchmarkAggregatorFrame.java
private JComponent createBenchmarkTreePanel() { JPanel benchmarkTreePanel = new JPanel(new BorderLayout()); benchmarkTreePanel.add(new JScrollPane( plannerBenchmarkResultList.isEmpty() ? createNoPlannerFoundTextField() : createCheckBoxTree(), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); JPanel buttonPanelWrapper = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 10, 0)); generateReportButton = new JButton(new GenerateReportAction(this)); generateReportButton.setEnabled(false); buttonPanel.add(generateReportButton); generateProgressBar = new JProgressBar(); buttonPanel.add(generateProgressBar); buttonPanelWrapper.add(buttonPanel); benchmarkTreePanel.add(buttonPanelWrapper, BorderLayout.SOUTH); benchmarkTreePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 15, 0)); return benchmarkTreePanel; }
From source file:org.pentaho.reporting.tools.configeditor.ConfigEditor.java
/** * Creates the button pane to hold all control buttons. * * @return the created panel with all control buttons. *///from w w w . j a v a 2s . c o m private JPanel createButtonPane() { final Action closeAction = new CloseAction(); final Action saveAction = new SaveAction(); final Action loadAction = new LoadAction(); final Action newAction = new NewAction(); final JPanel buttonHolder = new JPanel(); buttonHolder.setLayout(new GridLayout(1, 4, 5, 5)); buttonHolder.add(new JButton(newAction)); buttonHolder.add(new JButton(loadAction)); buttonHolder.add(new JButton(saveAction)); buttonHolder.add(new JButton(closeAction)); final JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.RIGHT)); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); panel.add(buttonHolder); return panel; }
From source file:emailplugin.MailCreator.java
/** * Show the EMail-Open Dialog./*from w w w . ja va 2 s .c om*/ * * This Dialog says that the EMail should have been opened. It gives the User * a chance to specify another EMail Program if it went wrong. * * @param parent * Parent-Frame */ private void showEMailOpenedDialog(Frame parent) { final JDialog dialog = new JDialog(parent, true); dialog.setTitle(mLocalizer.msg("EMailOpenedTitel", "Email was opened")); JPanel panel = (JPanel) dialog.getContentPane(); panel.setLayout(new FormLayout("fill:200dlu:grow", "default, 3dlu, default, 3dlu, default")); panel.setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("EMailOpened", "Email was opened. Configure it?")), cc.xy(1, 1)); final JCheckBox dontShowAgain = new JCheckBox( mLocalizer.msg("DontShowAgain", "Don't show this Dialog again")); panel.add(dontShowAgain, cc.xy(1, 3)); JButton configure = new JButton(mLocalizer.msg("configure", "Configure")); configure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Plugin.getPluginManager().showSettings(mPlugin); dialog.setVisible(false); } }); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dontShowAgain.isSelected()) { mSettings.setShowEmailOpened(false); } dialog.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(configure); buttonPanel.add(ok); panel.add(buttonPanel, cc.xy(1, 5)); UiUtilities.registerForClosing(new WindowClosingIf() { public void close() { dialog.setVisible(false); } public JRootPane getRootPane() { return dialog.getRootPane(); } }); dialog.getRootPane().setDefaultButton(ok); dialog.pack(); UiUtilities.centerAndShow(dialog); }
From source file:org.executequery.gui.ExportResultSetPanel.java
private void init() throws Exception { fileNameField = WidgetFactory.createTextField(); connectionsCombo = WidgetFactory.createComboBox(); String[] delims = { "|", ",", ";", "#" }; delimiterCombo = WidgetFactory.createComboBox(delims); delimiterCombo.setEditable(true);// w ww . jav a 2 s . c o m combosGroup = new TableSelectionCombosGroup(connectionsCombo); includeColumNamesCheck = new JCheckBox("Include column names as first row"); sqlText = new SimpleSqlTextPanel(); // sqlText.getTextPane().setBackground(Color.WHITE); sqlText.setBorder(null); sqlText.setScrollPaneBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIUtils.getDefaultBorderColour())); statusBar = new SqlTextPaneStatusBar(); JPanel sqlPanel = new JPanel(new BorderLayout()); sqlPanel.add(sqlText, BorderLayout.CENTER); sqlPanel.add(statusBar, BorderLayout.SOUTH); statusBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); outputPanel = new LoggingOutputPanel(); FlatSplitPane splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT, sqlPanel, outputPanel); splitPane.setResizeWeight(0.5); splitPane.setDividerLocation(0.8); splitPane.setDividerSize(5); JButton button = WidgetFactory.createInlineFieldButton("Browse"); button.setActionCommand("browse"); button.addActionListener(this); button.setMnemonic('r'); JPanel mainPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.gridx = 0; gbc.gridheight = 1; gbc.insets.top = 5; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.insets.left = 5; gbc.anchor = GridBagConstraints.NORTHWEST; mainPanel.add(new JLabel("Connection:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(connectionsCombo, gbc); gbc.insets.left = 5; gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 0; mainPanel.add(new JLabel("Data Delimiter:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(delimiterCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 2; mainPanel.add(new JLabel("Output File:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(fileNameField, gbc); gbc.gridx = 2; gbc.weightx = 0; gbc.insets.left = 0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(button, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets.top = 2; gbc.insets.left = 5; mainPanel.add(includeColumNamesCheck, gbc); gbc.gridy++; gbc.insets.bottom = 10; mainPanel.add(new JLabel(instructionNote()), gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.insets.top = 0; gbc.insets.left = 5; gbc.insets.bottom = 5; gbc.fill = GridBagConstraints.BOTH; mainPanel.add(splitPane, gbc); mainPanel.setBorder(BorderFactory.createEtchedBorder()); int minimumButtonWidth = 85; executeButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Execute", "executeAndExport"); stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop"); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5)); buttonPanel.add(executeButton); buttonPanel.add(stopButton); stopButton.setEnabled(false); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // register as a keyword and connection listener EventMediator.registerListener(this); JTextPane textPane = sqlText.getTextPane(); ActionMap actionMap = textPane.getActionMap(); String actionKey = "executeQueryAction"; actionMap.put(actionKey, executeQueryAction); InputMap inputMap = textPane.getInputMap(); inputMap.put(EXECUTE_KEYSTROKE, actionKey); JPopupMenu popupMenu = sqlText.getPopup(); popupMenu.addSeparator(); popupMenu.add(executeQueryAction); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java
/** * Builds the tool bar./* w w w. j a v a 2 s .c om*/ * * @return See above. */ private JPanel buildToolBar() { JPanel bar = new JPanel(); bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS)); bar.setBorder(null); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.setBorder(null); p.add(leftMenuBar); p.setPreferredSize(leftMenuBar.getPreferredSize()); bar.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); p.setBorder(null); p.add(rightMenuBar); p.setPreferredSize(rightMenuBar.getPreferredSize()); bar.add(p); return bar; }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Creates the component./*from w w w. j a v a 2s . co m*/ */ public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; Component component = renderedResultPanel.getComponent(0); if (component instanceof DialogTextArea) { nodeToWrapSelection.put(path, e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }