List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text, Icon icon)
From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java
/** * Returns the panel for the work flow./*from w w w.j a va 2 s. co m*/ * * @return the panel for the work flow */ private JComponent createWorkflow() { JPanel workflowPanel = new JPanel(new GridLayout(1, 3)); listModelMajor2 = new DefaultListModel(); listModelMajor3 = new DefaultListModel(); listModelSupplement1 = new DefaultListModel(); listModelSupplement2 = new DefaultListModel(); listModelSupplement3 = new DefaultListModel(); listPluginMajor2 = new JList(listModelMajor2); listPluginMajor3 = new JList(listModelMajor3); listPluginSupplement1 = new JList(listModelSupplement1); listPluginSupplement2 = new JList(listModelSupplement2); listPluginSupplement3 = new JList(listModelSupplement3); // phase1 JPanel phasePanel = new JPanel(new GridLayout(1, 1)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase1. Plain Text Processing")); JPanel listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement1); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); // phase2 phasePanel = new JPanel(new GridLayout(1, 2)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase2. Morphological Analysis")); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginMajor2); listPanel.add(scroll); phasePanel.add(listPanel); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement2); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); // phase3 phasePanel = new JPanel(new GridLayout(1, 2)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase3. Part Of Speech Tagging")); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginMajor3); listPanel.add(scroll); phasePanel.add(listPanel); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement3); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); ///////////////////////////////////////////////////////////////////////////////////// JPanel controlPanel = new JPanel(new GridLayout(4, 1)); controlPanel.setBorder(BorderFactory.createTitledBorder("Workflow Control")); buttonActivate = new JButton("Activate the workflow"); buttonAnalysis = new JButton("Analyze Text"); buttonReset = new JButton("Close the workflow"); JPanel threadPanel = new JPanel(new GridLayout(1, 1)); radioMultiThread = new JRadioButton("Mutli-thread Mode", true); radioSingleThread = new JRadioButton("Single-thread Mode", false); threadPanel.setBorder(BorderFactory.createTitledBorder("Thread Mode")); threadPanel.add(radioMultiThread); threadPanel.add(radioSingleThread); ButtonGroup groupThread = new ButtonGroup(); groupThread.add(radioMultiThread); groupThread.add(radioSingleThread); controlPanel.add(threadPanel); controlPanel.add(buttonActivate); controlPanel.add(buttonAnalysis); controlPanel.add(buttonReset); buttonAnalysis.setEnabled(false); buttonReset.setEnabled(false); ///////////////////////////////////////////////////////////////////////////////////// JPanel pluginInfoPanel = new JPanel(new GridLayout(1, 1)); pluginInfoPanel.setBorder(BorderFactory.createTitledBorder("Plug-in Information")); areaPluginInfo = new JTextArea(); areaPluginInfo.setLineWrap(true); scroll = new JScrollPane(); scroll.setViewportView(areaPluginInfo); pluginInfoPanel.add(scroll); JPanel infoPanel = new JPanel(new GridLayout(1, 2)); infoPanel.add(pluginInfoPanel); infoPanel.add(controlPanel); JPanel panel = new JPanel(new GridLayout(2, 1)); workflowPanel.setBorder(BorderFactory.createTitledBorder("HanNanum Workflow")); panel.add(workflowPanel); panel.add(infoPanel); return panel; }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void initComps() { final ButtonGroup examples = new ButtonGroup(); examples.add(new JRadioButton(Main.Examples.DEPRESSION.name, true)); examples.add(new JRadioButton(Main.Examples.HYPERTENSION.name)); final AbstractAction exampleAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { d_main.loadExampleDomain(Main.Examples.findFileName(getSelection(examples).getText())); closeWelcome();//from w ww. j av a 2 s . c om } }; final AbstractAction loadAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { if (d_main.fileLoadActions() == JFileChooser.APPROVE_OPTION) { closeWelcome(); } } }; final AbstractAction newAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { d_main.newFileActions(); closeWelcome(); } }; FormLayout layout = new FormLayout("left:pref, " + SPACING + "px, left:pref", "p, 3dlu, p, " + SPACING + "px, p, " + SPACING + "px, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); final CellConstraints cc = new CellConstraints(); builder.add(createImageLabel(FileNames.IMAGE_HEADER), cc.xyw(1, 1, 3)); builder.add(createButton("Load example", FileNames.ICON_TIP, exampleAction), cc.xy(1, 3)); final PanelBuilder radios = new PanelBuilder(new FormLayout("p, fill:pref:grow, right:pref", "p, 3dlu, p")); final ArrayList<AbstractButton> buttons = Collections.list(examples.getElements()); forAllDo(buttons, new Closure<AbstractButton>() { public void execute(final AbstractButton exampleOption) { int row = buttons.indexOf(exampleOption) == 0 ? 1 : buttons.indexOf(exampleOption) + 2; exampleOption.setOpaque(false); radios.add(exampleOption, cc.xy(1, row)); radios.add(createHelpButton(exampleOption), cc.xy(3, row)); } private JButton createHelpButton(final AbstractButton exampleOption) { JButton help = GUIFactory.createIconButton(org.drugis.mtc.gui.FileNames.ICON_ABOUT, "Information about this example"); removeBackground(help); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Examples example = Examples.findByName(exampleOption.getText()); String helpText = s_help.getHelpText(example.name().toLowerCase()); showExampleInfo(helpText); } }); return help; } }); JPanel radiosPanel = radios.getPanel(); setBorder(radiosPanel); builder.add(radiosPanel, cc.xy(3, 3)); builder.add(createButton("Open file", FileNames.ICON_OPENFILE, loadAction), cc.xy(1, 5)); JTextPane load = createLabel("Load an existing ADDIS data file stored on your computer."); builder.add(load, cc.xy(3, 5)); builder.add(createButton("New dataset", FileNames.ICON_FILE_NEW, newAction), cc.xy(1, 7)); builder.add(createLabel("Start with an empty file to build up your own data and analyses."), cc.xy(3, 7)); builder.add(createImageLabel(FileNames.IMAGE_FOOTER), cc.xyw(1, 9, 3)); setContentPane(builder.getPanel()); }
From source file:savant.view.variation.swing.VariationModule.java
public VariationModule(VariationController vc) { super(new GridBagLayout()); controller = vc;/*from w w w . j a v a2s. c o m*/ // Toolbar shared by all panels. JToolBar tools = new JToolBar(); tools.setFloatable(false); rangeField = new JTextField(); rangeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String text = rangeField.getText(); try { Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange()); controller.setLocation(bm.getReference(), (Range) bm.getRange()); } catch (ParseException x) { DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text)); } } }); tools.add(rangeField); tools.addSeparator(); JButton zoomInButton = new JButton(); zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.setBorderPainted(false); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomIn(); } }); tools.add(zoomInButton); JButton zoomOutButton = new JButton(); zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOutButton.setBorderPainted(false); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomOut(); } }); tools.add(zoomOutButton); tools.addSeparator(); JButton controlsButton = new JButton("Controls"); controlsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (controller.getTracks().length > 0) { new CaseControlDialog(controller).setVisible(true); frequencyPlot.repaint(); } else { Toolkit.getDefaultToolkit().beep(); } } }); tools.add(controlsButton); tabs = new JTabbedPane(); table = new RecordTable(new VariantTableModel(null)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { controller.navigateToRecord(controller.getData().get(table.getSelectedRow())); } } }); tabs.addTab("Table", new JScrollPane(table)); map = new VariantMap(controller); map.addMouseWheelListener(wheelListener); LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { map.repaint(); } }); JPanel mapPanel = populatePanel(map); tabs.addTab("Map", mapPanel); frequencyPlot = new AlleleFrequencyPlot(controller); frequencyPlot.addMouseWheelListener(wheelListener); JPanel frequencyPanel = populatePanel(frequencyPlot); tabs.addTab("Allele Frequency", frequencyPanel); JPanel ldPanel = new JPanel(); ldPanel.setLayout(new GridBagLayout()); ActionListener redrawForcer = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ldPlot.repaint(); } }; JRadioButton dPrimeButton = new JRadioButton("D\u2032", true); dPrimeButton.setActionCommand("true"); dPrimeButton.addActionListener(redrawForcer); JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false); rSquaredButton.setActionCommand("false"); rSquaredButton.addActionListener(redrawForcer); methodGroup = new ButtonGroup(); JPanel methodPanel = new JPanel(); methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method")); methodPanel.add(dPrimeButton); methodGroup.add(dPrimeButton); methodPanel.add(rSquaredButton); methodGroup.add(rSquaredButton); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 0.0; ldPanel.add(methodPanel, gbc); ldPlot = new LDPlot(controller); JPanel lowerLDPanel = populatePanel(ldPlot); gbc.weighty = 1.0; ldPanel.add(lowerLDPanel, gbc); tabs.addTab("LD Plot", ldPanel); gbc.weighty = 0.0; add(tools, gbc); // Create the informative cards, but don't use them. messageLabel = new JLabel(); messageLabel.setFont(MESSAGE_FONT); messagePanel = populatePanel(messageLabel); progressPanel = new ProgressPanel(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { controller.cancelDataRequests(); } }); showCard(tabs, null); }
From source file:tvbrowser.extras.reminderplugin.ReminderSettingsTab.java
/** * Creates the settings panel for this tab. *///from ww w . j a v a 2 s . com public JPanel createSettingsPanel() { FormLayout layout = new FormLayout("5dlu,pref,5dlu,pref,pref:grow,3dlu,pref,3dlu,pref,5dlu", "pref,5dlu,pref,1dlu,pref,1dlu,pref,1dlu,pref,10dlu,pref,5dlu," + "pref,10dlu,pref,5dlu,pref,10dlu,pref,5dlu,pref,10dlu," + "pref,5dlu,pref,3dlu,pref,10dlu,pref,5dlu,pref"); layout.setColumnGroups(new int[][] { { 7, 9 } }); PanelBuilder pb = new PanelBuilder(layout, new ScrollableJPanel()); pb.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); final String[] extArr = { ".wav", ".aif", ".rmf", ".au", ".mid" }; String soundFName = mSettings.getProperty("soundfile", "/"); String msg = mLocalizer.msg("soundFileFilter", "Sound file ({0})", "*" + StringUtils.join(extArr, ", *")); mReminderWindowChB = new JCheckBox(mLocalizer.msg("reminderWindow", "Reminder window"), mSettings.getProperty("usemsgbox", "false").equalsIgnoreCase("true")); mShowAlwaysOnTop = new JCheckBox(mLocalizer.msg("alwaysOnTop", "Show always on top"), mSettings.getProperty("alwaysOnTop", "true").equalsIgnoreCase("true")); mShowAlwaysOnTop.setEnabled(mReminderWindowChB.isSelected()); JPanel reminderWindowCfg = new JPanel(new FormLayout("12dlu,default:grow", "pref,1dlu,pref")); reminderWindowCfg.add(mReminderWindowChB, cc.xyw(1, 1, 2)); reminderWindowCfg.add(mShowAlwaysOnTop, cc.xy(2, 3)); mSoundFileChB = new FileCheckBox(mLocalizer.msg("playlingSound", "Play sound"), new File(soundFName), 0, false); JFileChooser soundChooser = new JFileChooser((String) null); soundChooser.setFileFilter(new ExtensionFileFilter(extArr, msg)); mSoundFileChB.setFileChooser(soundChooser); mSoundFileChB.setSelected(mSettings.getProperty("usesound", "false").equals("true")); mBeep = new JCheckBox(mLocalizer.msg("beep", "Speaker sound"), mSettings.getProperty("usebeep", "true").equalsIgnoreCase("true")); mExecFileStr = mSettings.getProperty("execfile", ""); mExecParamStr = mSettings.getProperty("execparam", ""); final JButton soundTestBt = new JButton(mLocalizer.msg("test", "Test")); mExecChB = new JCheckBox(mLocalizer.msg("executeProgram", "Execute program")); mExecChB.setSelected(mSettings.getProperty("useexec", "false").equals("true")); mExecFileDialogBtn = new JButton(mLocalizer.msg("executeConfig", "Configure")); mExecFileDialogBtn.setEnabled(mExecChB.isSelected()); mPluginLabel = new JLabel(); JButton choose = new JButton(mLocalizer.msg("selectPlugins", "Choose Plugins")); mClientPluginTargets = ReminderPlugin.getInstance().getClientPluginsTargets(); handlePluginSelection(); choose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance()); PluginChooserDlg chooser = null; chooser = new PluginChooserDlg(parent, mClientPluginTargets, null, ReminderPluginProxy.getInstance()); chooser.setLocationRelativeTo(parent); chooser.setVisible(true); if (chooser.getReceiveTargets() != null) { mClientPluginTargets = chooser.getReceiveTargets(); } handlePluginSelection(); } catch (Exception ee) { ee.printStackTrace(); } } }); int autoCloseReminderTime = 10; try { String asString = mSettings.getProperty("autoCloseReminderTime", "10"); autoCloseReminderTime = Integer.parseInt(asString); if (autoCloseReminderTime == 0) { autoCloseReminderTime = 10; } } catch (Exception exc) { // ignore } mCloseOnEnd = new JRadioButton(mLocalizer.msg("autoCloseReminderAtProgramEnd", "Program end"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onEnd")); mCloseOnEnd.setEnabled(mReminderWindowChB.isSelected()); mCloseNever = new JRadioButton(mLocalizer.msg("autoCloseNever", "Never close"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("never")); mCloseNever.setEnabled(mReminderWindowChB.isSelected()); mCloseOnTime = new JRadioButton(mLocalizer.ellipsisMsg("autoCloseAfterTime", "After time"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onTime")); mCloseOnTime.setEnabled(mReminderWindowChB.isSelected()); ButtonGroup bg = new ButtonGroup(); bg.add(mCloseOnEnd); bg.add(mCloseNever); bg.add(mCloseOnTime); mAutoCloseReminderTimeSp = new JSpinner( new SpinnerNumberModel(autoCloseReminderTime, autoCloseReminderTime < 5 ? 1 : 5, 600, 1)); mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected()); mShowTimeCounter = new JCheckBox(mLocalizer.msg("showTimeCounter", "Show time counter"), mSettings.getProperty("showTimeCounter", "false").compareTo("true") == 0); mShowTimeCounter.setEnabled(!mCloseNever.isSelected() && mReminderWindowChB.isSelected()); PanelBuilder autoClosePanel = new PanelBuilder( new FormLayout("12dlu,default,2dlu,default:grow", "pref,2dlu,pref,2dlu,pref,2dlu,pref,10dlu,pref")); autoClosePanel.add(mCloseOnEnd, cc.xyw(1, 1, 4)); autoClosePanel.add(mCloseNever, cc.xyw(1, 3, 4)); autoClosePanel.add(mCloseOnTime, cc.xyw(1, 5, 4)); autoClosePanel.add(mAutoCloseReminderTimeSp, cc.xy(2, 7)); final JLabel secondsLabel = autoClosePanel.addLabel(mLocalizer.msg("seconds", "seconds (0 = off)"), cc.xy(4, 7)); autoClosePanel.add(mShowTimeCounter, cc.xyw(1, 9, 4)); secondsLabel.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected()); String defaultReminderEntryStr = (String) mSettings.get("defaultReminderEntry"); mDefaultReminderEntryList = new JComboBox(ReminderDialog.SMALL_REMIND_MSG_ARR); if (defaultReminderEntryStr != null) { try { int inx = Integer.parseInt(defaultReminderEntryStr); if (inx < ReminderDialog.SMALL_REMIND_MSG_ARR.length) { mDefaultReminderEntryList.setSelectedIndex(inx); } } catch (NumberFormatException e) { // ignore } } mShowTimeSelectionDlg = new JCheckBox( mLocalizer.msg("showTimeSelectionDialog", "Show time selection dialog")); mShowTimeSelectionDlg .setSelected(mSettings.getProperty("showTimeSelectionDialog", "true").compareTo("true") == 0); mShowRemovedDlg = new JCheckBox( mLocalizer.msg("showRemovedDialog", "Show removed reminders after data update")); mShowRemovedDlg.setSelected(mSettings.getProperty("showRemovedDialog", "true").compareTo("true") == 0); pb.addSeparator(mLocalizer.msg("remindBy", "Remind me by"), cc.xyw(1, 1, 10)); pb.add(reminderWindowCfg, cc.xyw(2, 3, 4)); pb.add(mSoundFileChB, cc.xyw(2, 5, 4)); pb.add(mSoundFileChB.getButton(), cc.xy(7, 5)); pb.add(soundTestBt, cc.xy(9, 5)); pb.add(mBeep, cc.xy(2, 7)); pb.add(mExecChB, cc.xyw(2, 9, 4)); pb.add(mExecFileDialogBtn, cc.xyw(7, 9, 3)); pb.addSeparator(mLocalizer.msg("sendToPlugin", "Send reminded program to"), cc.xyw(1, 11, 10)); pb.add(mPluginLabel, cc.xyw(2, 13, 4)); pb.add(choose, cc.xyw(7, 13, 3)); final JLabel c = (JLabel) pb .addSeparator(mLocalizer.msg("autoCloseReminder", "Automatically close reminder"), cc.xyw(1, 15, 10)) .getComponent(0); c.setEnabled(mReminderWindowChB.isSelected()); pb.add(autoClosePanel.getPanel(), cc.xyw(2, 17, 5)); JPanel reminderEntry = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); reminderEntry.add(mDefaultReminderEntryList); pb.addSeparator(mLocalizer.msg("defaltReminderEntry", "Default reminder time"), cc.xyw(1, 19, 10)); pb.add(reminderEntry, cc.xyw(2, 21, 4)); pb.addSeparator(mLocalizer.msg("miscSettings", "Misc settings"), cc.xyw(1, 23, 10)); pb.add(mShowTimeSelectionDlg, cc.xyw(2, 25, 7)); pb.add(mShowRemovedDlg, cc.xyw(2, 27, 7)); pb.addSeparator(DefaultMarkingPrioritySelectionPanel.getTitle(), cc.xyw(1, 29, 10)); pb.add(mMarkingsPanel = DefaultMarkingPrioritySelectionPanel .createPanel(ReminderPlugin.getInstance().getMarkPriority(), false, false), cc.xyw(2, 31, 9)); mReminderWindowChB.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { mShowAlwaysOnTop.setEnabled(e.getStateChange() == ItemEvent.SELECTED); c.setEnabled(e.getStateChange() == ItemEvent.SELECTED); secondsLabel.setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected()); mCloseOnEnd.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mCloseNever.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mCloseOnTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED && !mCloseNever.isSelected()); mAutoCloseReminderTimeSp .setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected()); } }); soundTestBt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().compareTo(mLocalizer.msg("test", "Test")) == 0) { mTestSound = ReminderPlugin.playSound(mSoundFileChB.getTextField().getText()); if (mTestSound != null) { soundTestBt.setText(mLocalizer.msg("stop", "Stop")); } if (mTestSound != null) { if (mTestSound instanceof SourceDataLine) { ((SourceDataLine) mTestSound).addLineListener(new LineListener() { public void update(LineEvent event) { if (event.getType() == Type.CLOSE) { soundTestBt.setText(mLocalizer.msg("test", "Test")); } } }); } else if (mTestSound instanceof Sequencer) { new Thread("Test MIDI sound") { public void run() { setPriority(Thread.MIN_PRIORITY); while (((Sequencer) mTestSound).isRunning()) { try { Thread.sleep(100); } catch (Exception ee) { } } soundTestBt.setText(mLocalizer.msg("test", "Test")); } }.start(); } } } else if (mTestSound != null) { if (mTestSound instanceof SourceDataLine && ((SourceDataLine) mTestSound).isRunning()) { ((SourceDataLine) mTestSound).stop(); } else if (mTestSound instanceof Sequencer && ((Sequencer) mTestSound).isRunning()) { ((Sequencer) mTestSound).stop(); } } } }); mSoundFileChB.getCheckBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { soundTestBt.setEnabled(mSoundFileChB.isSelected()); } }); mSoundFileChB.getTextField().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { String text = mSoundFileChB.getTextField().getText(); if ((new File(text)).isFile()) { boolean notFound = true; for (String extension : extArr) { if (StringUtils.endsWithIgnoreCase(text, extension)) { notFound = false; break; } } if (notFound) { soundTestBt.setEnabled(false); } else { soundTestBt.setEnabled(true); } } else { soundTestBt.setEnabled(false); } } }); mSoundFileChB.getTextField().getKeyListeners()[0].keyReleased(null); mExecChB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mExecFileDialogBtn.setEnabled(mExecChB.isSelected()); if (mExecFileDialogBtn.isEnabled()) { showFileSettingsDialog(); } } }); mExecFileDialogBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFileSettingsDialog(); } }); ItemListener autoCloseListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected()); secondsLabel.setEnabled(mCloseOnTime.isSelected()); mShowTimeCounter.setEnabled(mCloseOnTime.isSelected() || mCloseOnEnd.isSelected()); } }; mCloseOnEnd.addItemListener(autoCloseListener); mCloseOnTime.addItemListener(autoCloseListener); mCloseOnTime.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); JScrollPane scrollPane = new JScrollPane(pb.getPanel()); scrollPane.setBorder(null); scrollPane.setViewportBorder(null); JPanel scrollPanel = new JPanel(new FormLayout("default:grow", "default")); scrollPanel.add(scrollPane, cc.xy(1, 1)); return scrollPanel; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Builds the GUI for the application/*w ww . j a v a2 s . co m*/ */ private void setup() { JPanel panel; JPanel gridPanel; JPanel outerPanel; JPanel flowPanel; JPanel boxedPanel; ButtonGroup bGroup; MaxHeightJScrollPane maxHeightJScrollPane; setupComponents(); getContentPane().setLayout(new BorderLayout()); // table.getTableHeader().setFont(new Font(table.getTableHeader().getFont(). // getName(), table.getTableHeader().getFont().getStyle(), // MessageStyleFactory.instance().getFontSize())); getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); panel = new JPanel(); panel.setLayout(new BorderLayout()); outerPanel = new JPanel(); outerPanel.setLayout(new BorderLayout()); gridPanel = new JPanel(); gridPanel.setLayout(new GridLayout(0, 1)); gridPanel.add(connectString = new JComboBox()); connectString.setEditable(true); gridPanel.add(querySelection = new JComboBox()); querySelection.setEditable(false); querySelection.addActionListener(this); outerPanel.add(gridPanel, BorderLayout.NORTH); outerPanel.add(new JScrollPane(queryText = new JTextArea(QUERY_AREA_ROWS, QUERY_AREA_COLUMNS)), BorderLayout.SOUTH); queryText.setLineWrap(true); queryText.setWrapStyleWord(true); queryText.addKeyListener(this); panel.add(outerPanel, BorderLayout.CENTER); outerPanel = new JPanel(); outerPanel.setLayout(new BorderLayout()); boxedPanel = new JPanel(); boxedPanel.setLayout(new GridLayout(0, 2)); boxedPanel.add(new JLabel(Resources.getString("proUserId"))); boxedPanel.add(userId = new JTextField(10)); boxedPanel.add(new JLabel(Resources.getString("proPassword"))); boxedPanel.add(password = new JPasswordField(10)); outerPanel.add(boxedPanel, BorderLayout.WEST); // Prev/Next and the checkboxes are all on the flowPanel - Center of // outerPanel flowPanel = new JPanel(); flowPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Previous/Next buttons boxedPanel = new JPanel(); boxedPanel.setLayout(new FlowLayout()); boxedPanel.add(previousQuery = new JButton(Resources.getString("ctlPrev"), new ImageIcon(ImageUtility.getImageAsByteArray("ArrowLeftGreen.gif")))); previousQuery.setToolTipText(Resources.getString("tipPrev")); previousQuery.addActionListener(this); boxedPanel.add(nextQuery = new JButton(Resources.getString("ctlNext"), new ImageIcon(ImageUtility.getImageAsByteArray("ArrowRightGreen.gif")))); nextQuery.setToolTipText(Resources.getString("tipNext")); nextQuery.addActionListener(this); flowPanel.add(boxedPanel); // Checkboxes: Autocommit, Read Only and Pooling boxedPanel = new JPanel(); boxedPanel.setLayout(new FlowLayout()); boxedPanel.setBorder(getStandardBorder()); boxedPanel.add(autoCommit = new JCheckBox(Resources.getString("ctlAutoCommit"), true)); boxedPanel.add(readOnly = new JCheckBox(Resources.getString("ctlReadOnly"), false)); boxedPanel.add(poolConnect = new JCheckBox(Resources.getString("ctlConnPool"), false)); poolConnect.setEnabled(false); flowPanel.add(boxedPanel); outerPanel.add(flowPanel, BorderLayout.CENTER); boxedPanel = new JPanel(); boxedPanel.setLayout(new GridLayout(0, 1)); boxedPanel.setBorder(getStandardBorder()); boxedPanel.add(runIndicator = new JLabel(Resources.getString("ctlRunning"), JLabel.CENTER)); runIndicator.setForeground(Color.lightGray); boxedPanel.add(timeIndicator = new JLabel("", JLabel.RIGHT)); outerPanel.add(boxedPanel, BorderLayout.EAST); panel.add(outerPanel, BorderLayout.NORTH); flowPanel = new JPanel(); flowPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); boxedPanel = new JPanel(); boxedPanel.setLayout(new FlowLayout()); boxedPanel.setBorder(getStandardBorder()); boxedPanel.add(new JLabel(Resources.getString("proQueryType"))); boxedPanel.add(asQuery = new JRadioButton(Resources.getString("ctlSelect"), true)); boxedPanel.add(asUpdate = new JRadioButton(Resources.getString("ctlUpdate"))); boxedPanel.add(asDescribe = new JRadioButton(Resources.getString("ctlDescribe"))); bGroup = new ButtonGroup(); bGroup.add(asQuery); bGroup.add(asUpdate); bGroup.add(asDescribe); asQuery.addActionListener(this); asUpdate.addActionListener(this); asDescribe.addActionListener(this); flowPanel.add(boxedPanel); flowPanel.add(new JLabel(" ")); boxedPanel = new JPanel(); boxedPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); boxedPanel.setBorder(getStandardBorder()); boxedPanel.add(new JLabel(Resources.getString("proMaxRows"))); boxedPanel.add(maxRows); flowPanel.add(boxedPanel); flowPanel.add(new JLabel(" ")); flowPanel.add(execute = new JButton(Resources.getString("ctlExecute"))); execute.addActionListener(this); flowPanel.add(remove = new JButton(Resources.getString("ctlRemove"))); remove.addActionListener(this); flowPanel.add(commentToggle = new JButton(Resources.getString("ctlComment"))); commentToggle.addActionListener(this); flowPanel.add(nextInList = new JButton(Resources.getString("ctlDown"))); nextInList.addActionListener(this); panel.add(flowPanel, BorderLayout.SOUTH); getContentPane().add(panel, BorderLayout.NORTH); getRootPane().setDefaultButton(execute); messageDocument = new DefaultStyledDocument(); getContentPane().add( maxHeightJScrollPane = new MaxHeightJScrollPane(message = new JTextPane(messageDocument)), BorderLayout.SOUTH); message.setEditable(false); loadedDBDriver = false; loadMenu(); setupTextStyles(); loadProperties(); setupUserDefinedColoring(); setupResultsTableColoring(); loadConfig(); loadConnectStrings(); loadQueries(); loadDrivers(); // Check for avail of pool - enable/disable pooling option as appropriate // Not really useful until we get the pooling classes out of this code try { new GenericObjectPool(null); poolConnect.setEnabled(true); poolConnect.setSelected(true); } catch (Throwable any) { // No Apache Commons DB Pooling Library Found (DBCP) LOGGER.error(Resources.getString("errNoPoolLib"), any); } setDefaults(); maxHeightJScrollPane.lockHeight(getHeight() / MAX_SCROLL_PANE_DIVISOR_FOR_MAX_HEIGHT); // Font setFontFromConfig(Configuration.instance()); setVisible(true); }