List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private AbstractWizardPage getAddTagsPage() { //setup page// ww w . j a va 2 s. co m final DefaultWizardPage page = new DefaultWizardPage("Add Tags") { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Variants can be filtered by tag value in the Filter section."); page.addText("Add tags for this set of variants:"); final String[] patternExamples = { "<Tag Name>", "Sequencer", "Sequencer Version", "Variant Caller", "Variant Caller Version", "Technician" }; locationField = new JComboBox(patternExamples); locationField.setEditable(true); final JPanel tagContainer = new JPanel(); ViewUtil.applyVerticalBoxLayout(tagContainer); final JTextField valueField = new JTextField(); final String startingValue = "<Value>"; valueField.setText(startingValue); final JTextArea ta = new JTextArea(); ta.setRows(10); ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ta.setEditable(false); JLabel button = ViewUtil.createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD)); button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (locationField.getSelectedItem().toString().isEmpty()) { DialogUtils.displayError("Tag cannot be empty"); locationField.requestFocus(); return; } else if (locationField.getSelectedItem().toString().equals(patternExamples[0])) { DialogUtils.displayError("Enter a valid tag name"); locationField.requestFocus(); return; } if (valueField.getText().toString().isEmpty()) { DialogUtils.displayError("Value cannot be empty"); valueField.requestFocus(); return; } else if (valueField.getText().equals(startingValue)) { DialogUtils.displayError("Enter a valid value"); valueField.requestFocus(); return; } VariantTag tag = new VariantTag((String) locationField.getSelectedItem(), valueField.getText()); variantTags.add(tag); ta.append(tag.toString() + "\n"); valueField.setText(""); } }); JPanel container2 = new JPanel(); ViewUtil.clear(container2); ViewUtil.applyHorizontalBoxLayout(container2); container2.add(locationField); container2.add(ViewUtil.clear(new JLabel(" = "))); container2.add(valueField); container2.add(button); page.addComponent(container2); locationField.setToolTipText("Current display range"); locationField.setPreferredSize(LOCATION_SIZE); locationField.setMinimumSize(LOCATION_SIZE); valueField.setPreferredSize(LOCATION_SIZE); valueField.setMinimumSize(LOCATION_SIZE); page.addComponent(tagContainer); page.addComponent(new JScrollPane(ta)); JButton clear = new JButton("Clear"); clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantTags.clear(); ta.setText(""); addDefaultTags(variantTags, ta); } }); addDefaultTags(variantTags, ta); page.addComponent(ViewUtil.alignRight(clear)); return page; }
From source file:org.yccheok.jstock.gui.AutoCompleteJComboBox.java
private DocumentListener getDocumentListener() { return new DocumentListener() { private volatile boolean ignore = false; @Override//from w w w . j av a 2 s . c om public void insertUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void removeUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void changedUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } private void _handle(final String string) { // We are no longer busy. busySubject.notify(AutoCompleteJComboBox.this, false); if (AutoCompleteJComboBox.this.getSelectedItem() != null) { // Remember to use toString(). As getSelectedItem() can be // either StockInfo, or ResultSet. if (AutoCompleteJComboBox.this.getSelectedItem().toString().equals(string)) { // We need to differentiate, whether "string" is from user // typing, or drop down list selection. This is because when // user perform selection, document change event will be triggered // too. When string is from drop down list selection, user // are not expecting any auto complete suggestion. Return early. return; } } if (string.isEmpty()) { // Empty string. Return early. Do not perform hidePopup and // removeAllItems right here. As when user performs list // selection, previous text field item will be removed, and // cause us fall into this scope. We do not want to hidePopup // and removeAllItems when user is selecting his item. // // hidePopup and removeAllItems when user clears off all items // in text field, will be performed through keyReleased. return; } // Use to avoid endless DocumentEvent triggering. ignore = true; // During _handle operation, there will be a lot of ListDataListeners // trying to modify the content of our text field. We will not allow // them to do so. // // Without setReadOnly(true), when we type the first character "w", IME // will suggest ... However, when we call removeAllItems and addItem, // JComboBox will "commit" this suggestion to JComboBox's text field. // Hence, if we continue to type second character "m", the string displayed // at JComboBox's text field will be ... // AutoCompleteJComboBox.this.jComboBoxEditor.setReadOnly(true); // Must hide popup. If not, the pop up windows will not be // resized. AutoCompleteJComboBox.this.hidePopup(); AutoCompleteJComboBox.this.removeAllItems(); boolean shouldShowPopup = false; if (AutoCompleteJComboBox.this.stockInfoDatabase != null) { java.util.List<StockInfo> stockInfos = greedyEnabled ? stockInfoDatabase.greedySearchStockInfos(string) : stockInfoDatabase.searchStockInfos(string); sortStockInfosIfPossible(stockInfos); if (stockInfos.isEmpty() == false) { // Change to offline mode before adding any item. changeMode(Mode.Offline); } for (StockInfo stockInfo : stockInfos) { AutoCompleteJComboBox.this.addItem(stockInfo); shouldShowPopup = true; } if (shouldShowPopup) { AutoCompleteJComboBox.this.showPopup(); } else { } // if (shouldShowPopup) } // if (AutoCompleteJComboBox.this.stockInfoDatabase != null) if (shouldShowPopup == false) { // OK. We found nothing from offline database. Let's // ask help from online database. // We are busy contacting server right now. // TODO // Only enable ajaxYahooSearchEngineMonitor, till we solve // http://sourceforge.net/apps/mediawiki/jstock/index.php?title=TechnicalDisability busySubject.notify(AutoCompleteJComboBox.this, true); canRemoveAllItems = true; ajaxYahooSearchEngineMonitor.clearAndPut(string); ajaxGoogleSearchEngineMonitor.clearAndPut(string); } // When we are in windows look n feel, the text will always be selected. We do not want that. final Component component = AutoCompleteJComboBox.this.getEditor().getEditorComponent(); if (component instanceof JTextField) { JTextField jTextField = (JTextField) component; jTextField.setSelectionStart(jTextField.getText().length()); jTextField.setSelectionEnd(jTextField.getText().length()); jTextField.setCaretPosition(jTextField.getText().length()); } // Restore. AutoCompleteJComboBox.this.jComboBoxEditor.setReadOnly(false); ignore = false; } private void handle(final String string) { if (ignore) { return; } // Submit to GUI event queue. Used to avoid // Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Attempt to mutate in notification SwingUtilities.invokeLater(new Runnable() { @Override public void run() { _handle(string); } }); } }; }
From source file:pl.edu.pw.appt.GUI.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed boolean zal = false; JTextField z1 = new JTextField(); JTextField z2 = new JTextField(); Object[] message = { "Zdarzenie 1", z1, "Zdarzenie 2", z2 }; JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); pane.createDialog(null, "Badanie zdarze").setVisible(true); if (selectSystem.getSelectedIndex() != -1) { zal = server.messages.isDependent1(Integer.parseInt(z1.getText()), Integer.parseInt(z2.getText()), selectSystem.getSelectedItem().toString()); JOptionPane.showMessageDialog(null, zal ? "Zdarzenia s zalene" : "Zdarzenia s niezalene", "Badanie zdarze", JOptionPane.WARNING_MESSAGE); }//from w w w.ja v a2 s.c om }
From source file:qic.ui.GuildPanel.java
public GuildPanel() { super(new BorderLayout(1, 1)); textArea.setFont(new Font("Consolas", Font.TRUETYPE_FONT, 12)); add(new JScrollPane(textArea), BorderLayout.CENTER); JPanel southPanel = new JPanel(); JButton guildBtn = new JButton("Append with Guildmates"); JButton saveBtn = new JButton("Save"); JTextField guildUrl = new JTextField(50); // https://www.pathofexile.com/guild/profile/162231 southPanel.add(new JLabel("Guild Profile No./Url")); southPanel.add(guildUrl);//from w ww . j ava 2 s. c o m southPanel.add(guildBtn); southPanel.add(new JLabel("Discount: " + Config.getPropety(Config.GUILD_DISCOUNT_STRING, Config.GUILD_DISCOUNT_STRING_DEFAULT))); add(southPanel, BorderLayout.SOUTH); southPanel.add(saveBtn); loadConfigToTextArea(); guildBtn.addActionListener(e -> { String url = guildUrl.getText(); if (!url.isEmpty()) { Worker<List<String>> worker = new Worker<List<String>>(() -> { List<String> members = Collections.emptyList(); String urlFinal = StringUtils.isNumeric(url) ? "https://www.pathofexile.com/guild/profile/" + url : url; try { members = GuildPageScraper.scrapeMembers(urlFinal); } catch (Exception ex) { logger.error("Error while scraping guild page: " + urlFinal); showError(ex); } return members; }, guildNames -> { if (!guildNames.isEmpty()) { guildNames.stream().forEach(name -> { String ls = textArea.getText().isEmpty() ? "" : System.lineSeparator(); textArea.append(ls + name); }); } }); worker.execute(); } }); saveBtn.addActionListener(e -> save()); }
From source file:qic.ui.ManualPanel.java
@SuppressWarnings("serial") public ManualPanel(Main main) { super(new BorderLayout(5, 5)); table.setDoubleBuffered(true);// ww w.j a v a 2 s . c om JTextField searchTf = new JTextField(100); JButton runBtn = new JButton("Run"); runBtn.setPreferredSize(new Dimension(200, 10)); JLabel invalidTermsLblLbl = new JLabel(); invalidTermsLblLbl.setFont(invalidTermsLblLbl.getFont().deriveFont(Font.BOLD)); JLabel invalidTermsLbl = new JLabel(); invalidTermsLbl.setForeground(Color.RED); JPanel northPanel = new JPanel(); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.X_AXIS)); JLabel searchLbl = new JLabel(" Search: "); searchLbl.setFont(searchLbl.getFont().deriveFont(Font.BOLD)); northPanel.add(searchLbl); northPanel.add(searchTf); northPanel.add(invalidTermsLblLbl); northPanel.add(invalidTermsLbl); northPanel.add(runBtn); this.add(northPanel, BorderLayout.NORTH); List<String> searchList = Util.loadSearchList(MANUAL_TXT_FILENAME); searchList.stream().forEach(searchJListModel::addElement); searchJList.setModel(searchJListModel); searchJList.addListSelectionListener(e -> { if (e.getValueIsAdjusting()) { searchTf.setText(trimToEmpty(searchJList.getSelectedValue())); } }); searchJList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { int index = searchJList.locationToIndex(evt.getPoint()); if (index != -1) { String search = trimToEmpty(searchJListModel.getElementAt(index)); searchTf.setText(search); runBtn.doClick(); } } } }); searchJList.getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "doSomething"); searchJList.getActionMap().put("doSomething", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { int selectedIndex = searchJList.getSelectedIndex(); if (selectedIndex != -1) { searchJListModel.remove(selectedIndex); } } }); ActionListener runCommand = e -> { String tfText = searchTf.getText().trim(); if (!tfText.isEmpty()) { Worker<Command> worker = new Worker<Command>(() -> { runBtn.setEnabled(false); Command result = null; try { result = runQuery(main, tfText); } catch (Exception ex) { runBtn.setEnabled(true); SwingUtil.showError(ex); } return result; }, command -> { if (command != null) { if (command.invalidSearchTerms.isEmpty()) { addDataToTable(command); saveSearchToList(tfText); invalidTermsLbl.setText(""); invalidTermsLblLbl.setText(""); if (getBooleanProperty(MANUAL_AUTO_VERIFY, false)) { long sleep = Config.getLongProperty(Config.MANUAL_AUTO_VERIFY_SLEEP, 5000); table.runAutoVerify(sleep); } } else { String invalidTermsStr = command.invalidSearchTerms.stream().collect(joining(", ")); invalidTermsLbl.setText(invalidTermsStr + " "); invalidTermsLblLbl.setText(" Invalid: "); } } runBtn.setEnabled(true); }); worker.execute(); } }; searchTf.addActionListener(runCommand); runBtn.addActionListener(runCommand); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(table), new JScrollPane(searchJList)); this.add(splitPane, BorderLayout.CENTER); }
From source file:qic.ui.QicFrame.java
public QicFrame(Main main, String query) { super("QIC Search - Simple GUI"); setLayout(new BorderLayout(5, 5)); RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60); textArea.setText("Enter a command in the textfield then press Enter.."); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON); textArea.setCodeFoldingEnabled(true); RTextScrollPane sp = new RTextScrollPane(textArea); JTextField searchTf = new JTextField(100); JButton runBtn = new JButton("Run"); JPanel northPanel = new JPanel(); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.X_AXIS)); northPanel.add(searchTf);//from w w w . java 2 s .c o m northPanel.add(runBtn); getContentPane().add(northPanel, BorderLayout.NORTH); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize(screenSize.width - 50, screenSize.height - 50); setLocationRelativeTo(null); searchTf.setText("search bo tmpsc "); if (query != null) { searchTf.setText(query); } JTable table = new JTable(); table.setDefaultRenderer(List.class, new MultiLineTableCellRenderer()); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Table", new JScrollPane(table)); tabbedPane.addTab("JSON", new JScrollPane(sp)); BeanPropertyTableModel<SearchResultItem> model = new BeanPropertyTableModel<>(SearchResultItem.class); model.setOrderedProperties(asList("id", "buyout", "item", "seller", "reqs", "mods", "q", "APS", "PDPS", "EDPS", "DPS", "ele", "phys", "ar", "ev", "ES", "blk", "crit", "lvl")); table.setModel(model); setColumnWidths(table.getColumnModel(), asList(1, 15, 280, 230, 50, 420)); getContentPane().add(tabbedPane, BorderLayout.CENTER); ActionListener runCommand = e -> { String tfText = searchTf.getText(); Worker<Command> pathNotesWorker = new Worker<Command>(() -> runQuery(main, tfText), command -> { String json = command.toJson(); textArea.setText(json); model.setData(command.itemResults); }, ex -> { String stackTrace = ExceptionUtils.getStackTrace(ex); textArea.setText(stackTrace); showError(ex); }); pathNotesWorker.execute(); }; searchTf.addActionListener(runCommand); runBtn.addActionListener(runCommand); table.getSelectionModel().addListSelectionListener(e -> { if (e.getValueIsAdjusting()) { int selectedRow = table.getSelectedRow(); if (selectedRow > -1) { SearchResultItem searchResultItem = model.getData().get(selectedRow); SwingUtil.copyToClipboard(searchResultItem.wtb()); } } }); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); }
From source file:qrcode.JavaQR.java
@Override public void run() { setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); JPanel centerPanel = new JPanel(); JPanel bottomPanel = new JPanel(); topPanel.setLayout(new GridLayout(0, 1)); topPanel.setBorder(BorderFactory.createTitledBorder("Input Data")); JPanel rowTopPanel = new JPanel(); rowTopPanel.setLayout(new GridLayout(0, 2)); JLabel accKey = new JLabel("Access Key"); JTextField accField = new JTextField(5); accField.setEditable(false);/* w ww . j a va 2s. co m*/ accField.setText(Data.accessKey); JLabel regNo = new JLabel("Registration Number"); JTextField regField = new JTextField(5); regField.setEditable(false); regField.setText(Data.registrationNumber); JLabel licNo = new JLabel("License Number"); JFormattedTextField licField = new JFormattedTextField(); licField.setEditable(false); licField.setText(Data.licenseNumber); rowTopPanel.add(accKey); rowTopPanel.add(accField); rowTopPanel.add(regNo); rowTopPanel.add(regField); rowTopPanel.add(licNo); rowTopPanel.add(licField); topPanel.add(rowTopPanel); centerPanel.setLayout(new GridLayout(0, 1)); centerPanel.setBorder(BorderFactory.createTitledBorder("QR Code")); JPanel rowCenPanel = new JPanel(); rowCenPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton genBtn = new JButton("Download QR Code"); JButton homeBtn = new JButton("Back to Start"); String accessKey = accField.getText().toString(); String regKey = regField.getText().toString(); String licKey = licField.getText().toString(); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("accessKey", accessKey); jsonObject.put("registrationNumber", regKey); jsonObject.put("licenseNumber", licKey); } catch (JSONException e1) { e1.printStackTrace(); } QRLogic qrGen = new QRLogic(); BufferedImage image = qrGen.generateQR(jsonObject); centerPanel.add(new JLabel(new ImageIcon(image))); bottomPanel.setLayout(new GridLayout(2, 1)); rowCenPanel.add(homeBtn); rowCenPanel.add(genBtn); bottomPanel.add(rowCenPanel); add(topPanel, BorderLayout.NORTH); add(bottomPanel, BorderLayout.SOUTH); add(centerPanel, BorderLayout.CENTER); Data.mainFrame.setSize(1000, 500); genBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Date date = new Date(); String newDate = new SimpleDateFormat("yyyy-MM-dd h-m-a").format(date); JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); File myFile = new File(Data.registrationNumber + ".png"); fileChooser.setSelectedFile(myFile); fileChooser.showSaveDialog(null); String dlDir = fileChooser.getSelectedFile().getPath(); System.out.println(dlDir); String fileName = fileChooser.getSelectedFile().getName(); String filePath = ""; if (fileName != null) { filePath = dlDir + ".png"; } else { filePath = dlDir + "/" + Data.registrationNumber + ".png"; } String fileType = "png"; myFile = new File(filePath); if (dlDir != null) { try { ImageIO.write(image, fileType, myFile); JOptionPane.showMessageDialog(Data.mainFrame, "QR Code Saved in " + dlDir); } catch (IOException e1) { e1.printStackTrace(); } } } }); homeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("inventory"); } }); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } }
From source file:richtercloud.reflection.form.builder.typehandler.StringTypeHandler.java
@Override public Pair<JComponent, ComponentHandler<?>> handle(Type type, String fieldValue, String fieldName, Class<?> declaringClass, final FieldUpdateListener<FieldUpdateEvent<String>> updateListener, ReflectionFormBuilder reflectionFormBuilder) throws IllegalArgumentException, IllegalAccessException, FieldHandlingException { final JTextField retValue = new JTextField(fieldValue); retValue.addKeyListener(new KeyListener() { @Override/* w w w . ja va 2 s. c o m*/ public void keyTyped(KeyEvent e) { updateListener.onUpdate(new FieldUpdateEvent<>(retValue.getText())); } @Override public void keyPressed(KeyEvent e) { updateListener.onUpdate(new FieldUpdateEvent<>(retValue.getText())); } @Override public void keyReleased(KeyEvent e) { updateListener.onUpdate(new FieldUpdateEvent<>(retValue.getText())); } }); //action listener doesn't register text change events with keyboard return new ImmutablePair<JComponent, ComponentHandler<?>>(retValue, this); }
From source file:ropes.MainWindow.java
private void jTextField_sliderValueKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_sliderValueKeyReleased JTextField txt = (JTextField) evt.getSource(); if (txt.getText().equals("")) { txt.setText("0"); return;/*from w ww .j a va2 s.c om*/ } jSlider_size_select.setValue(Integer.valueOf(txt.getText())); }
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);/*from w w w. j a v a2s . co 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); }