List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java
/** * Teste si aucune valeur est vide.//from w w w .j ava 2s . c o m * @return boolean True si toutes les valeurs sont ok, c'est dire non vide. **/ private boolean checkNoBlankValues() { boolean erreur = false; Enumeration<JComponent> v = values.elements(); Enumeration<JCheckBox> c = valuesPresent.elements(); while (!erreur && v.hasMoreElements()) { JComponent composant = v.nextElement(); JCheckBox checkbox = c.nextElement(); if (checkbox.isSelected() && composant instanceof JTextField && ((JTextField) composant).getText().length() == 0) { erreur = true; } } return !erreur; }
From source file:org.jfree.chart.demo.Bottom_panel.java
/** * Create the panel./*from w w w .j ava2s .c o m*/ */ public Bottom_panel(ArrayList<Graphic> Grafs, ArrayList<XYSeries> series, int x, int y, int width, int height) { graf = Grafs.get(8); serie = series; setBounds(x, y, width, height); setLayout(new GridLayout(0, 4, 2, 0)); final JCheckBox chckbxNewCheckBox_5 = new JCheckBox("Graph 1"); chckbxNewCheckBox_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { XYSeries sr = serie.get(0); if (chckbxNewCheckBox_5.isSelected() == true) { graf.change_data(serie.get(0), true); } else { graf.change_data(serie.get(0), false); } } }); chckbxNewCheckBox_5.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_5); final JCheckBox chckbxNewCheckBox_1 = new JCheckBox("Graph2"); chckbxNewCheckBox_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { XYSeries sr = serie.get(1); if (chckbxNewCheckBox_1.isSelected() == true) { graf.change_data(serie.get(1), true); } else { graf.change_data(serie.get(1), false); } } }); chckbxNewCheckBox_1.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_1); final JCheckBox chckbxNewCheckBox_2 = new JCheckBox("Graph 3"); chckbxNewCheckBox_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(2); if (chckbxNewCheckBox_2.isSelected() == true) { graf.change_data(serie.get(2), true); } else { graf.change_data(serie.get(2), false); } } }); chckbxNewCheckBox_2.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_2); final JCheckBox chckbxNewCheckBox = new JCheckBox("Graph 4"); chckbxNewCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(3); if (chckbxNewCheckBox.isSelected() == true) { graf.change_data(serie.get(3), true); } else { graf.change_data(serie.get(3), false); } } }); chckbxNewCheckBox.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox); final JCheckBox chckbxNewCheckBox_3 = new JCheckBox("Graph 5"); chckbxNewCheckBox_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(4); if (chckbxNewCheckBox_3.isSelected() == true) { graf.change_data(serie.get(4), true); } else { graf.change_data(serie.get(4), false); } } }); chckbxNewCheckBox_3.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_3); final JCheckBox chckbxNewCheckBox_4 = new JCheckBox("Graph 6"); chckbxNewCheckBox_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(5); if (chckbxNewCheckBox_4.isSelected() == true) { graf.change_data(serie.get(5), true); } else { graf.change_data(serie.get(5), false); } } }); chckbxNewCheckBox_4.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_4); final JCheckBox chckbxNewCheckBox_6 = new JCheckBox("Graph 7"); chckbxNewCheckBox_6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(6); if (chckbxNewCheckBox_6.isSelected() == true) { graf.change_data(serie.get(6), true); } else { graf.change_data(serie.get(6), false); } } }); chckbxNewCheckBox_6.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_6); final JCheckBox chckbxNewCheckBox_7 = new JCheckBox("Graph 8"); chckbxNewCheckBox_7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XYSeries sr = serie.get(7); if (chckbxNewCheckBox_6.isSelected() == true) { graf.change_data(serie.get(7), true); } else { graf.change_data(serie.get(7), false); } } }); chckbxNewCheckBox_7.setBackground(new Color(176, 199, 246)); add(chckbxNewCheckBox_7); }
From source file:biomine.bmvis2.pipeline.BestPathHiderOperation.java
public JComponent getSettingsComponent(final SettingsChangeCallback settingsChangeCallback, final VisualGraph graph) { long nodeCount = graph.getAllNodes().size(); if (oldCount != 0) { long newTarget = (target * nodeCount) / oldCount; this.target = Math.max(newTarget, target); } else/*w ww. j a v a2 s .c o m*/ this.target = nodeCount; this.oldCount = nodeCount; JPanel ret = new JPanel(); // if int overflows, we're fucked final JSlider sl = new JSlider(0, (int) nodeCount, (int) Math.min(target, nodeCount)); sl.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (target == sl.getValue()) return; target = sl.getValue(); settingsChangeCallback.settingsChanged(false); } }); ret.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; //c.gridwidth=2; ret.add(sl, c); c.gridy++; int choices = graph.getNodesOfInterest().size() + 1; Object[] items = new Object[choices]; items[0] = "All PoIs"; for (int i = 1; i < choices; i++) { items[i] = i + " nearest"; } final JComboBox pathTypeBox = new JComboBox(items); pathTypeBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int i = pathTypeBox.getSelectedIndex(); grader.setPathK(i); settingsChangeCallback.settingsChanged(false); } }); ret.add(new JLabel("hide by best path quality to:"), c); c.gridy++; ret.add(pathTypeBox, c); c.gridy++; System.out.println("new confpane nodeCount = " + nodeCount); final JCheckBox useMatchingColoring = new JCheckBox(); ret.add(useMatchingColoring, c); useMatchingColoring.setAction(new AbstractAction("Use matching coloring") { public void actionPerformed(ActionEvent arg0) { matchColoring = useMatchingColoring.isSelected(); settingsChangeCallback.settingsChanged(false); } }); useMatchingColoring.setAlignmentX(JComponent.CENTER_ALIGNMENT); c.gridy++; final JCheckBox labelsBox = new JCheckBox(); ret.add(labelsBox, c); labelsBox.setAction(new AbstractAction("Show goodness in node labels") { public void actionPerformed(ActionEvent arg0) { showLabel = labelsBox.isSelected(); settingsChangeCallback.settingsChanged(false); } }); return ret; }
From source file:MainClass.java
public MainClass() { super("Selection Model Test"); setSize(450, 350);// w ww. ja v a 2 s . c om setDefaultCloseOperation(EXIT_ON_CLOSE); TableModel tm = new AbstractTableModel() { public int getRowCount() { return 10; } public int getColumnCount() { return 10; } public Object getValueAt(int r, int c) { return "0"; } }; final JTable jt = new JTable(tm); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); JPanel controlPanel, buttonPanel, columnPanel, rowPanel; buttonPanel = new JPanel(); final JCheckBox cellBox, columnBox, rowBox; cellBox = new JCheckBox("Cells", jt.getCellSelectionEnabled()); columnBox = new JCheckBox("Columns", jt.getColumnSelectionAllowed()); rowBox = new JCheckBox("Rows", jt.getRowSelectionAllowed()); cellBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setCellSelectionEnabled(cellBox.isSelected()); columnBox.setSelected(jt.getColumnSelectionAllowed()); rowBox.setSelected(jt.getRowSelectionAllowed()); } }); columnBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setColumnSelectionAllowed(columnBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); rowBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setRowSelectionAllowed(rowBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); buttonPanel.add(new JLabel("Selections allowed:")); buttonPanel.add(cellBox); buttonPanel.add(columnBox); buttonPanel.add(rowBox); columnPanel = new JPanel(); ListSelectionModel csm = jt.getColumnModel().getSelectionModel(); JLabel columnCounter = new JLabel("Selected Column Indices:"); csm.addListSelectionListener(new SelectionDebugger(columnCounter, csm)); columnPanel.add(new JLabel("Selected columns:")); columnPanel.add(columnCounter); rowPanel = new JPanel(); ListSelectionModel rsm = jt.getSelectionModel(); JLabel rowCounter = new JLabel("Selected Row Indices:"); rsm.addListSelectionListener(new SelectionDebugger(rowCounter, rsm)); rowPanel.add(new JLabel("Selected rows:")); rowPanel.add(rowCounter); controlPanel = new JPanel(new GridLayout(0, 1)); controlPanel.add(buttonPanel); controlPanel.add(columnPanel); controlPanel.add(rowPanel); getContentPane().add(controlPanel, BorderLayout.SOUTH); }
From source file:SelectionExample.java
public SelectionExample() { super("Selection Model Test"); setSize(450, 350);/*from w w w .j a va 2s . c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); TableModel tm = new AbstractTableModel() { // We'll create a simple multiplication table to serve as a // noneditable // table with several rows and columns public int getRowCount() { return 10; } public int getColumnCount() { return 10; } public Object getValueAt(int r, int c) { return "" + (r + 1) * (c + 1); } }; final JTable jt = new JTable(tm); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); // Now set up our selection controls JPanel controlPanel, buttonPanel, columnPanel, rowPanel; buttonPanel = new JPanel(); final JCheckBox cellBox, columnBox, rowBox; cellBox = new JCheckBox("Cells", jt.getCellSelectionEnabled()); columnBox = new JCheckBox("Columns", jt.getColumnSelectionAllowed()); rowBox = new JCheckBox("Rows", jt.getRowSelectionAllowed()); cellBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setCellSelectionEnabled(cellBox.isSelected()); columnBox.setSelected(jt.getColumnSelectionAllowed()); rowBox.setSelected(jt.getRowSelectionAllowed()); } }); columnBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setColumnSelectionAllowed(columnBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); rowBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setRowSelectionAllowed(rowBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); buttonPanel.add(new JLabel("Selections allowed:")); buttonPanel.add(cellBox); buttonPanel.add(columnBox); buttonPanel.add(rowBox); columnPanel = new JPanel(); ListSelectionModel csm = jt.getColumnModel().getSelectionModel(); JLabel columnCounter = new JLabel("(Selected Column Indices Go Here)"); csm.addListSelectionListener(new SelectionDebugger(columnCounter, csm)); columnPanel.add(new JLabel("Selected columns:")); columnPanel.add(columnCounter); rowPanel = new JPanel(); ListSelectionModel rsm = jt.getSelectionModel(); JLabel rowCounter = new JLabel("(Selected Row Indices Go Here)"); rsm.addListSelectionListener(new SelectionDebugger(rowCounter, rsm)); rowPanel.add(new JLabel("Selected rows:")); rowPanel.add(rowCounter); controlPanel = new JPanel(new GridLayout(0, 1)); controlPanel.add(buttonPanel); controlPanel.add(columnPanel); controlPanel.add(rowPanel); getContentPane().add(controlPanel, BorderLayout.SOUTH); }
From source file:edu.ku.brc.specify.config.init.GenericFormPanel.java
@Override public List<Pair<String, String>> getSummary() { List<Pair<String, String>> list = new ArrayList<Pair<String, String>>(); for (int i = 0; i < labels.length; i++) { JComponent comp = compList.get(i); if (comp instanceof JTextField) { list.add(new Pair<String, String>(UIRegistry.getResourceString(labels[i]), ((JTextField) comp).getText())); } else if (comp instanceof JCheckBox) { JCheckBox chkbx = (JCheckBox) comp; list.add(new Pair<String, String>(UIRegistry.getResourceString(labels[i]), UIRegistry.getResourceString(Boolean.toString(chkbx.isSelected())))); }/* w ww .jav a2s . c o m*/ } return list; }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;/*ww w . j a v a 2 s. co m*/ height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:projects.upc.exec.HrDiagram.java
/** * Main constructor./*from w w w. j a v a 2 s .c o m*/ */ public HrDiagram() { List<UpcStar> upcStars = UpcUtils.loadUpcCatalogue(); List<UpcStar> hipStars = UpcUtils.getHipparcosSubset(upcStars); List<UpcStar> unmatchedStars = UpcUtils.getUnmatchedSubset(upcStars); upcStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(upcStars); hipStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(hipStars); unmatchedStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(unmatchedStars); logger.info("Loaded " + upcStarCrossMatches.size() + " UpcStars with SSA cross matches"); logger.info("Loaded " + hipStarCrossMatches.size() + " UpcStars with Hipparcos and SSA cross matches"); logger.info("Loaded " + unmatchedStarCrossMatches.size() + " UpcStars with no parallax cross-match, and with SSA cross matches"); starsToPlot = upcStarCrossMatches; useHip = false; method = METHOD.NAIVE; fMax = 1.0; final JCheckBox plotAllCheckBox = new JCheckBox("Plot all UPC stars: ", true); plotAllCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotAllCheckBox.isSelected()) { starsToPlot = upcStarCrossMatches; updateChart(); } } }); final JCheckBox plotHipCheckBox = new JCheckBox("Plot Hipparcos stars only: ", false); plotHipCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotHipCheckBox.isSelected()) { starsToPlot = hipStarCrossMatches; updateChart(); } } }); final JCheckBox plotUnmatchedCheckBox = new JCheckBox("Plot all stars with no external match: ", false); plotUnmatchedCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (plotUnmatchedCheckBox.isSelected()) { starsToPlot = unmatchedStarCrossMatches; updateChart(); } } }); final ButtonGroup bg = new ButtonGroup(); bg.add(plotHipCheckBox); bg.add(plotAllCheckBox); bg.add(plotUnmatchedCheckBox); JCheckBox useHipCheckBox = new JCheckBox("Use Hipparcos parallaxes when available", useHip); useHipCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { useHip = !useHip; updateChart(); } }); final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(3, 3)); controls.add(plotAllCheckBox); controls.add(plotHipCheckBox); controls.add(plotUnmatchedCheckBox); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(useHipCheckBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); add(controls, BorderLayout.SOUTH); }
From source file:edu.ku.brc.helpers.EMailHelper.java
/** * Asks for a username and password./*w w w. j a va2 s . co m*/ * @param topframe the parent frame * @return the list of user[index 1] and password[index 2], or 'null' if cancel was pressed */ public static ArrayList<String> askForUserAndPassword(final Frame topframe) { ArrayList<String> userAndPass = new ArrayList<String>(); //get remote prefs AppPreferences remotePrefs = AppPreferences.getRemote(); //get remote password String remoteUsername = remotePrefs.get("settings.email.username", null); //$NON-NLS-1$ PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p", "p,2px,p,2px,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); JLabel plabel = createI18NFormLabel("EMailHelper.PASSWORD"); //$NON-NLS-1$ //$NON-NLS-2$ JLabel ulabel = createI18NFormLabel("EMailHelper.USERNAME"); //$NON-NLS-1$ //$NON-NLS-2$ JPasswordField passField = createPasswordField(25); JTextField userField = createTextField(remoteUsername, 25); JCheckBox savePassword = createCheckBox(getResourceString("EMailHelper.SAVE_PASSWORD")); //$NON-NLS-1$ builder.add(ulabel, cc.xy(1, 1)); builder.add(userField, cc.xy(3, 1)); builder.add(plabel, cc.xy(1, 3)); builder.add(passField, cc.xy(3, 3)); builder.add(savePassword, cc.xy(3, 5)); Integer option = JOptionPane.showConfirmDialog(topframe, builder.getPanel(), getResourceString("EMailHelper.PASSWORD_TITLE"), JOptionPane.OK_CANCEL_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE); String passwordText = new String(passField.getPassword()); String userText = new String(userField.getText()); if (savePassword.isSelected()) { if (StringUtils.isNotEmpty(passwordText)) { remotePrefs.put("settings.email.password", Encryption.encrypt(passwordText)); //$NON-NLS-1$ } } if (option == JOptionPane.CANCEL_OPTION) { return null; } //else userAndPass.add(0, userText); userAndPass.add(1, passwordText); return userAndPass; }
From source file:SoundPlayer.java
void addMidiControls() { // Add a slider to control the tempo final JSlider tempo = new JSlider(50, 200); tempo.setValue((int) (sequencer.getTempoFactor() * 100)); tempo.setBorder(new TitledBorder("Tempo Adjustment (%)")); java.util.Hashtable labels = new java.util.Hashtable(); labels.put(new Integer(50), new JLabel("50%")); labels.put(new Integer(100), new JLabel("100%")); labels.put(new Integer(200), new JLabel("200%")); tempo.setLabelTable(labels);/*from w ww . ja v a 2 s . c o m*/ tempo.setPaintLabels(true); // The event listener actually changes the tmpo tempo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sequencer.setTempoFactor(tempo.getValue() / 100.0f); } }); this.add(tempo); // Create rows of solo and checkboxes for each track Track[] tracks = sequence.getTracks(); for (int i = 0; i < tracks.length; i++) { final int tracknum = i; // Two checkboxes per track final JCheckBox solo = new JCheckBox("solo"); final JCheckBox mute = new JCheckBox("mute"); // The listeners solo or mute the track solo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sequencer.setTrackSolo(tracknum, solo.isSelected()); } }); mute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sequencer.setTrackMute(tracknum, mute.isSelected()); } }); // Build up a row Box box = Box.createHorizontalBox(); box.add(new JLabel("Track " + tracknum)); box.add(Box.createHorizontalStrut(10)); box.add(solo); box.add(Box.createHorizontalStrut(10)); box.add(mute); box.add(Box.createHorizontalGlue()); // And add it to this component this.add(box); } }