List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:edu.ku.brc.ui.tmanfe.SearchReplacePanel.java
/** * Creates the panel that displays the close button, the search field, the next button, * the previous button, the match case checkbox and the wrap search checkbox *//*from ww w .j a v a 2 s. c o m*/ private void createFindPanel() { cancelButton = createButton(hideFindPanelAction); cancelButton.setIcon(IconManager.getIcon("Close")); cancelButton.setMargin(new Insets(0, 0, 0, 0)); cancelButton.setBorder(null); findLabel = createLabel(getResourceString("SS_SR_FIND") + ": ", SwingConstants.RIGHT); nextButton = createButton(getResourceString("SS_SR_NEXT"));//, new ImageIcon(Specify.class.getResource("images/down.png"))); nextButton.setEnabled(false); UIHelper.setLocalizedMnemonic(previousButton, "SS_SR_NEXT_MNEU"); nextButton.addActionListener(searchAction); previousButton = createButton(getResourceString("SS_SR_PREVIOUS"));//, new ImageIcon(Specify.class.getResource("images/up.png"))); previousButton.setEnabled(false); UIHelper.setLocalizedMnemonic(previousButton, "SS_SR_PREVIOUS_MNEU"); previousButton.addActionListener(searchAction); //JComponent[] itemSample = { new JMenuItem("Replace"), new JMenuItem("Replace All") }; //replaceButton = new MemoryDropDownButton("Replace", IconManager.getIcon("DropDownArrow"), // 1, java.util.Arrays.asList(itemSample)); //replaceButton.setOverrideBorder(true, replaceButton.raisedBorder); //replaceButton.setEnabled(false); findField.setColumns(textFieldLength); findField.setText(""); findField.addKeyListener(new FindReplaceTextFieldKeyAdapter()); //replaceField.setColumns(textFieldLength); //replaceField.addKeyListener(new InputFieldKeyAdapter()); matchCaseButton = createCheckBox(getResourceString("SS_SR_MATCHCASE")); matchCaseButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { //don't care } }); wrapSearchButton = createCheckBox(getResourceString("SS_SR_WRAP")); wrapSearchButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { setCheckAndSetWrapOption(); } }); searchSelectionChkBx = createCheckBox(getResourceString("SS_SR_SELECTED")); searchSelectionChkBx.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { setSearchSelectionOption(); foundCell = null; } }); //searchSelectionChkBx.setEnabled(false); builder.add(cancelButton, cc.xy(1, 1)); builder.add(findLabel, cc.xy(3, 1)); builder.add(findField, cc.xy(5, 1)); builder.add(nextButton, cc.xy(7, 1)); builder.add(previousButton, cc.xy(9, 1)); builder.add(matchCaseButton, cc.xy(11, 1)); builder.add(wrapSearchButton, cc.xy(13, 1)); builder.add(searchSelectionChkBx, cc.xy(15, 1)); // statusInfo = createLabel(""); // builder.add(statusInfo, cc.xy(15,1)); }
From source file:daylightchart.gui.DaylightChartGui.java
private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) { final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$ menu.setMnemonic('O'); final GuiAction options = new OptionsAction(this); menu.add(options);// ww w .j a v a 2 s.co m final GuiAction chartOptions = new ChartOptionsAction(this); menu.add(chartOptions); final GuiAction resetAll = new ResetAllAction(this); menu.add(resetAll); menu.addSeparator(); final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem( Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$ slimUiMenuItem.setState(isSlimUi()); slimUiMenuItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED; final Options options = UserPreferences.optionsFile().getData(); options.setSlimUi(slimUi); UserPreferences.optionsFile().save(options); ResetAllAction.restart(DaylightChartGui.this, slimUi); } }); menu.add(slimUiMenuItem); menuBar.add(menu); toolBar.add(options); toolBar.add(chartOptions); toolBar.addSeparator(); }
From source file:com.funambol.exchange.admin.ExchangeSyncSourceConfigPanel.java
/** * Creates the panel's components and layout. * @todo adjust layout//from ww w. j av a 2s. c o m */ private void init() { // set layout this.setLayout(null); // set properties of label, position and border // referred to the title of the panel titledBorder = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText(getPanelName()); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder); final int LABEL_X = 14; final int VALUE_X = 170; int y = 60; final int GAP_X = 150; final int GAP_Y = 30; sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18)); y += GAP_Y; // New line nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); nameValue.setFont(defaultFont); nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18)); y += GAP_Y; // New line y += GAP_Y; // New line typeLabel.setText("Type: "); typeLabel.setFont(defaultFont); typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); typeCombo.setFont(defaultFont); typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18)); // What happens when the Type value is changed? typeCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (isSIFSelected()) { encoding.setSelected(true); // SIFs always encoded encoding.setEnabled(false); } else { encryption.setSelected(false); encoding.setSelected(false); encoding.setEnabled(true); } } }); y += GAP_Y; // New line int x = LABEL_X; y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed encryption.setText("Encrypt data"); encryption.setFont(defaultFont); encryption.setSelected(false); encryption.setBounds(x, y, 150, 25); // What happens if the encryption is enabled? encryption.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == e.SELECTED) { encoding.setSelected(true); // Encryption implies encoding encoding.setEnabled(false); } if (e.getStateChange() == e.DESELECTED) { if (!isSIFSelected()) { encoding.setEnabled(true); } } } }); y += GAP_Y; // New line encoding.setText("Encode data in Base 64"); encoding.setFont(defaultFont); encoding.setSelected(false); encoding.setBounds(x, y, 150, 25); y += GAP_Y; // New line y += GAP_Y; // New line confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(VALUE_X, y, 70, 25); // What happens when the confirmButton is pressed? confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage(), e)); } } }); // Adds all components to the panel this.add(panelName, null); this.add(nameLabel, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameValue, null); this.add(typeLabel, null); this.add(typeCombo, null); this.add(encryption, null); this.add(encoding, null); this.add(confirmButton, null); }
From source file:com.tiempometa.muestradatos.JProgramTags.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY // //GEN-BEGIN:initComponents ResourceBundle bundle = ResourceBundle.getBundle("com.tiempometa.muestradatos.muestradatos"); dialogPane = new JPanel(); contentPanel = new JPanel(); label1 = new JLabel(); statusLabel = new JLabel(); nextChipnumberTextField = new JTextField(); programButton = new JButton(); bibLabel = new JLabel(); label3 = new JLabel(); tidTextField = new JTextField(); label4 = new JLabel(); epcTextField = new JTextField(); label5 = new JLabel(); programmedEpcTextField = new JTextField(); scrollPane1 = new JScrollPane(); tagReadTable = new JTable(); lockCheckbox = new JCheckBox(); label2 = new JLabel(); accessPasswordTextField = new JTextField(); label6 = new JLabel(); killPasswordTextField = new JTextField(); checkBox1 = new JCheckBox(); buttonBar = new JPanel(); closeButton = new JButton(); CellConstraints cc = new CellConstraints(); // ======== this ======== setTitle(bundle.getString("JProgramTags.this.title")); setIconImage(/*from w ww . j a va 2 s . c om*/ new ImageIcon(getClass().getResource("/com/tiempometa/resources/tiempometa_icon_large_alpha.png")) .getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); // ======== dialogPane ======== { dialogPane.setBorder(Borders.DIALOG_BORDER); dialogPane.setLayout(new BorderLayout()); // ======== contentPanel ======== { contentPanel.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.setLayout(new FormLayout( new ColumnSpec[] { new ColumnSpec(Sizes.dluX(12)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(86)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(73)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(71)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(68)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(97)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(15)), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(17)), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); // ---- label1 ---- label1.setText(bundle.getString("JProgramTags.label1.text")); label1.setFont(new Font("Tahoma", Font.PLAIN, 36)); contentPanel.add(label1, cc.xywh(3, 5, 3, 1)); // ---- statusLabel ---- statusLabel.setText(bundle.getString("JProgramTags.statusLabel.text")); statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setBackground(Color.yellow); statusLabel.setOpaque(true); statusLabel.setFont(new Font("Tahoma", Font.BOLD, 20)); contentPanel.add(statusLabel, cc.xywh(9, 3, 3, 5)); // ---- nextChipnumberTextField ---- nextChipnumberTextField.setFont(new Font("Tahoma", Font.PLAIN, 36)); contentPanel.add(nextChipnumberTextField, cc.xy(7, 5)); // ---- programButton ---- programButton.setText(bundle.getString("JProgramTags.programButton.text")); programButton.setFont(new Font("Tahoma", Font.PLAIN, 14)); programButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { programButtonActionPerformed(e); } }); contentPanel.add(programButton, cc.xywh(3, 7, 3, 1)); // ---- bibLabel ---- bibLabel.setForeground(Color.red); bibLabel.setFont(new Font("Tahoma", Font.BOLD, 36)); bibLabel.setHorizontalAlignment(SwingConstants.CENTER); contentPanel.add(bibLabel, cc.xy(11, 9)); // ---- label3 ---- label3.setText(bundle.getString("JProgramTags.label3.text")); label3.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(label3, cc.xy(7, 11)); // ---- tidTextField ---- tidTextField.setEditable(false); tidTextField.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(tidTextField, cc.xywh(9, 11, 3, 1)); // ---- label4 ---- label4.setText(bundle.getString("JProgramTags.label4.text")); label4.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(label4, cc.xy(7, 13)); // ---- epcTextField ---- epcTextField.setEditable(false); epcTextField.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(epcTextField, cc.xywh(9, 13, 3, 1)); // ---- label5 ---- label5.setText(bundle.getString("JProgramTags.label5.text")); label5.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(label5, cc.xy(7, 15)); // ---- programmedEpcTextField ---- programmedEpcTextField.setEditable(false); programmedEpcTextField.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(programmedEpcTextField, cc.xywh(9, 15, 3, 1)); // ======== scrollPane1 ======== { scrollPane1.setViewportView(tagReadTable); } contentPanel.add(scrollPane1, cc.xywh(3, 17, 9, 1)); // ---- lockCheckbox ---- lockCheckbox.setText(bundle.getString("JProgramTags.lockCheckbox.text")); lockCheckbox.setSelected(true); lockCheckbox.setFont(new Font("Tahoma", Font.PLAIN, 14)); lockCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkBox2ItemStateChanged(e); } }); contentPanel.add(lockCheckbox, cc.xy(3, 19)); // ---- label2 ---- label2.setText(bundle.getString("JProgramTags.label2.text")); label2.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(label2, cc.xy(5, 19)); // ---- accessPasswordTextField ---- accessPasswordTextField.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(accessPasswordTextField, cc.xy(7, 19)); // ---- label6 ---- label6.setText(bundle.getString("JProgramTags.label6.text")); label6.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(label6, cc.xy(5, 21)); // ---- killPasswordTextField ---- killPasswordTextField.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPanel.add(killPasswordTextField, cc.xy(7, 21)); // ---- checkBox1 ---- checkBox1.setText(bundle.getString("JProgramTags.checkBox1.text")); checkBox1.setEnabled(false); contentPanel.add(checkBox1, cc.xy(9, 21)); } dialogPane.add(contentPanel, BorderLayout.EAST); // ======== buttonBar ======== { buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER); buttonBar.setLayout( new FormLayout(new ColumnSpec[] { FormFactory.GLUE_COLSPEC, FormFactory.BUTTON_COLSPEC }, RowSpec.decodeSpecs("pref"))); // ---- closeButton ---- closeButton.setText("Cerrar"); closeButton.setFont(new Font("Tahoma", Font.PLAIN, 14)); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeButtonActionPerformed(e); } }); buttonBar.add(closeButton, cc.xy(2, 1)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); setSize(700, 625); setLocationRelativeTo(getOwner()); // //GEN-END:initComponents }
From source file:ca.uhn.hunit.swing.ui.iface.JmsInterfaceForm.java
/** * {@inheritDoc }/*from w ww. j a va 2s . c o m*/ */ @Override public void setController(JmsInterfaceContextController theController) { final JmsInterfaceImpl model = theController.getModel(); myUsernameTextBox.setText(model.getUsername()); myUsernameTextBox.getDocument().addUndoableEditListener(new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent e) { model.setUsername(myUsernameTextBox.getText()); } }); myPasswordTextBox.setText(model.getPassword()); myPasswordTextBox.getDocument().addUndoableEditListener(new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent e) { model.setPassword(myPasswordTextBox.getText()); } }); myQueueNameTextBox.setText(model.getQueueName()); if (StringUtils.isBlank(model.getQueueName())) { myQueueNameTextBox.setBackground(Colours.getTextFieldError()); } myQueueNameTextBox.getDocument().addUndoableEditListener(new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { try { model.setQueueName(myQueueNameTextBox.getText()); myQueueNameTextBox.setBackground(Colours.getTextFieldOk()); } catch (PropertyVetoException ex) { LogFactory.INSTANCE.getSystem(getClass()).error(ex.getMessage()); myQueueNameTextBox.setBackground(Colours.getTextFieldError()); } } }); myQueueTopicCombo.setSelectedIndex(model.isPubSubDomain() ? 1 : 0); myQueueTopicCombo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { model.setPubSubDomain(myQueueTopicCombo.getSelectedIndex() == 1); } }); myConnectionFactoryBeanEditor.setController(theController.getConstructorArgsController()); }
From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);//from w ww . j a v a 2s . c o m // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { ResidualPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; ResidualPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help...", new ImageIcon(ResidualPlotAction.class.getResource("/images/action/help-16x16.png"))); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("residual-plot", ResidualPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private void addActionListeners() { MultiListener listener = new MultiListener(this); typeChooser.addItemListener(listener); textField.getDocument().addDocumentListener(listener); levelSpinner.getModel().addChangeListener(listener); megaFilter.addItemListener(listener); effectFilter.addItemListener(listener); survivalMode.addItemListener(new ItemListener() { @Override/*from w ww . j a va 2 s . c om*/ public void itemStateChanged(ItemEvent e) { updateTeamPanel(); } }); }
From source file:fr.free.hd.servers.gui.FaceView.java
private JPanel createKind() { JPanel panel = new JPanel(new GridLayout(3, 0)); final JSlider sliderX = new JSlider(); final JSlider sliderY = new JSlider(); final JComboBox box = new JComboBox(HandKeyEnum.values()); sliderX.setMinimum(-1000);/* w w w.j av a 2 s . co m*/ sliderX.setMaximum(1000); sliderX.setMajorTickSpacing(100); sliderX.setPaintLabels(true); sliderX.setPaintTicks(true); sliderX.setPaintTrack(true); sliderY.setMinimum(-1000); sliderY.setMaximum(1000); sliderY.setMajorTickSpacing(100); sliderY.setPaintLabels(true); sliderY.setPaintTicks(true); sliderY.setPaintTrack(true); box.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { kind = (HandKeyEnum) e.getItem(); updateLabel(); } }); panel.add(box); sliderX.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorX_2D(sliderX.getValue()); break; case HAND_KEY_2M: face.setAnchorX_2M(sliderX.getValue()); break; case HAND_KEY_1M: face.setAnchorX_1M(sliderX.getValue()); break; case HAND_KEY_2V: face.setAnchorX_2V(sliderX.getValue()); break; case HAND_KEY_3D: face.setAnchorX_3D(sliderX.getValue()); break; case HAND_KEY_3G: face.setAnchorX_3G(sliderX.getValue()); break; case HAND_KEY_4G: face.setAnchorX_4G(sliderX.getValue()); break; case HAND_KEY_5M: face.setAnchorX_5M(sliderX.getValue()); break; } updateLabel(); } }); sliderY.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorY_2D(sliderY.getValue()); break; case HAND_KEY_2M: face.setAnchorY_2M(sliderY.getValue()); break; case HAND_KEY_1M: face.setAnchorY_1M(sliderY.getValue()); break; case HAND_KEY_2V: face.setAnchorY_2V(sliderY.getValue()); break; case HAND_KEY_3D: face.setAnchorY_3D(sliderY.getValue()); break; case HAND_KEY_3G: face.setAnchorY_3G(sliderY.getValue()); break; case HAND_KEY_4G: face.setAnchorY_4G(sliderY.getValue()); break; case HAND_KEY_5M: face.setAnchorY_5M(sliderY.getValue()); break; } updateLabel(); } }); panel.add(sliderX); panel.add(sliderY); return panel; }
From source file:tvbrowser.extras.reminderplugin.ReminderSettingsTab.java
/** * Creates the settings panel for this tab. *///from w w w .j a v a 2s.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:edu.gmu.cs.sim.util.media.chart.BoxPlotGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((CategoryPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);/*from w ww .j a va 2 s. com*/ getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); ((CategoryPlot) (chart.getPlot())).setRangeAxis(logAxis); } else { ((CategoryPlot) (chart.getPlot())).setRangeAxis(new NumberAxis(yLabel.getValue())); } } }); list.add(new JLabel("Y Log Axis"), yLog); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(true); } else { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); // JFreeChart's Box Plots look awful when wide because the mean // circle is based on the width of the bar to the exclusion of all // else. So I've restricted the width to be no more than 0.4, and 0.1 // is the suggested default. final double INITIAL_WIDTH = 0.1; final double MAXIMUM_RATIONAL_WIDTH = 0.4; maximumWidthField = new NumberTextField(INITIAL_WIDTH, 2.0, 0) { public double newValue(double newValue) { if (newValue <= 0.0 || newValue > MAXIMUM_RATIONAL_WIDTH) { newValue = currentValue; } ((BoxAndWhiskerRenderer) (((CategoryPlot) (chart.getPlot())).getRenderer())) .setMaximumBarWidth(newValue); //update(); return newValue; } }; list.addLabelled("Max Width", maximumWidthField); Box box = Box.createHorizontalBox(); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Y Grid Lines"), ygridlines); mean = new JCheckBox(); mean.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMeanVisible(mean.isSelected()); } }; mean.addItemListener(il); median = new JCheckBox(); median.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMedianVisible(median.isSelected()); } }; median.addItemListener(il); list.add(new JLabel("Mean"), mean); list.add(new JLabel("Median"), median); final JCheckBox horizontal = new JCheckBox(); horizontal.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot plot = (CategoryPlot) (chart.getPlot()); if (e.getStateChange() == ItemEvent.SELECTED) { plot.setOrientation(PlotOrientation.HORIZONTAL); } else { plot.setOrientation(PlotOrientation.VERTICAL); } //updateGridLines(); } }; horizontal.addItemListener(il); list.add(new JLabel("Horizontal"), horizontal); final JCheckBox whiskersUseFillColorButton = new JCheckBox(); whiskersUseFillColorButton.setSelected(false); whiskersUseFillColorButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setUseOutlinePaintForWhiskers(!whiskersUseFillColorButton.isSelected()); } }); box = Box.createHorizontalBox(); box.add(new JLabel(" Colored")); box.add(whiskersUseFillColorButton); box.add(Box.createGlue()); list.add(new JLabel("Whiskers"), box); }