List of usage examples for javax.swing JButton setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:org.zaproxy.zap.extension.browserView.ResponseBrowserView.java
private JButton createAdjustHeightButton() { JButton button = new JButton(); button.setToolTipText(ADJUST_HEIGHT_BUTTON_TOOLTIP); button.setIcon(ADJUST_HEIGHT_ICON);//from w w w . ja v a 2 s.c o m ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ssb.adjustPanelHeightToWebsite(); } }; button.addActionListener(actionListener); return button; }
From source file:org.zaproxy.zap.extension.requester.ManualHttpRequestEditorPanel.java
@Override protected Component getManualSendPanel() { if (requestResponsePanel == null) { requestResponsePanel = new RequestResponsePanel(configurationKey, getRequestPanel(), getResponsePanel());//from w ww .j av a2 s. c o m if (helpKey != null) { JButton helpButton = new JButton(); helpButton.setIcon(ExtensionHelp.getHelpIcon()); helpButton.setToolTipText(Constant.messages.getString("help.dialog.button.tooltip")); helpButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { ExtensionHelp.showHelp(helpKey); } }); requestResponsePanel.addToolbarButton(helpButton); } requestResponsePanel.addEndButton(getBtnSend()); requestResponsePanel.addSeparator(); requestResponsePanel.loadConfig(); } return requestResponsePanel; }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private void initToolbar() { toolBar = new JToolBar(); final JComboBox searchMode = new JComboBox( new String[] { "String contains search: ", "Regex search: ", "Query search: " }); final SearchAction searchActionForward = new SearchAction(otrosApplication, SearchDirection.FORWARD); final SearchAction searchActionBackward = new SearchAction(otrosApplication, SearchDirection.REVERSE); searchFieldCbxModel = new DefaultComboBoxModel(); searchField = new JXComboBox(searchFieldCbxModel); searchField.setEditable(true);//from w w w .j a va 2 s. co m AutoCompleteDecorator.decorate(searchField); searchField.setMinimumSize(new Dimension(150, 10)); searchField.setPreferredSize(new Dimension(250, 10)); searchField.setToolTipText( "<HTML>Enter text to search.<BR/>" + "Enter - search next,<BR/>Alt+Enter search previous,<BR/>" + "Ctrl+Enter - mark all found</HTML>"); final DelayedSwingInvoke delayedSearchResultUpdate = new DelayedSwingInvoke() { @Override protected void performActionHook() { JTextComponent editorComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); int stringEnd = editorComponent.getSelectionStart(); if (stringEnd < 0) { stringEnd = editorComponent.getText().length(); } try { String selectedText = editorComponent.getText(0, stringEnd); if (StringUtils.isBlank(selectedText)) { return; } OtrosJTextWithRulerScrollPane<JTextPane> logDetailWithRulerScrollPane = otrosApplication .getSelectedLogViewPanel().getLogDetailWithRulerScrollPane(); MessageUpdateUtils.highlightSearchResult(logDetailWithRulerScrollPane, otrosApplication.getAllPluginables().getMessageColorizers()); RulerBarHelper.scrollToFirstMarker(logDetailWithRulerScrollPane); } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "Can't update search highlight", e); } } }; JTextComponent searchFieldTextComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); searchFieldTextComponent.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { delayedSearchResultUpdate.performAction(); } }); final MarkAllFoundAction markAllFoundAction = new MarkAllFoundAction(otrosApplication); final SearchModeValidatorDocumentListener searchValidatorDocumentListener = new SearchModeValidatorDocumentListener( (JTextField) searchField.getEditor().getEditorComponent(), observer, SearchMode.STRING_CONTAINS); SearchMode searchModeFromConfig = configuration.get(SearchMode.class, "gui.searchMode", SearchMode.STRING_CONTAINS); final String lastSearchString; int selectedSearchMode = 0; if (searchModeFromConfig.equals(SearchMode.STRING_CONTAINS)) { selectedSearchMode = 0; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_STRING, ""); } else if (searchModeFromConfig.equals(SearchMode.REGEX)) { selectedSearchMode = 1; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_REGEX, ""); } else if (searchModeFromConfig.equals(SearchMode.QUERY)) { selectedSearchMode = 2; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_QUERY, ""); } else { LOGGER.warning("Unknown search mode " + searchModeFromConfig); lastSearchString = ""; } Component editorComponent = searchField.getEditor().getEditorComponent(); if (editorComponent instanceof JTextField) { final JTextField sfTf = (JTextField) editorComponent; sfTf.getDocument().addDocumentListener(searchValidatorDocumentListener); sfTf.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { try { int length = e.getDocument().getLength(); if (length > 0) { searchResultColorizer.setSearchString(e.getDocument().getText(0, length)); } } catch (BadLocationException e1) { LOGGER.log(Level.SEVERE, "Error: ", e1); } } }); sfTf.addKeyListener(new SearchFieldKeyListener(searchActionForward, sfTf)); sfTf.setText(lastSearchString); } searchMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SearchMode mode = null; boolean validationEnabled = false; String confKey = null; String lastSearch = ((JTextField) searchField.getEditor().getEditorComponent()).getText(); if (searchMode.getSelectedIndex() == 0) { mode = SearchMode.STRING_CONTAINS; searchValidatorDocumentListener.setSearchMode(mode); validationEnabled = false; searchMode.setToolTipText("Checking if log message contains string (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_STRING; } else if (searchMode.getSelectedIndex() == 1) { mode = SearchMode.REGEX; validationEnabled = true; searchMode .setToolTipText("Checking if log message matches regular expression (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_REGEX; } else if (searchMode.getSelectedIndex() == 2) { mode = SearchMode.QUERY; validationEnabled = true; String querySearchTooltip = "<HTML>" + // "Advance search using SQL-like quries (i.e. level>=warning && msg~=failed && thread==t1)<BR/>" + // "Valid operator for query search is ==, ~=, !=, LIKE, EXISTS, <, <=, >, >=, &&, ||, ! <BR/>" + // "See wiki for more info<BR/>" + // "</HTML>"; searchMode.setToolTipText(querySearchTooltip); confKey = ConfKeys.SEARCH_LAST_QUERY; } searchValidatorDocumentListener.setSearchMode(mode); searchValidatorDocumentListener.setEnable(validationEnabled); searchActionForward.setSearchMode(mode); searchActionBackward.setSearchMode(mode); markAllFoundAction.setSearchMode(mode); configuration.setProperty("gui.searchMode", mode); searchResultColorizer.setSearchMode(mode); List<Object> list = configuration.getList(confKey); searchFieldCbxModel.removeAllElements(); for (Object o : list) { searchFieldCbxModel.addElement(o); } searchField.setSelectedItem(lastSearch); } }); searchMode.setSelectedIndex(selectedSearchMode); final JCheckBox markFound = new JCheckBox("Mark search result"); markFound.setMnemonic(KeyEvent.VK_M); searchField.addKeyListener(markAllFoundAction); configuration.addConfigurationListener(markAllFoundAction); JButton markAllFoundButton = new JButton(markAllFoundAction); final JComboBox markColor = new JComboBox(MarkerColors.values()); markFound.setSelected(configuration.getBoolean("gui.markFound", true)); markFound.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { boolean selected = markFound.isSelected(); searchActionForward.setMarkFound(selected); searchActionBackward.setMarkFound(selected); configuration.setProperty("gui.markFound", markFound.isSelected()); } }); markColor.setRenderer(new MarkerColorsComboBoxRenderer()); // markColor.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); // searchActionForward.setMarkerColors(markerColors); // searchActionBackward.setMarkerColors(markerColors); // markAllFoundAction.setMarkerColors(markerColors); // configuration.setProperty("gui.markColor", markColor.getSelectedItem()); // otrosApplication.setSelectedMarkColors(markerColors); // } // }); markColor.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); searchActionForward.setMarkerColors(markerColors); searchActionBackward.setMarkerColors(markerColors); markAllFoundAction.setMarkerColors(markerColors); configuration.setProperty("gui.markColor", markColor.getSelectedItem()); otrosApplication.setSelectedMarkColors(markerColors); } }); markColor.getModel() .setSelectedItem(configuration.get(MarkerColors.class, "gui.markColor", MarkerColors.Aqua)); buttonSearch = new JButton(searchActionForward); buttonSearch.setMnemonic(KeyEvent.VK_N); JButton buttonSearchPrev = new JButton(searchActionBackward); buttonSearchPrev.setMnemonic(KeyEvent.VK_P); enableDisableComponetsForTabs.addComponet(buttonSearch); enableDisableComponetsForTabs.addComponet(buttonSearchPrev); enableDisableComponetsForTabs.addComponet(searchField); enableDisableComponetsForTabs.addComponet(markFound); enableDisableComponetsForTabs.addComponet(markAllFoundButton); enableDisableComponetsForTabs.addComponet(searchMode); enableDisableComponetsForTabs.addComponet(markColor); toolBar.add(searchMode); toolBar.add(searchField); toolBar.add(buttonSearch); toolBar.add(buttonSearchPrev); toolBar.add(markFound); toolBar.add(markAllFoundButton); toolBar.add(markColor); JButton nextMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.FORWARD)); nextMarked.setToolTipText(nextMarked.getText()); nextMarked.setText(""); nextMarked.setMnemonic(KeyEvent.VK_E); enableDisableComponetsForTabs.addComponet(nextMarked); toolBar.add(nextMarked); JButton prevMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.BACKWARD)); prevMarked.setToolTipText(prevMarked.getText()); prevMarked.setText(""); prevMarked.setMnemonic(KeyEvent.VK_R); enableDisableComponetsForTabs.addComponet(prevMarked); toolBar.add(prevMarked); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.SEVERE))); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.SEVERE))); }
From source file:pl.otros.logview.gui.LogViewPanel.java
protected void initMessageDetailsToolbar() { final JButton buttonFormatters = new JButton("Message formatters", Icons.MESSAGE_FORMATTER); buttonFormatters.addMouseListener(new MouseAdapter() { @Override/*from ww w . j a v a2 s . c o m*/ public void mouseClicked(MouseEvent e) { showMessageFormatterOrColorizerPopupMenu(e, "Message formatters", selectedMessageFormattersContainer, messageFormattersContainer); } }); buttonFormatters.setToolTipText("Select used message formatters"); messageDetailToolbar.add(buttonFormatters); final JButton buttonColorizers = new JButton("Message colorizers", Icons.MESSAGE_COLORIZER); buttonColorizers.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showMessageFormatterOrColorizerPopupMenu(e, "Message colorizers", selectedMessageColorizersContainer, messageColorizersContainer); } }); buttonColorizers.setToolTipText("Select used message colorizers"); messageDetailToolbar.add(buttonColorizers); messageDetailToolbar.add(new CopyStyledMessageDetailAction(otrosApplication, dateFormat, selectedMessageColorizersContainer, selectedMessageFormattersContainer)); messageDetailToolbar.add(new JLabel("Maximum message size for format")); final DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel(new String[] {}); String[] values = new String[] { "10kB", "100kB", "200kB", "300kB", "400kB", "500kB", "600kB", "700kB", "800kB", "900kB", "1MB", "2MB", "3MB", "4MB", "5MB" }; for (String value : values) { defaultComboBoxModel.addElement(value); } final JXComboBox messageMaximumSize = new JXComboBox(defaultComboBoxModel); messageMaximumSize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String max = (String) defaultComboBoxModel.getElementAt(messageMaximumSize.getSelectedIndex()); configuration.setProperty(ConfKeys.MESSAGE_FORMATTER_MAX_SIZE, max); messageDetailListener.setMaximumMessageSize((int) new FileSize(max).getBytes()); } }); messageMaximumSize.setEditable(false); AutoCompleteDecorator.decorate(messageMaximumSize); messageMaximumSize.setMaximumSize(new Dimension(100, 50)); messageDetailToolbar.add(messageMaximumSize); String messageMaxSize = configuration.getString(ConfKeys.MESSAGE_FORMATTER_MAX_SIZE, (String) defaultComboBoxModel.getElementAt(messageMaximumSize.getSelectedIndex())); if (defaultComboBoxModel.getIndexOf(messageMaxSize) >= 0) { messageMaximumSize.setSelectedItem(messageMaxSize); } }
From source file:plugins.ImageRectificationPanel.java
private JButton createButton(String buttonLabel, String toolTip, String actionCommand) { JButton btn = new JButton(buttonLabel); btn.addActionListener(this); btn.setActionCommand(actionCommand); btn.setToolTipText(toolTip); return btn;//from w ww .j a v a2 s . co m }
From source file:ro.nextreports.designer.datasource.ConnectionDialog.java
private void create() { this.getContentPane().setLayout(new GridBagLayout()); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize();//from w w w . j ava 2 s .co m } }); JPanel p = new JPanel(new GridBagLayout()); backColor = p.getBackground(); mName = new JTextField(); mDriver = new JTextField(); //mDriver.setBackground(backColor); mURL = new JTextField(); //mURL.setBackground(backColor); mUser = new JTextField(); //mUser.setBackground(backColor); mPassword = new JPasswordField(); mPassword.setEchoChar('*'); //mPassword.setBackground(backColor); txaStatus = new JTextArea(); txaStatus.setEditable(false); txaStatus.setBackground(backColor); scr = new JScrollPane(txaStatus); scr.setSize(220, 50); scr.setBorder(new TitledBorder(STATUS)); types = new JComboBox(); types.addItemListener(this); urlFormatLabel = new JLabel(); Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10); urlFormatLabel.setFont(font); urlButton = new JButton(); urlButton.setPreferredSize(buttonDim); urlButton.setMinimumSize(buttonDim); urlButton.setMaximumSize(buttonDim); urlButton.setIcon(ImageUtil.getImageIcon("url_edit")); urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip")); urlButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editUrl(); } }); for (DriverTemplate template : templates) { types.addItem(template.getType()); } types.setSelectedItem(DEFAULT_DRIVER_TYPE); auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto")); if (viewOnly) { mName.setEditable(false); types.setEnabled(false); mDriver.setEditable(false); mURL.setEditable(false); mUser.setEditable(false); mPassword.setEditable(false); urlButton.setEnabled(false); } p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); } p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } JButton okBtn, disBtn, drvBtn, addBtn, propBtn; okBtn = new JButton(I18NSupport.getString("connection.dialog.test"), ImageUtil.getImageIcon("database_connect")); okBtn.setMnemonic('T'); okBtn.setActionCommand("ConnectOk"); okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip")); okBtn.addActionListener(this); disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"), ImageUtil.getImageIcon("database")); disBtn.setMnemonic('D'); disBtn.setActionCommand("Disconnect"); disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect")); disBtn.addActionListener(this); drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"), ImageUtil.getImageIcon("add_driver")); drvBtn.setMnemonic('A'); drvBtn.setActionCommand("AddDriver"); drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip")); drvBtn.addActionListener(this); propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"), ImageUtil.getImageIcon("properties")); propBtn.setMnemonic('P'); propBtn.setActionCommand("Properties"); propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip")); propBtn.addActionListener(this); addBtn = new JButton(ImageUtil.getImageIcon("database_export")); if (oldDataSource == null) { addBtn.setText(I18NSupport.getString("connection.dialog.save")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip")); addBtn.setMnemonic('S'); } else { addBtn.setText(I18NSupport.getString("connection.dialog.modify")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip")); addBtn.setMnemonic('M'); } addBtn.setActionCommand("AddDataSource"); addBtn.addActionListener(this); JPanel btnPanel = new JPanel(); btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS)); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(propBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(okBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); //btnPanel.add(disBtn); //btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(addBtn); // btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); // btnPanel.add(drvBtn); SwingUtil.equalizeButtonSizes(btnPanel); if (!viewOnly) { p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); if (oldDataSource != null) { mName.setText(oldDataSource.getName()); types.setSelectedItem(oldDataSource.getType()); mDriver.setText(oldDataSource.getDriver()); mURL.setText(oldDataSource.getUrl()); mUser.setText(oldDataSource.getUser()); mPassword.setText(oldDataSource.getPassword()); } }
From source file:savant.util.swing.TrackChooser.java
private JButton createMoveRight() { JButton moveRight = new JButton(">"); moveRight.setToolTipText("Add item(s) to selected"); moveRight.addActionListener(new ActionListener() { @Override/*from ww w .j a v a 2 s . co m*/ public void actionPerformed(ActionEvent e) { Object[] selected = leftList.getSelectedValues(); if (selected.length > 1 && !multiple) return; if (((TrackListModel) rightList.getModel()).getSize() > 0 && !multiple) return; for (int i = 0; i < selected.length; i++) { ((TrackListModel) rightList.getModel()).add(selected[i].toString()); } ((TrackListModel) leftList.getModel()).removeIndices(leftList.getSelectedIndices()); rightList.updateUI(); leftList.updateUI(); leftList.clearSelection(); rightList.clearSelection(); } }); return moveRight; }
From source file:savant.util.swing.TrackChooser.java
private JButton createMoveLeft() { JButton moveLeft = new JButton("<"); moveLeft.setToolTipText("Remove item(s) from selected"); moveLeft.addActionListener(new ActionListener() { @Override/* www. j ava 2s .co m*/ public void actionPerformed(ActionEvent e) { Object[] selected = rightList.getSelectedValues(); if (selected.length > 1 && !multiple) return; for (int i = 0; i < selected.length; i++) { ((TrackListModel) leftList.getModel()).add(selected[i].toString()); } ((TrackListModel) rightList.getModel()).removeIndices(rightList.getSelectedIndices()); leftList.updateUI(); rightList.updateUI(); leftList.clearSelection(); rightList.clearSelection(); } }); return moveLeft; }
From source file:savant.util.swing.TrackChooser.java
private JButton createAllRight() { JButton allRight = new JButton(">>"); allRight.setToolTipText("Add all to selected"); if (!this.multiple) allRight.setEnabled(false);/*from ww w. ja va 2 s. c o m*/ allRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectAll(); } }); return allRight; }
From source file:savant.util.swing.TrackChooser.java
private JButton createAllLeft() { JButton allLeft = new JButton("<<"); allLeft.setToolTipText("Remove all from selected"); if (!this.multiple) allLeft.setEnabled(false);// w ww .j a v a 2 s . co m allLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] stringsRight = ((TrackListModel) rightList.getModel()).getAll(); for (int i = 0; i < stringsRight.length; i++) { ((TrackListModel) leftList.getModel()).add(stringsRight[i]); } ((TrackListModel) rightList.getModel()).removeAll(); leftList.updateUI(); rightList.updateUI(); leftList.clearSelection(); rightList.clearSelection(); } }); return allLeft; }