List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:cool.pandora.modeller.ui.jpanel.base.NewBagInPlaceFrame.java
/** * layoutAddKeepFilesToEmptyCheckBox./*w ww . ja va 2 s . co m*/ * * <p>Setting and displaying the ".keep Files in Empty Folder(s):" Check Box * on the Create Bag In Place Pane */ private void layoutAddKeepFilesToEmptyCheckBox(final JPanel contentPane, final int row) { // Delete Empty Folder(s) final JLabel addKeepFilesToEmptyFoldersCheckBoxLabel = new JLabel( bagView.getPropertyMessage("bag.label" + ".addkeepfilestoemptyfolders")); addKeepFilesToEmptyFoldersCheckBoxLabel .setToolTipText(bagView.getPropertyMessage("bag" + ".addkeepfilestoemptyfolders" + ".help")); final JCheckBox addKeepFilesToEmptyFoldersCheckBox = new JCheckBox(bagView.getPropertyMessage("")); addKeepFilesToEmptyFoldersCheckBox.setSelected(bag.isAddKeepFilesToEmptyFolders()); addKeepFilesToEmptyFoldersCheckBox.addActionListener(new AddKeepFilesToEmptyFoldersHandler()); GridBagConstraints glbc = new GridBagConstraints(); final JLabel spacerLabel = new JLabel(); glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); contentPane.add(addKeepFilesToEmptyFoldersCheckBoxLabel, glbc); glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); contentPane.add(addKeepFilesToEmptyFoldersCheckBox, glbc); glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); contentPane.add(spacerLabel, glbc); }
From source file:eu.europeana.sip.gui.SipCreatorGUI.java
private JPanel createConnectPanel() { connectedBox = new JCheckBox(String.format(CONNECT_TO, sipModel.getAppConfigModel().getServerHostPort())); sipModel.getAppConfigModel().addListener(new AppConfigModel.Listener() { @Override//from ww w .j a va 2 s. c o m public void appConfigUpdated(AppConfig appConfig) { connectedBox.setText(String.format(CONNECT_TO, sipModel.getAppConfigModel().getServerHostPort())); } }); connectedBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { boolean enabled = itemEvent.getStateChange() == ItemEvent.SELECTED; dataSetClient.setListFetchingEnabled(enabled); if (!enabled) { dataSetListModel.clear(); for (FileStore.DataSetStore dataSetStore : sipModel.getFileStore().getDataSetStores() .values()) { dataSetListModel.setDataSetStore(dataSetStore); } } titleLabel.setText(enabled ? LOCAL_AND_REMOTE_SETS : LOCAL_SETS); } }); JPanel p = new JPanel(new FlowLayout()); p.add(connectedBox); return p; }
From source file:caarray.client.test.gui.GuiMain.java
public GuiMain() throws Exception { JFrame frame = new JFrame("API Test Suite"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout(6, 6)); JPanel topPanel = new JPanel(); /* ###### Text fields for modifiable parameters ##### */ final JTextField javaHostText = new JTextField(TestProperties.getJavaServerHostname(), 20); JLabel javaHostLabel = new JLabel("Java Service Host"); JButton save = new JButton("Save"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { TestProperties.setJavaServerHostname(javaHostText.getText()); }/*from w ww. ja v a 2 s .c o m*/ }); JLabel javaPortLabel = new JLabel("Java Port"); final JTextField javaPortText = new JTextField(Integer.toString(TestProperties.getJavaServerJndiPort()), 5); JButton save2 = new JButton("Save"); save2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { int port = Integer.parseInt(javaPortText.getText()); TestProperties.setJavaServerJndiPort(port); } catch (NumberFormatException e) { System.out.println(javaPortText.getText() + " is not a valid port number."); } } }); JLabel gridHostLabel = new JLabel("Grid Service Host"); final JTextField gridHostText = new JTextField(TestProperties.getGridServerHostname(), 20); JButton save3 = new JButton("Save"); save3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { TestProperties.setGridServerHostname(gridHostText.getText()); } }); JLabel gridPortLabel = new JLabel("Grid Service Port"); final JTextField gridPortText = new JTextField(Integer.toString(TestProperties.getGridServerPort()), 5); JButton save4 = new JButton("Save"); save4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { int port = Integer.parseInt(gridPortText.getText()); TestProperties.setGridServerPort(port); } catch (NumberFormatException e) { System.out.println(gridPortText.getText() + " is not a valid port number."); } } }); JLabel excludeLabel = new JLabel("Exclude test cases (comma-separated list):"); final JTextField excludeText = new JTextField("", 30); JButton save5 = new JButton("Save"); save5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String testString = excludeText.getText(); if (testString != null) { String[] testCases = testString.split(","); if (testCases != null && testCases.length > 0) { List<Float> tests = new ArrayList<Float>(); for (String test : testCases) { try { tests.add(Float.parseFloat(test)); } catch (NumberFormatException e) { System.out.println(test + " is not a valid test case."); } } TestProperties.setExcludedTests(tests); } } } }); JLabel includeLabel = new JLabel("Include only (comma-separated list):"); final JTextField includeText = new JTextField("", 30); JButton save6 = new JButton("Save"); save6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String testString = includeText.getText(); if (testString != null) { String[] testCases = testString.split(","); if (testCases != null && testCases.length > 0) { List<Float> tests = new ArrayList<Float>(); for (String test : testCases) { try { tests.add(Float.parseFloat(test)); } catch (NumberFormatException e) { System.out.println(test + " is not a valid test case."); } } TestProperties.setIncludeOnlyTests(tests); } } } }); JLabel threadLabel = new JLabel("Number of threads:"); final JTextField threadText = new JTextField(Integer.toString(TestProperties.getNumThreads()), 5); JButton save7 = new JButton("Save"); save7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { int threads = Integer.parseInt(threadText.getText()); TestProperties.setNumThreads(threads); } catch (NumberFormatException e) { System.out.println(threadText.getText() + " is not a valid thread number."); } } }); GridBagLayout topLayout = new GridBagLayout(); topPanel.setLayout(topLayout); JLabel[] labels = new JLabel[] { javaHostLabel, javaPortLabel, gridHostLabel, gridPortLabel, excludeLabel, includeLabel, threadLabel }; JTextField[] textFields = new JTextField[] { javaHostText, javaPortText, gridHostText, gridPortText, excludeText, includeText, threadText }; JButton[] buttons = new JButton[] { save, save2, save3, save4, save5, save6, save7 }; for (int i = 0; i < labels.length; i++) { GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = i; topPanel.add(labels[i], c); c.gridx = 1; topPanel.add(textFields[i], c); c.gridx = 2; topPanel.add(buttons[i], c); } frame.getContentPane().add(topPanel, BorderLayout.PAGE_START); GridLayout bottomLayout = new GridLayout(0, 4); selectionPanel.setLayout(bottomLayout); JCheckBox selectAll = new JCheckBox("Select/Deselect All"); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox box = (JCheckBox) e.getSource(); selectAll(box.isSelected()); } }); selectionPanel.add(selectAll); JCheckBox excludeLongTests = new JCheckBox("Exclude Long Tests"); excludeLongTests.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox box = (JCheckBox) e.getSource(); if (box.isSelected()) { TestProperties.excludeLongTests(); } else { TestProperties.removeExcludedLongTests(); } } }); TestProperties.excludeLongTests(); excludeLongTests.setSelected(true); selectionPanel.add(excludeLongTests); //Initialize check boxes corresponding to test categories initializeTests(); centerPanel.setLayout(new GridLayout(0, 1)); centerPanel.add(selectionPanel); //Redirect System messages to gui JScrollPane textScroll = new JScrollPane(); textScroll.setViewportView(textDisplay); System.setOut(new PrintStream(new JTextAreaOutputStream(textDisplay))); System.setErr(new PrintStream(new JTextAreaOutputStream(textDisplay))); centerPanel.add(textScroll); JScrollPane scroll = new JScrollPane(centerPanel); frame.getContentPane().add(scroll, BorderLayout.CENTER); JButton runButton = new JButton("Run Tests"); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { runTests(); } catch (Exception e) { System.out.println("An error occured executing the tests: " + e.getClass() + ". Check error log for details."); log.error("Exception encountered:", e); } } }); JPanel bottomPanel = new JPanel(); bottomPanel.add(runButton); frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END); frame.pack(); frame.setVisible(true); }
From source file:au.org.ala.delta.intkey.ui.DefineButtonDialog.java
public DefineButtonDialog(Frame owner, boolean modal) { super(owner, modal); setPreferredSize(new Dimension(500, 430)); ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(DefineButtonDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(DefineButtonDialog.class, this); setTitle(title);//from w ww .ja v a2 s .c o m _okButtonPressed = false; _pnlButtons = new JPanel(); getContentPane().add(_pnlButtons, BorderLayout.SOUTH); _btnOk = new JButton(); _btnOk.setAction(actionMap.get("DefineButtonDialog_OK")); _pnlButtons.add(_btnOk); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("DefineButtonDialog_Cancel")); _pnlButtons.add(_btnCancel); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("DefineButtonDialog_Help")); _btnHelp.setEnabled(false); _pnlButtons.add(_btnHelp); _pnlMain = new JPanel(); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(5, 0)); _pnlButtonProperties = new JPanel(); _pnlButtonProperties.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, null, null), new EmptyBorder(5, 5, 5, 5)))); _pnlMain.add(_pnlButtonProperties, BorderLayout.NORTH); GridBagLayout gbl__pnlButtonProperties = new GridBagLayout(); gbl__pnlButtonProperties.columnWidths = new int[] { 475, 0 }; gbl__pnlButtonProperties.rowHeights = new int[] { 14, 23, 14, 20, 14, 20, 14, 0, 23, 23, 23, 23, 0 }; gbl__pnlButtonProperties.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl__pnlButtonProperties.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlButtonProperties.setLayout(gbl__pnlButtonProperties); _lblEnterNameOf = new JLabel(enterFileNameCaption); _lblEnterNameOf.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterNameOf = new GridBagConstraints(); gbc__lblEnterNameOf.anchor = GridBagConstraints.WEST; gbc__lblEnterNameOf.insets = new Insets(0, 0, 5, 0); gbc__lblEnterNameOf.gridx = 0; gbc__lblEnterNameOf.gridy = 0; _pnlButtonProperties.add(_lblEnterNameOf, gbc__lblEnterNameOf); _pnlFile = new JPanel(); GridBagConstraints gbc__pnlFile = new GridBagConstraints(); gbc__pnlFile.fill = GridBagConstraints.HORIZONTAL; gbc__pnlFile.insets = new Insets(0, 0, 5, 0); gbc__pnlFile.gridx = 0; gbc__pnlFile.gridy = 1; _pnlButtonProperties.add(_pnlFile, gbc__pnlFile); _pnlFile.setLayout(new BorderLayout(0, 0)); _txtFldFileName = new JTextField(); _pnlFile.add(_txtFldFileName, BorderLayout.CENTER); _txtFldFileName.setColumns(10); _btnBrowse = new JButton(); _btnBrowse.setAction(actionMap.get("DefineButtonDialog_Browse")); _pnlFile.add(_btnBrowse, BorderLayout.EAST); _lblEnterTheCommands = new JLabel(enterCommandsCaption); _lblEnterTheCommands.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterTheCommands = new GridBagConstraints(); gbc__lblEnterTheCommands.anchor = GridBagConstraints.WEST; gbc__lblEnterTheCommands.insets = new Insets(0, 0, 5, 0); gbc__lblEnterTheCommands.gridx = 0; gbc__lblEnterTheCommands.gridy = 2; _pnlButtonProperties.add(_lblEnterTheCommands, gbc__lblEnterTheCommands); _txtFldCommands = new JTextField(); GridBagConstraints gbc__txtFldCommands = new GridBagConstraints(); gbc__txtFldCommands.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldCommands.insets = new Insets(0, 0, 5, 0); gbc__txtFldCommands.gridx = 0; gbc__txtFldCommands.gridy = 3; _pnlButtonProperties.add(_txtFldCommands, gbc__txtFldCommands); _txtFldCommands.setColumns(10); _lblEnterBriefHelp = new JLabel(enterBriefHelpCaption); _lblEnterBriefHelp.setAlignmentY(Component.TOP_ALIGNMENT); GridBagConstraints gbc__lblEnterBriefHelp = new GridBagConstraints(); gbc__lblEnterBriefHelp.anchor = GridBagConstraints.NORTHWEST; gbc__lblEnterBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__lblEnterBriefHelp.gridx = 0; gbc__lblEnterBriefHelp.gridy = 4; _pnlButtonProperties.add(_lblEnterBriefHelp, gbc__lblEnterBriefHelp); _txtFldBriefHelp = new JTextField(); GridBagConstraints gbc__txtFldBriefHelp = new GridBagConstraints(); gbc__txtFldBriefHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldBriefHelp.gridx = 0; gbc__txtFldBriefHelp.gridy = 5; _pnlButtonProperties.add(_txtFldBriefHelp, gbc__txtFldBriefHelp); _txtFldBriefHelp.setColumns(10); _lblEnterMoreDetailed = new JLabel(enterDetailedHelpCaption); GridBagConstraints gbc__lblEnterMoreDetailed = new GridBagConstraints(); gbc__lblEnterMoreDetailed.anchor = GridBagConstraints.WEST; gbc__lblEnterMoreDetailed.insets = new Insets(0, 0, 5, 0); gbc__lblEnterMoreDetailed.gridx = 0; gbc__lblEnterMoreDetailed.gridy = 6; _pnlButtonProperties.add(_lblEnterMoreDetailed, gbc__lblEnterMoreDetailed); _txtFldDetailedHelp = new JTextField(); GridBagConstraints gbc__txtFldDetailedHelp = new GridBagConstraints(); gbc__txtFldDetailedHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldDetailedHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldDetailedHelp.gridx = 0; gbc__txtFldDetailedHelp.gridy = 7; _pnlButtonProperties.add(_txtFldDetailedHelp, gbc__txtFldDetailedHelp); _txtFldDetailedHelp.setColumns(10); _chckbxEnableOnlyIfUsedCharacters = new JCheckBox(enableOnlyIfUsedCaption); GridBagConstraints gbc__chckbxEnableOnlyIf = new GridBagConstraints(); gbc__chckbxEnableOnlyIf.anchor = GridBagConstraints.WEST; gbc__chckbxEnableOnlyIf.insets = new Insets(0, 0, 5, 0); gbc__chckbxEnableOnlyIf.gridx = 0; gbc__chckbxEnableOnlyIf.gridy = 8; _pnlButtonProperties.add(_chckbxEnableOnlyIfUsedCharacters, gbc__chckbxEnableOnlyIf); _rdbtnEnableInAll = new JRadioButton(enableInAllModesCaption); GridBagConstraints gbc__rdbtnEnableInAll = new GridBagConstraints(); gbc__rdbtnEnableInAll.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAll.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInAll.gridx = 0; gbc__rdbtnEnableInAll.gridy = 9; _pnlButtonProperties.add(_rdbtnEnableInAll, gbc__rdbtnEnableInAll); _rdbtnEnableInNormal = new JRadioButton(enableInNormalModeCaption); GridBagConstraints gbc__rdbtnEnableInNormal = new GridBagConstraints(); gbc__rdbtnEnableInNormal.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInNormal.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInNormal.gridx = 0; gbc__rdbtnEnableInNormal.gridy = 10; _pnlButtonProperties.add(_rdbtnEnableInNormal, gbc__rdbtnEnableInNormal); _rdbtnEnableInAdvanced = new JRadioButton(enableInAdvancedModeCaption); GridBagConstraints gbc__rdbtnEnableInAdvanced = new GridBagConstraints(); gbc__rdbtnEnableInAdvanced.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAdvanced.gridx = 0; gbc__rdbtnEnableInAdvanced.gridy = 11; _pnlButtonProperties.add(_rdbtnEnableInAdvanced, gbc__rdbtnEnableInAdvanced); _pnlSpaceRemoveAll = new JPanel(); _pnlSpaceRemoveAll.setBorder(new EmptyBorder(0, 10, 0, 0)); _pnlMain.add(_pnlSpaceRemoveAll, BorderLayout.SOUTH); _pnlSpaceRemoveAll.setLayout(new BoxLayout(_pnlSpaceRemoveAll, BoxLayout.Y_AXIS)); _chckbxInsertASpace = new JCheckBox(insertSpaceCaption); _chckbxInsertASpace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _insertSpace = !_insertSpace; if (_insertSpace) { _removeAllButtons = false; _chckbxRemoveAllButtons.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxInsertASpace); _chckbxRemoveAllButtons = new JCheckBox(removeAllCaption); _chckbxRemoveAllButtons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _removeAllButtons = !_removeAllButtons; if (_removeAllButtons) { _insertSpace = false; _chckbxInsertASpace.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxRemoveAllButtons); _pnlButtonProperties.setEnabled(false); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(_rdbtnEnableInAll); btnGroup.add(_rdbtnEnableInNormal); btnGroup.add(_rdbtnEnableInAdvanced); _rdbtnEnableInAll.setSelected(true); }
From source file:analysers.FilterValidatedDialog.java
/** * Create the dialog./* w ww . ja v a2 s . c o m*/ */ public FilterValidatedDialog() { setTitle("Validated Lineages: Export Filter"); setBounds(100, 100, 632, 348); 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[] { 160, 440, 0 }; gbl_contentPanel.rowHeights = new int[] { 1, 28, 28, 28, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblCriterion = new JLabel("Lineage Criterion"); lblCriterion.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblCriterion = new GridBagConstraints(); gbc_lblCriterion.insets = new Insets(0, 0, 5, 5); gbc_lblCriterion.gridx = 0; gbc_lblCriterion.gridy = 0; contentPanel.add(lblCriterion, gbc_lblCriterion); } { JLabel lblValue = new JLabel("Value"); lblValue.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblValue = new GridBagConstraints(); gbc_lblValue.insets = new Insets(0, 0, 5, 0); gbc_lblValue.gridx = 1; gbc_lblValue.gridy = 0; contentPanel.add(lblValue, gbc_lblValue); } { lblMinLineageLength = new JLabel("Min. Length (frames)"); GridBagConstraints gbc_lblMinLineageLength = new GridBagConstraints(); gbc_lblMinLineageLength.fill = GridBagConstraints.BOTH; gbc_lblMinLineageLength.insets = new Insets(0, 0, 5, 5); gbc_lblMinLineageLength.gridx = 0; gbc_lblMinLineageLength.gridy = 1; contentPanel.add(lblMinLineageLength, gbc_lblMinLineageLength); } { minLinLen = new JTextField(); GridBagConstraints gbc_minLinLen = new GridBagConstraints(); gbc_minLinLen.anchor = GridBagConstraints.NORTH; gbc_minLinLen.fill = GridBagConstraints.HORIZONTAL; gbc_minLinLen.insets = new Insets(0, 0, 5, 0); gbc_minLinLen.gridx = 1; gbc_minLinLen.gridy = 1; contentPanel.add(minLinLen, gbc_minLinLen); minLinLen.setText("1"); minLinLen.setColumns(3); } { lblStartFrameOf = new JLabel("Max. Start Frame"); GridBagConstraints gbc_lblStartFrameOf = new GridBagConstraints(); gbc_lblStartFrameOf.fill = GridBagConstraints.HORIZONTAL; gbc_lblStartFrameOf.insets = new Insets(0, 0, 5, 5); gbc_lblStartFrameOf.gridx = 0; gbc_lblStartFrameOf.gridy = 2; contentPanel.add(lblStartFrameOf, gbc_lblStartFrameOf); } { startLin = new JTextField(); GridBagConstraints gbc_startLin = new GridBagConstraints(); gbc_startLin.insets = new Insets(0, 0, 5, 0); gbc_startLin.fill = GridBagConstraints.HORIZONTAL; gbc_startLin.gridx = 1; gbc_startLin.gridy = 2; contentPanel.add(startLin, gbc_startLin); startLin.setText("-1"); startLin.setColumns(3); } { JButton btnPreview = new JButton("Preview"); btnPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { preview.setText(makePreview()); } }); GridBagConstraints gbc_btnPreview = new GridBagConstraints(); gbc_btnPreview.insets = new Insets(0, 0, 5, 5); gbc_btnPreview.gridx = 0; gbc_btnPreview.gridy = 3; contentPanel.add(btnPreview, gbc_btnPreview); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 3; contentPanel.add(scrollPane, gbc_scrollPane); { preview = new JTextArea(); scrollPane.setViewportView(preview); preview.setEditable(false); preview.setColumns(10); preview.setTabSize(4); } } { JLabel lblOptions = new JLabel("Options"); GridBagConstraints gbc_lblOptions = new GridBagConstraints(); gbc_lblOptions.insets = new Insets(0, 0, 0, 5); gbc_lblOptions.gridx = 0; gbc_lblOptions.gridy = 4; contentPanel.add(lblOptions, gbc_lblOptions); } { JPanel panel = new JPanel(); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.anchor = GridBagConstraints.NORTH; gbc_panel.fill = GridBagConstraints.HORIZONTAL; gbc_panel.gridx = 1; gbc_panel.gridy = 4; contentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 69, 169, 162, 0 }; gbl_panel.rowHeights = new int[] { 23, 23, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { rdbtnExportMeanIntensity = new JRadioButton("Export Mean Intensity"); rdbtnExportMeanIntensity.setSelected(true); buttonGroup.add(rdbtnExportMeanIntensity); GridBagConstraints gbc_rdbtnExportMeanIntensity = new GridBagConstraints(); gbc_rdbtnExportMeanIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMeanIntensity.insets = new Insets(0, 0, 5, 5); gbc_rdbtnExportMeanIntensity.gridx = 1; gbc_rdbtnExportMeanIntensity.gridy = 0; panel.add(rdbtnExportMeanIntensity, gbc_rdbtnExportMeanIntensity); } { rdbtnExportMaxIntensity = new JRadioButton("Export Max Intensity"); buttonGroup.add(rdbtnExportMaxIntensity); GridBagConstraints gbc_rdbtnExportMaxIntensity = new GridBagConstraints(); gbc_rdbtnExportMaxIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMaxIntensity.insets = new Insets(0, 0, 5, 0); gbc_rdbtnExportMaxIntensity.gridx = 2; gbc_rdbtnExportMaxIntensity.gridy = 0; panel.add(rdbtnExportMaxIntensity, gbc_rdbtnExportMaxIntensity); } { chckbxExportPositions = new JCheckBox("Export Cell Positions and Areas in CSV"); GridBagConstraints gbc_chckbxExportPositions = new GridBagConstraints(); gbc_chckbxExportPositions.anchor = GridBagConstraints.NORTH; gbc_chckbxExportPositions.gridwidth = 2; gbc_chckbxExportPositions.gridx = 1; gbc_chckbxExportPositions.gridy = 1; panel.add(chckbxExportPositions, gbc_chckbxExportPositions); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (validateFields()) { Prefs.set("TrackApp.FilterValidatedDialog.startLin", valStartLin); Prefs.set("TrackApp.FilterValidatedDialog.minLinLen", valMinLinLen); Prefs.set("TrackApp.FilterValidatedDialog.exportMean", doExportMean); Prefs.set("TrackApp.FilterValidatedDialog.exportPositions", doExportPositions); Prefs.savePreferences(); dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java
/** * Customization of external program paths. * * @param prefs a <code>JabRefPreferences</code> value *///from www . java2 s. c o m public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) { this.prefs = prefs; this.frame = frame; setLayout(new BorderLayout()); TableModel tm = new AbstractTableModel() { @Override public int getRowCount() { return rowCount; } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { int internalRow = row; if (internalRow == 0) { return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth); } internalRow--; if (internalRow >= tableRows.size()) { return ""; } Object rowContent = tableRows.get(internalRow); if (rowContent == null) { return ""; } TableRow tr = (TableRow) rowContent; // Only two columns if (column == 0) { return tr.getName(); } else { return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : ""; } } @Override public String getColumnName(int col) { return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width"); } @Override public Class<?> getColumnClass(int column) { if (column == 0) { return String.class; } return Integer.class; } @Override public boolean isCellEditable(int row, int col) { return !((row == 0) && (col == 0)); } @Override public void setValueAt(Object value, int row, int col) { tableChanged = true; // Make sure the vector is long enough. while (row >= tableRows.size()) { tableRows.add(new TableRow("", -1)); } if ((row == 0) && (col == 1)) { ncWidth = Integer.parseInt(value.toString()); return; } TableRow rowContent = tableRows.get(row - 1); if (col == 0) { rowContent.setName(value.toString()); if ("".equals(getValueAt(row, 1))) { setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1); } } else { if (value == null) { rowContent.setLength(-1); } else { rowContent.setLength(Integer.parseInt(value.toString())); } } } }; colSetup = new JTable(tm); TableColumnModel cm = colSetup.getColumnModel(); cm.getColumn(0).setPreferredWidth(140); cm.getColumn(1).setPreferredWidth(80); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); JPanel pan = new JPanel(); JPanel tabPanel = new JPanel(); tabPanel.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200)); sp.setMinimumSize(new Dimension(250, 300)); tabPanel.add(sp, BorderLayout.CENTER); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setFloatable(false); AddRowAction addRow = new AddRowAction(); DeleteRowAction deleteRow = new DeleteRowAction(); MoveRowUpAction moveUp = new MoveRowUpAction(); MoveRowDownAction moveDown = new MoveRowDownAction(); toolBar.setBorder(null); toolBar.add(addRow); toolBar.add(deleteRow); toolBar.addSeparator(); toolBar.add(moveUp); toolBar.add(moveDown); tabPanel.add(toolBar, BorderLayout.EAST); fileColumn = new JCheckBox(Localization.lang("Show file column")); urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column")); preferUrl = new JRadioButton(Localization.lang("Show URL first")); preferDoi = new JRadioButton(Localization.lang("Show DOI first")); ButtonGroup preferUrlDoiGroup = new ButtonGroup(); preferUrlDoiGroup.add(preferUrl); preferUrlDoiGroup.add(preferDoi); urlColumn.addChangeListener(arg0 -> { preferUrl.setEnabled(urlColumn.isSelected()); preferDoi.setEnabled(urlColumn.isSelected()); }); arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column")); Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); String[] fileTypeNames = new String[fileTypes.size()]; int i = 0; for (ExternalFileType fileType : fileTypes) { fileTypeNames[i++] = fileType.getName(); } listOfFileColumns = new JList<>(fileTypeNames); JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns); listOfFileColumns.setVisibleRowCount(3); extraFileColumns = new JCheckBox(Localization.lang("Show extra columns")); extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected())); /*** begin: special table columns and special fields ***/ JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS) .getHelpButton(); rankingColumn = new JCheckBox(Localization.lang("Show rank")); qualityColumn = new JCheckBox(Localization.lang("Show quality")); priorityColumn = new JCheckBox(Localization.lang("Show priority")); relevanceColumn = new JCheckBox(Localization.lang("Show relevance")); printedColumn = new JCheckBox(Localization.lang("Show printed status")); readStatusColumn = new JCheckBox(Localization.lang("Show read status")); // "sync keywords" and "write special" fields may be configured mutually exclusive only // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense) // To avoid confusion, we opted to make the setting mutually exclusive syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords")); writeSpecialFields = new JRadioButton( Localization.lang("Write values of special fields as separate fields to BibTeX")); ButtonGroup group = new ButtonGroup(); group.add(syncKeywords); group.add(writeSpecialFields); specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields")); specialFieldsEnabled.addChangeListener(event -> { boolean isEnabled = specialFieldsEnabled.isSelected(); rankingColumn.setEnabled(isEnabled); qualityColumn.setEnabled(isEnabled); priorityColumn.setEnabled(isEnabled); relevanceColumn.setEnabled(isEnabled); printedColumn.setEnabled(isEnabled); readStatusColumn.setEnabled(isEnabled); syncKeywords.setEnabled(isEnabled); writeSpecialFields.setEnabled(isEnabled); }); builder.appendSeparator(Localization.lang("Special table columns")); builder.nextLine(); builder.append(pan); DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder( new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref")); CellConstraints cc = new CellConstraints(); specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3)); specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2)); specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2)); specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2)); specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2)); specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2)); specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2)); specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2)); specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2)); specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2)); specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2)); specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2)); specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3)); specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4)); specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2)); specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2)); specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6)); builder.append(specialTableColumnsBuilder.getPanel()); builder.nextLine(); /*** end: special table columns and special fields ***/ builder.appendSeparator(Localization.lang("Entry table columns")); builder.nextLine(); builder.append(pan); builder.append(tabPanel); builder.nextLine(); builder.append(pan); JButton buttonWidth = new JButton(new UpdateWidthsAction()); JButton buttonOrder = new JButton(new UpdateOrderAction()); builder.append(buttonWidth); builder.nextLine(); builder.append(pan); builder.append(buttonOrder); builder.nextLine(); builder.append(pan); builder.nextLine(); pan = builder.getPanel(); pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(pan, BorderLayout.CENTER); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private void handleFirstStart() { if (!ServiceFunctions.getPropertiesFile().exists()) { JOptionPane.showMessageDialog(mainFrame, "Willkommen bei " + APP_NAME, "Willkommen", JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("<html>Wenn Sie " + APP_NAME + " nutzen mchten, mssen Sie die folgende Punkte akzeptieren." + "<ul>" + "<li>This software is under the GNU GENERAL PUBLIC LICENSE Version 3.<br>" + "View https://github.com/kekru/ILIASDownloader2/blob/master/LICENSE for detailed information." + "</li>" + "<li>Dieses Programm wird Ihr Passwort nicht speichern</li>" + "<li>Dieses Programm wird Ihren Loginnamen und Ihr Passwort nur an den von Ihnen angegebenen Server senden</li>" + "<li>Ihr Passwort wird im Arbeitsspeicher dieses Computers <b>nicht</b> verschlsselt gespeichert.<br>Ein Schadprogramm knnte den Arbeitsspeicher auslesen und so an Ihre Logindaten gelangen.<br>Der Autor von " + APP_NAME + " bernimmt keine Verantwortung fr die Sicherheit Ihrer Logindaten</li>" + "<li>Im nchsten Schritt mssen Sie Ihren Ilias Server eingeben. Bitte achten Sie darauf, dass die Adresse mit 'https://' beginnt.<br>Das bewirkt eine gesicherte Verbindung zwischen " + APP_NAME + " und Ihrem Ilias Server</li>" + "<li>Die Nutzung und die Weitergabe von " + APP_NAME + " ist kostenlos.</li>" + "<li>Beim Programmstart wird auf Updates berprft. Dabei wird lediglich der Programmname an den Updateserver gesendet. Ihre Logindaten oder andere persnliche Daten werden nicht bertragen.<br>Wenn Sie die Updatefunktion ausschalten mchten, starten Sie das Programm mit dem Parameter '" + StartGui.NO_UPDATER + "'</li>" + "</ul>" + "</html>"), BorderLayout.NORTH); JButton licenseButton = new JButton("Open GNU GENERAL PUBLIC LICENSE Version 3"); licenseButton.addActionListener(new ActionListener() { @Override//from w ww .ja va 2 s . co m public void actionPerformed(ActionEvent e) { openWebsiteLicense(); } }); panel.add(licenseButton, BorderLayout.CENTER); JCheckBox checkboxAccept = new JCheckBox( "Ich akzeptiere die hier aufgefhrten Bedingungen/I accept these agreements."); checkboxAccept.setSelected(false); panel.add(checkboxAccept, BorderLayout.SOUTH); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Bedingungen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) && checkboxAccept.isSelected()) { chooseServer(); } else { System.exit(0); } } }
From source file:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java
private void layoutAddKeepFilesToEmptyCheckBox(JPanel contentPane, int row) { // Delete Empty Folder(s) JLabel addKeepFilesToEmptyFoldersCheckBoxLabel = new JLabel( bagView.getPropertyMessage("bag.label.addkeepfilestoemptyfolders")); addKeepFilesToEmptyFoldersCheckBoxLabel .setToolTipText(bagView.getPropertyMessage("bag.addkeepfilestoemptyfolders.help")); addKeepFilesToEmptyFoldersCheckBox = new JCheckBox(bagView.getPropertyMessage("")); addKeepFilesToEmptyFoldersCheckBox.setSelected(bag.isAddKeepFilesToEmptyFolders()); addKeepFilesToEmptyFoldersCheckBox.addActionListener(new AddKeepFilesToEmptyFoldersHandler()); GridBagConstraints glbc = new GridBagConstraints(); JLabel spacerLabel = new JLabel(); glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); contentPane.add(addKeepFilesToEmptyFoldersCheckBoxLabel, glbc); glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); contentPane.add(addKeepFilesToEmptyFoldersCheckBox, glbc); glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); contentPane.add(spacerLabel, glbc);//from ww w . j a v a2s .c o m }
From source file:BasicDnD.java
public BasicDnD() { super(new BorderLayout()); JPanel leftPanel = createVerticalBoxPanel(); JPanel rightPanel = createVerticalBoxPanel(); // Create a table model. DefaultTableModel tm = new DefaultTableModel(); tm.addColumn("Column 0"); tm.addColumn("Column 1"); tm.addColumn("Column 2"); tm.addColumn("Column 3"); tm.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" }); tm.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" }); tm.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" }); tm.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" }); // LEFT COLUMN // Use the table model to create a table. table = new JTable(tm); leftPanel.add(createPanelForComponent(table, "JTable")); // Create a color chooser. colorChooser = new JColorChooser(); leftPanel.add(createPanelForComponent(colorChooser, "JColorChooser")); // RIGHT COLUMN // Create a textfield. textField = new JTextField(30); textField.setText("Favorite foods:\nPizza, Moussaka, Pot roast"); rightPanel.add(createPanelForComponent(textField, "JTextField")); // Create a scrolled text area. textArea = new JTextArea(5, 30); textArea.setText("Favorite shows:\nBuffy, Alias, Angel"); JScrollPane scrollPane = new JScrollPane(textArea); rightPanel.add(createPanelForComponent(scrollPane, "JTextArea")); // Create a list model and a list. DefaultListModel listModel = new DefaultListModel(); listModel.addElement("Martha Washington"); listModel.addElement("Abigail Adams"); listModel.addElement("Martha Randolph"); listModel.addElement("Dolley Madison"); listModel.addElement("Elizabeth Monroe"); listModel.addElement("Louisa Adams"); listModel.addElement("Emily Donelson"); list = new JList(listModel); list.setVisibleRowCount(-1);// w ww . j a v a 2 s. c o m list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setTransferHandler(new TransferHandler() { public boolean canImport(TransferHandler.TransferSupport info) { // we only import Strings if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); if (dl.getIndex() == -1) { return false; } return true; } public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } // Check for String flavor if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { displayDropLocation("List doesn't accept a drop of this type."); return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); DefaultListModel listModel = (DefaultListModel) list.getModel(); int index = dl.getIndex(); boolean insert = dl.isInsert(); // Get the current string under the drop. String value = (String) listModel.getElementAt(index); // Get the string that is being dropped. Transferable t = info.getTransferable(); String data; try { data = (String) t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { return false; } // Display a dialog with the drop information. String dropValue = "\"" + data + "\" dropped "; if (dl.isInsert()) { if (dl.getIndex() == 0) { displayDropLocation(dropValue + "at beginning of list"); } else if (dl.getIndex() >= list.getModel().getSize()) { displayDropLocation(dropValue + "at end of list"); } else { String value1 = (String) list.getModel().getElementAt(dl.getIndex() - 1); String value2 = (String) list.getModel().getElementAt(dl.getIndex()); displayDropLocation(dropValue + "between \"" + value1 + "\" and \"" + value2 + "\""); } } else { displayDropLocation(dropValue + "on top of " + "\"" + value + "\""); } /** * This is commented out for the basicdemo.html tutorial page. * If you * add this code snippet back and delete the * "return false;" line, the * list will accept drops * of type string. // Perform the actual * import. if (insert) { listModel.add(index, data); } else { * listModel.set(index, data); } return true; */ return false; } public int getSourceActions(JComponent c) { return COPY; } protected Transferable createTransferable(JComponent c) { JList list = (JList) c; Object[] values = list.getSelectedValues(); StringBuffer buff = new StringBuffer(); for (int i = 0; i < values.length; i++) { Object val = values[i]; buff.append(val == null ? "" : val.toString()); if (i != values.length - 1) { buff.append("\n"); } } return new StringSelection(buff.toString()); } }); list.setDropMode(DropMode.ON_OR_INSERT); JScrollPane listView = new JScrollPane(list); listView.setPreferredSize(new Dimension(300, 100)); rightPanel.add(createPanelForComponent(listView, "JList")); // Create a tree. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Mia Familia"); DefaultMutableTreeNode sharon = new DefaultMutableTreeNode("Sharon"); rootNode.add(sharon); DefaultMutableTreeNode maya = new DefaultMutableTreeNode("Maya"); sharon.add(maya); DefaultMutableTreeNode anya = new DefaultMutableTreeNode("Anya"); sharon.add(anya); sharon.add(new DefaultMutableTreeNode("Bongo")); maya.add(new DefaultMutableTreeNode("Muffin")); anya.add(new DefaultMutableTreeNode("Winky")); DefaultTreeModel model = new DefaultTreeModel(rootNode); tree = new JTree(model); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JScrollPane treeView = new JScrollPane(tree); treeView.setPreferredSize(new Dimension(300, 100)); rightPanel.add(createPanelForComponent(treeView, "JTree")); // Create the toggle button. toggleDnD = new JCheckBox("Turn on Drag and Drop"); toggleDnD.setActionCommand("toggleDnD"); toggleDnD.addActionListener(this); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); splitPane.setOneTouchExpandable(true); add(splitPane, BorderLayout.CENTER); add(toggleDnD, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:com.mirth.connect.client.ui.components.rsta.FindReplaceDialog.java
private void initComponents() { setLayout(new MigLayout("insets 11, novisualpadding, hidemode 3, fill, gap 6")); setBackground(UIConstants.COMBO_BOX_BACKGROUND); getContentPane().setBackground(getBackground()); findPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill, gap 6")); findPanel.setBackground(getBackground()); ActionListener findActionListener = new ActionListener() { @Override/*w w w .ja v a2s . c o m*/ public void actionPerformed(ActionEvent evt) { find(); } }; findLabel = new JLabel("Find text:"); findComboBox = new JComboBox<String>(); findComboBox.setEditable(true); findComboBox.setBackground(UIConstants.BACKGROUND_COLOR); findComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && evt.getModifiers() == 0) { find(); } } }); ActionListener replaceActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replace(); } }; replaceLabel = new JLabel("Replace with:"); replaceComboBox = new JComboBox<String>(); replaceComboBox.setEditable(true); replaceComboBox.setBackground(UIConstants.BACKGROUND_COLOR); directionPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); directionPanel.setBackground(getBackground()); directionPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Direction", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); ButtonGroup directionButtonGroup = new ButtonGroup(); directionForwardRadio = new JRadioButton("Forward"); directionForwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionForwardRadio); directionBackwardRadio = new JRadioButton("Backward"); directionBackwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionBackwardRadio); optionsPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); optionsPanel.setBackground(getBackground()); optionsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Options", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); wrapSearchCheckBox = new JCheckBox("Wrap Search"); matchCaseCheckBox = new JCheckBox("Match Case"); regularExpressionCheckBox = new JCheckBox("Regular Expression"); wholeWordCheckBox = new JCheckBox("Whole Word"); findButton = new JButton("Find"); findButton.addActionListener(findActionListener); replaceButton = new JButton("Replace"); replaceButton.addActionListener(replaceActionListener); replaceAllButton = new JButton("Replace All"); replaceAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replaceAll(); } }); warningLabel = new JLabel(); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); }