List of usage examples for javax.swing JCheckBox addActionListener
public void addActionListener(ActionListener l)
ActionListener
to the button. From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private AbstractWizardPage getChooseFilesPage() { //setup page// w ww .j a va 2 s . com final DefaultWizardPage page = new DefaultWizardPage("Choose Files") { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); if (uploadRequired) { if (variantFiles != null && variantFiles.length > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } else { if (serverPathField.getText().isEmpty()) { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } } } }; chooseContainer = new JPanel(); chooseContainer = new JPanel(); chooseContainer.setLayout(new BorderLayout()); chooseTitleLabel = new JLabel(); filesOnMyComputerPanel = populateOnMyComputerPanel(page);// populateRepositoryPanel(); filesOnMedSavantServerPanel = populateOnServerPanel(page); //populateLocalPanel(); page.addComponent(chooseTitleLabel); page.addComponent(chooseContainer); page.addComponent( new JLabel("Files can be in Variant Call Format (*.vcf) or BGZipped\nVCF (*.vcf.gz).\n\n")); final JCheckBox homoRefBox = new JCheckBox("Include HomoRef variants (strongly discouraged)"); homoRefBox.setOpaque(false); homoRefBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { includeHomoRef = homoRefBox.isSelected(); } }); page.addComponent(homoRefBox); setUploadRequired(true); return page; }
From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java
/** Create the frame. */ public CMSSFrame() { setTitle("Fingerprinting tools"); setResizable(false);//from w w w.ja va2s .c om setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 756, 372); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JLayeredPane layeredPane = new JLayeredPane(); contentPane.add(layeredPane, BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 725, 323); layeredPane.add(tabbedPane); JLayeredPane layeredPane_1 = new JLayeredPane(); tabbedPane.addTab("Fingerprint", null, layeredPane_1, null); JLabel label = new JLabel("App name:"); label.setBounds(35, 188, 76, 14); layeredPane_1.add(label); JLabel label_1 = new JLabel("Version:"); label_1.setBounds(35, 230, 76, 14); layeredPane_1.add(label_1); textField = new JTextField(); textField.setColumns(10); textField.setBounds(121, 188, 109, 29); layeredPane_1.add(textField); textField_1 = new JTextField(); textField_1.setColumns(10); textField_1.setBounds(121, 223, 109, 29); layeredPane_1.add(textField_1); JSeparator separator = new JSeparator(); separator.setBounds(35, 72, 665, 2); layeredPane_1.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(196, 11, 1, 201); layeredPane_1.add(separator_1); JSeparator separator_2 = new JSeparator(); separator_2.setOrientation(SwingConstants.VERTICAL); separator_2.setBounds(260, 81, 1, 201); layeredPane_1.add(separator_2); final JCheckBox chckbxGetVersion = new JCheckBox("Get version"); chckbxGetVersion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (textField_1.isEnabled() && !chckbxGetVersion.isSelected()) textField_1.setEnabled(false); if (!textField_1.isEnabled() && chckbxGetVersion.isSelected()) textField_1.setEnabled(true); } }); chckbxGetVersion.setBounds(35, 81, 195, 23); layeredPane_1.add(chckbxGetVersion); final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive"); chckbxPassiveFingerprinting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23); chckbxPassiveFingerprinting.setSelected(true); // layeredPane_1.add(chckbxPassiveFingerprinting); final JCheckBox chckbxAgressive = new JCheckBox("Agressive"); chckbxAgressive.setBounds(35, 133, 195, 23); layeredPane_1.add(chckbxAgressive); JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?"); lblWhatToFingerprint.setBounds(287, 81, 109, 14); layeredPane_1.add(lblWhatToFingerprint); JCheckBox chckbxCms = new JCheckBox("cms"); chckbxCms.setBounds(280, 102, 134, 23); layeredPane_1.add(chckbxCms); JCheckBox chckbxMessageboards = new JCheckBox("message-boards"); chckbxMessageboards.setBounds(280, 128, 134, 23); layeredPane_1.add(chckbxMessageboards); JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks"); chckbxJavascriptframeworks.setBounds(281, 154, 133, 23); layeredPane_1.add(chckbxJavascriptframeworks); JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks"); chckbxWebframeworks.setBounds(281, 178, 133, 23); layeredPane_1.add(chckbxWebframeworks); JCheckBox chckbxWebservers = new JCheckBox("web-servers"); chckbxWebservers.setBounds(281, 204, 133, 23); layeredPane_1.add(chckbxWebservers); JSeparator separator_4 = new JSeparator(); separator_4.setOrientation(SwingConstants.VERTICAL); separator_4.setBounds(435, 81, 1, 201); layeredPane_1.add(separator_4); JCheckBox chckbxDatabases = new JCheckBox("databases"); chckbxDatabases.setBounds(281, 228, 133, 23); layeredPane_1.add(chckbxDatabases); JButton btnMore = new JButton("More"); btnMore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { wtfpFrame = new WhatToFingerPrintFrame(); wtfpFrame.setLocationRelativeTo(null); wtfpFrame.setVisible(true); } }); btnMore.setBounds(291, 261, 123, 23); layeredPane_1.add(btnMore); JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:"); lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14); layeredPane_1.add(lblFingerprintingTimeAnd); JButton btnFingerprint = new JButton("Fingerprint"); btnFingerprint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) chckbxPassiveFingerprinting.setSelected(true); if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) POrAOption = 1; else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 2; else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 3; try { targetUrl = new URL(txtHttp.getText()); } catch (MalformedURLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } System.out.println("POrAOption : " + POrAOption); // we concatenate the two ArrayLists ArrayList<String> wtfpList = getWhatToFingerprint(); for (String wtfp : wtfpFrame.getWhatToFingerprint()) { wtfpList.add(wtfp); } // we call FastFingerprinter.filterResults on the global whatToFingerPrint // List fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption); fpThread.start(); while (fpThread.isAlive()) { // waiting; } ArrayList<String> resultList = fpThread.getFingerPrintingResult(); for (String app : resultList) { textField.setText(textField.getText() + app + " , "); } if (chckbxGetVersion.isSelected()) { System.out.println("wiw"); ArrayList<String> versions = new ArrayList<String>(); if (resultList.contains("wordpress")) { textField_1.setText(textField_1.getText() + "wordpress :"); for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } if (resultList.contains("joomla")) { textField_1.setText(textField_1.getText() + "joomla :"); for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } // blindelephant for (String app : resultList) { System.out.println("---->" + app); try { versions = WebAppGuesser.fingerPrintFile(app); textField_1.setText(textField_1.getText() + app + " : "); for (String version : versions) { textField_1.setText(textField_1.getText() + version + " ; "); } } catch (NoSuchAlgorithmException | IOException | DecoderException e1) { e1.printStackTrace(); } } } } }); btnFingerprint.setBounds(35, 154, 195, 23); layeredPane_1.add(btnFingerprint); JButton btnDetailedView = new JButton("Detailed view "); btnDetailedView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnDetailedView.setBounds(35, 259, 195, 23); layeredPane_1.add(btnDetailedView); this.checkBoxesList.add(chckbxCms); this.checkBoxesList.add(chckbxJavascriptframeworks); this.checkBoxesList.add(chckbxWebframeworks); this.checkBoxesList.add(chckbxWebservers); this.checkBoxesList.add(chckbxDatabases); this.checkBoxesList.add(chckbxMessageboards); txtHttp = new JTextField(); txtHttp.setText("http://"); txtHttp.setBounds(128, 22, 568, 29); layeredPane_1.add(txtHttp); txtHttp.setColumns(10); JLabel lblTarget = new JLabel("Target : "); lblTarget.setBounds(51, 29, 46, 14); layeredPane_1.add(lblTarget); JLayeredPane layeredPane_2 = new JLayeredPane(); tabbedPane.addTab("Details", null, layeredPane_2, null); JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.setBounds(0, 0, 720, 223); layeredPane_2.add(tabbedPane_1); JLayeredPane layeredPane_4 = new JLayeredPane(); tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null); JLayeredPane layeredPane_3 = new JLayeredPane(); tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null); JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null); }
From source file:pl.otros.logview.gui.actions.ExitAction.java
protected void askAndExit() { final DataConfiguration configuration = getOtrosApplication().getConfiguration(); boolean doConfirm = configuration.getBoolean(ConfKeys.CONFIRM_QUIT, true); JPanel panel = new JPanel(new MigLayout("left")); panel.add(new JLabel("Do you want to exit OtrosLogViewer and parse logs with 'grep'?"), "growx, wrap"); getOtrosApplication().getConfiguration().getBoolean(ConfKeys.CONFIRM_QUIT, true); final JCheckBox box = new JCheckBox("Always ask before exit", doConfirm); box.addActionListener(e -> configuration.setProperty(ConfKeys.CONFIRM_QUIT, box.isSelected())); panel.add(box, "growx, wrap"); if (!doConfirm || JOptionPane.showConfirmDialog(frame, panel, "Are you sure?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { frame.setVisible(false);/*from w w w . j av a 2 s.c o m*/ frame.dispose(); System.exit(0); } }
From source file:rita.ui.component.DialogSelectEnemies.java
/** * Recorre el directorio robots y agrega al panel a todos los robots * (.class) instalados/*from w ww . jav a 2 s . c o m*/ * * @throws FileNotFoundException * si no hay .class en el dir File(Settings.getInstallPath(), * "robots") */ private void addRobotsToPanel(JPanel panel) throws FileNotFoundException { if (Settings.getInstallPath() == null) { throw new FileNotFoundException( "La carpeta de robots no pudo ser encontrara porque InstallPath no esta definido"); } File robotDir = new File(Settings.getInstallPath(), "robots"); if (!robotDir.isDirectory() || !robotDir.canRead()) { //otra carpeta posible MVN robotDir = new File(Settings.getInstallPath() + Settings.getMvnResourcesPath(), "robots"); if (!robotDir.isDirectory() || !robotDir.canRead()) throw new FileNotFoundException( "La carpeta de robots " + robotDir + " no existe o no tiene permisos de lectura"); } boolean robotFound = false; // recorrer directorio robots y traer todos los robots instalados JCheckBox cb; JButton buttonPos; /* * buscar recursivametne a todos los .class en InstallPath() + "robots", * excluyendo a las inner clases, porque asumimos que son clases de * implementacion. Las reconocemos porque tienen '$' en el nombre de la * clase. */ for (File f : FileUtils.listFiles(robotDir, new String[] { "class" }, true)) { if (f.getName().endsWith(".class") && f.getName().indexOf('$') == -1) { String[] splitPath = f.getParent().split(pattern); /* * si el path del robot tiene directorio/nombrerobot.class => el * nombre del robot es "directorio.nombrerobot", sino es solo * "nombrerobot" */ if (splitPath.length > 0) { cb = new JCheckBox(splitPath[splitPath.length - 1] + "." + f.getName().substring(0, f.getName().lastIndexOf('.')), false); } else { cb = new JCheckBox(f.getName().substring(0, f.getName().lastIndexOf('.')), false); } JPanel panelCheckButton = new JPanel(); buttonPos = new JButton(icon); buttonPos.addActionListener(new PosicionRobotAction(cb.getText())); buttonPos.setPreferredSize(new Dimension(30, 30)); positionComponents.add(buttonPos); cb.addActionListener(robotNameClicked); cb.setPreferredSize(new Dimension(160, 30)); panelCheckButton.add(cb); panelCheckButton.add(buttonPos); panel.add(panelCheckButton); robotFound = true; } } if (!robotFound) { throw new FileNotFoundException("La carpeta de robots no contiene robots"); } }
From source file:savant.chromatogram.ChromatogramPlugin.java
@Override public void init(JPanel panel) { NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() { @Override/*from w ww. ja va 2 s . co m*/ public void handleEvent(LocationChangedEvent event) { updateChromatogram(); } }); GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { updateChromatogram(); } }); panel.setLayout(new GridBagLayout()); panel.setBorder(BorderFactory.createEtchedBorder()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; panel.add(new JLabel("File:"), gbc); pathField = new JTextField(); gbc.gridwidth = 3; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(pathField, gbc); JButton browseButton = new JButton("Browse\u2026"); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { File f = DialogUtils.chooseFileForOpen("Chromatogram File", null, null); if (f != null) { try { pathField.setText(f.getAbsolutePath()); if (canvas != null) { canvas.getParent().remove(canvas); canvas = null; } chromatogram = ChromatogramFactory.create(f); updateEndField(); updateChromatogram(); } catch (UnsupportedChromatogramFormatException x) { DialogUtils.displayMessage("Unable to Open Chromatogram", String.format( "<html><i>%s</i> does not appear to be a valid chromatogram file.<br><br><small>Supported formats are ABI and SCF.</small></html>", f.getName())); } catch (Exception x) { DialogUtils.displayException("Unable to Open Chromatogram", String.format("<html>There was an error opening <i>%s</i>.</html>", f.getName()), x); } } } }); gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; panel.add(browseButton, gbc); JLabel startLabel = new JLabel("Start Base:"); gbc.gridy++; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.EAST; panel.add(startLabel, gbc); startField = new JTextField("0"); startField.setColumns(12); startField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { updateEndField(); } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(startField, gbc); JLabel endLabel = new JLabel("End Base:"); gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.EAST; panel.add(endLabel, gbc); endField = new JTextField(); endField.setColumns(12); endField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { NumberFormat numberParser = NumberFormat.getIntegerInstance(); int endBase = numberParser.parse(endField.getText()).intValue(); if (chromatogram != null) { int startBase = endBase - chromatogram.getSequenceLength(); startField.setText(String.valueOf(startBase)); if (canvas != null) { canvas.updatePos(startBase); } } } catch (ParseException x) { Toolkit.getDefaultToolkit().beep(); } } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(endField, gbc); JCheckBox fillCheck = new JCheckBox("Fill Background"); fillCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { canvas.updateFillbackground(((JCheckBox) ae.getSource()).isSelected()); } }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 0.0; panel.add(fillCheck, gbc); // Add a filler panel at the bottom to force our components to the top. gbc.gridy++; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1.0; panel.add(new JPanel(), gbc); }
From source file:savant.plugin.ToolSettingsPanel.java
private void addArgumentToPanel(ToolArgument arg, int row) { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.gridy = row;//from w w w . ja v a 2 s .c om JComponent widget = null; if (arg.type == ToolArgument.Type.BOOL) { gbc.gridx = 2; gbc.anchor = GridBagConstraints.WEST; addWidget(arg, new BoolCheck(arg), gbc); } else { gbc.gridx = 1; gbc.anchor = GridBagConstraints.EAST; JLabel nameLabel = new JLabel(arg.name + ":"); add(nameLabel, gbc); gbc.gridx = 2; gbc.anchor = GridBagConstraints.WEST; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; JTextField field = null; switch (arg.type) { case INT: field = new JFormattedTextField(); ((JFormattedTextField) field).setValue(Integer.valueOf(arg.value != null ? arg.value : "0")); field.setColumns(5); addField(arg, field, gbc); break; case FLOAT: field = new JFormattedTextField(); ((JFormattedTextField) field).setValue(Double.valueOf(arg.value != null ? arg.value : "0.0")); field.setColumns(10); addField(arg, field, gbc); break; case OUTPUT_FILE: gbc.gridwidth = 1; gbc.fill = GridBagConstraints.HORIZONTAL; field = new JTextField(arg.value); addField(arg, field, gbc); gbc.gridx = 3; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 0.0; JCheckBox loadCheck = new JCheckBox("Load upon Completion", true); loadCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { tool.loadUponCompletion = ((JCheckBox) ae.getSource()).isSelected(); } }); add(loadCheck, gbc); break; case RANGE: field = new JTextField(); field.setColumns(25); LocationController.getInstance().addListener(new RangeUpdater(field)); addField(arg, field, gbc); break; case LIST: addWidget(arg, new StringCombo(arg), gbc); break; case MULTI: gbc.fill = GridBagConstraints.HORIZONTAL; addWidget(arg, new MultiCheckGrid(arg), gbc); break; case BAM_INPUT_FILE: TrackUtils.addTrackListener( (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.ALIGNMENT), gbc)); break; case FASTA_INPUT_FILE: TrackUtils.addTrackListener( (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.SEQUENCE), gbc)); break; } } }
From source file:savant.plugin.ToolSettingsPanel.java
private JComponent addWidget(ToolArgument arg, JComponent widget, GridBagConstraints gbc) { JCheckBox enablerCheck = null; if (!arg.required) { enablerCheck = new JCheckBox(); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.insets = new Insets(5, 5, 5, 5); gbc2.gridy = gbc.gridy;/*from w ww .ja va2 s . co m*/ gbc2.gridx = 0; add(enablerCheck, gbc2); } add(widget, gbc); if (enablerCheck != null) { enablerCheck.addActionListener(new EnablerCheckListener(arg, widget)); } return widget; }
From source file:savant.snp.SNPFinderPlugin.java
private void setupGUI(JPanel panel) { // add a toolbar JToolBar tb = new JToolBar(); tb.setName("SNP Finder Toolbar"); // add an ON/OFF checkbox JLabel lab_on = new JLabel("On/Off: "); JCheckBox cb_on = new JCheckBox(); cb_on.setSelected(isSNPFinderOn);// w w w. j a v a 2 s . c o m // what to do when a user clicks the checkbox cb_on.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // switch the SNP finder on/off setIsOn(!isSNPFinderOn); addMessage("Turning SNP finder " + (isSNPFinderOn ? "on" : "off")); } }); // add a Bookmarking ON/OFF checkbox JLabel lab_bm = new JLabel("Add Bookmarks: "); JCheckBox cb_bm = new JCheckBox(); cb_bm.setSelected(addBookmarks); // what to do when a user clicks the checkbox cb_bm.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // switch the SNP finder on/off setBookmarking(!addBookmarks); addMessage("Turning Bookmarking " + (addBookmarks ? "on" : "off")); } }); JLabel lab_sp = new JLabel("Heterozygosity: "); //add snp prior textfield final JTextField snpPriorField = new JTextField(String.valueOf(snpPrior), 4); snpPriorField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { setSNPPrior(Double.valueOf(snpPriorField.getText())); } catch (NumberFormatException ex) { snpPriorField.setText(String.valueOf(snpPrior)); } } }); int tfwidth = 35; int tfheight = 22; snpPriorField.setPreferredSize(new Dimension(tfwidth, tfheight)); snpPriorField.setMaximumSize(new Dimension(tfwidth, tfheight)); snpPriorField.setMinimumSize(new Dimension(tfwidth, tfheight)); // add a sensitivity slider JLabel lab_confidence = new JLabel("Confidence: "); final JSlider sens_slider = new JSlider(0, 50); sens_slider.setValue(confidence); final JLabel lab_confidence_status = new JLabel("" + sens_slider.getValue()); // what to do when a user slides the slider sens_slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { // set the snp finder's sensitivity lab_confidence_status.setText("" + sens_slider.getValue()); setSensitivity(sens_slider.getValue()); } }); // don't report the new setting until the user stops sliding sens_slider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { addMessage("Changed confidence to " + confidence); } }); // add a transparency slider JLabel lab_trans = new JLabel("Transparency: "); final JSlider trans_slider = new JSlider(0, 100); trans_slider.setValue(transparency); final JLabel lab_transparency_status = new JLabel("" + trans_slider.getValue()); // what to do when a user slides the slider trans_slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { // set the snp finder's transparency lab_transparency_status.setText("" + trans_slider.getValue()); setTransparency(trans_slider.getValue()); } }); // don't report the new setting until the user stops sliding trans_slider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { addMessage("Changed transparency to " + transparency); } }); // add the components to the GUI panel.setLayout(new BorderLayout()); tb.add(lab_on); tb.add(cb_on); tb.add(lab_bm); tb.add(cb_bm); tb.add(new JToolBar.Separator()); tb.add(lab_sp); tb.add(snpPriorField); tb.add(new JToolBar.Separator()); tb.add(lab_confidence); tb.add(sens_slider); tb.add(lab_confidence_status); tb.add(new JToolBar.Separator()); tb.add(lab_trans); tb.add(trans_slider); tb.add(lab_transparency_status); panel.add(tb, BorderLayout.NORTH); // add a text area to the GUI info = new JTextArea(); JScrollPane scrollPane = new JScrollPane(info); panel.add(scrollPane, BorderLayout.CENTER); }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java
private void init(boolean searchFieldEnabled) { setIcon(ImageResourceHelper//from w w w. j a v a2 s .c o m .loadImage("/sk/stuba/fiit/kvasnicka/topologyvisual/resources/files/arrow_down.gif")); setHorizontalTextPosition(JButton.LEFT); setFocusPainted(false); addActionListener(this); mainPanel.setLayout(new BorderLayout()); JPanel northPanel = new JPanel(new BorderLayout()); if (searchFieldEnabled) { addSearchField(northPanel); } final JCheckBox chSelectAll = new JCheckBox("All"); chSelectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectAll(chSelectAll.isSelected()); } }); chSelectAll.setAlignmentX(LEFT_ALIGNMENT); northPanel.add(chSelectAll, BorderLayout.CENTER); northPanel.setAlignmentX(LEFT_ALIGNMENT); northPanel.setBackground(Color.red); mainPanel.add(northPanel, BorderLayout.NORTH); checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.PAGE_AXIS)); scrollPane.setViewportView(checkPanel); scrollPane.setPreferredSize(new Dimension(200, 100)); mainPanel.add(scrollPane, BorderLayout.CENTER); popup.add(mainPanel); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { fireDropDownHiddenEvent(new DropDownHiddenEvent(this, getSelectedCheckBoxItems())); } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }
From source file:storybook.model.EntityUtil.java
public static List<JCheckBox> createCategoryCheckBoxes(MainFrame mainFrame, ActionListener comp) { List<JCheckBox> list = new ArrayList<>(); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); CategoryDAOImpl dao = new CategoryDAOImpl(session); List<Category> categories = dao.findAllOrderBySort(); model.commit();/*from w w w. j a v a2s.c o m*/ for (Category category : categories) { JCheckBox cb = new JCheckBox(category.getName()); cb.putClientProperty(SbConstants.ComponentName.CB_CATEGORY, category); cb.setOpaque(false); cb.addActionListener(comp); cb.setSelected(true); list.add(cb); } return list; }