List of usage examples for javax.swing JComboBox setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
@Override protected void setupSearchToolBar() { // additional functionality in Search panel: //final JPanel pnlCustomToolBarAreaSearch = new JPanel(); //pnlCustomToolBarAreaSearch.setLayout(new GridBagLayout()); super.setupSearchToolBar(); //final JToolBar toolbarSearchCustom = newCustomSearchToolBar(); if (SecurityCache.getInstance().isActionAllowed(Actions.ACTION_READ_DELETED_RECORD)) { //toolbarSearchCustom.add(Box.createHorizontalStrut(5)); //cmbbxSearchDeleted.addItem(SpringLocaleDelegate.getMessage("GenericObjectCollectController.59","Nur ungel\u00f6schte suchen")); //cmbbxSearchDeleted.addItem(SpringLocaleDelegate.getMessage("GenericObjectCollectController.58","Nur gel\u00f6schte suchen")); //cmbbxSearchDeleted.addItem(SpringLocaleDelegate.getMessage("GenericObjectCollectController.49","Gel\u00f6schte und ungel\u00f6schte suchen")); btnGrpSearchDeleted.add(miSearchDeleted[0]); btnGrpSearchDeleted.add(miSearchDeleted[1]); btnGrpSearchDeleted.add(miSearchDeleted[2]); btnGrpSearchDeleted.setSelected(miSearchDeleted[0].getModel(), true); //UIUtils.setMaximumSizeToPreferredSize(cmbbxSearchDeleted); //toolbarSearchCustom.add(cmbbxSearchDeleted); //this.getSearchPanel().addToolBarComponent(cmbbxSearchDeleted); this.getSearchPanel().addPopupExtraSeparator(); this.getSearchPanel().addPopupExtraMenuItem(miSearchDeleted[0]); this.getSearchPanel().addPopupExtraMenuItem(miSearchDeleted[1]); this.getSearchPanel().addPopupExtraMenuItem(miSearchDeleted[2]); /*cmbbxSearchDeleted.addItemListener(new ItemListener() { @Override/* w w w .ja v a2 s. co m*/ public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) iSearchDeleted = cmbbxSearchDeleted.getSelectedIndex(); } });*/ ItemListener il = new ItemListener() { @Override public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { for (int i = 0; i < miSearchDeleted.length; i++) { if (ev.getSource() == miSearchDeleted[i]) iSearchDeleted = i; } } } }; miSearchDeleted[0].addItemListener(il); miSearchDeleted[1].addItemListener(il); miSearchDeleted[2].addItemListener(il); } refreshFilterView(); // glue: //final JToolBar toolbarGlue = UIUtils.createNonFloatableToolBar(); // add toolbars to custom toolbar area: /*final GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.VERTICAL; gbc.weightx = 0.0; gbc.weighty = 1.0; pnlCustomToolBarAreaSearch.add(toolbarSearchCustom, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; pnlCustomToolBarAreaSearch.add(toolbarGlue, gbc); gbc.fill = GridBagConstraints.VERTICAL; gbc.weightx = 0.0; gbc.weighty = 1.0; JToolBar toolSearchState = UIUtils.createNonFloatableToolBar(); */ JComboBox jComboBox = getSearchStateBox().getJComboBox(); //UIUtils.setMaximumSizeToPreferredSize(jComboBox); jComboBox.setToolTipText( getSpringLocaleDelegate().getMessage("GenericObjectCollectController.8", "Aktueller Status")); //jComboBox.setOpaque(false); //CenteringPanel cpSearchState = new CenteringPanel(jComboBox); //cpSearchState.setOpaque(false); //toolSearchState.add(cpSearchState); //toolSearchState.add(Box.createHorizontalStrut(5)); ColoredLabel lbSearchBox = new ColoredLabel(jComboBox, getSpringLocaleDelegate().getMessage("nuclos.entityfield.eo.state.label", "Status")); lbSearchBox.setName("blSearchState"); this.getSearchPanel().addToolBarComponent(lbSearchBox, 6); //pnlCustomToolBarAreaSearch.add(toolSearchState, gbc); setSearchStatesAccordingToUsageCriteria(new UsageCriteria(iModuleId, null, null, getCustomUsage())); //getSearchPanel().setCustomToolBarArea(pnlCustomToolBarAreaSearch); }
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);// w ww. j a v a 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:shuffle.fwk.service.roster.EditRosterService.java
private JPanel createRosterComponent(Species s) { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 1;//from w w w.j a va 2s .c om c.gridy = 1; c.anchor = GridBagConstraints.CENTER; MouseAdapter ma = new PressOrClickMouseAdapter() { @Override protected void onRight(MouseEvent e) { onLeft(e); } @Override protected void onLeft(MouseEvent e) { setSelected(s, ret); selectedDisplayLabel.repaint(); } @Override protected void onEnter() { // Do nothing } }; SpeciesPaint sp = new SpeciesPaint(s, false, getMegaFilter()); ImageIcon icon = getUser().getImageManager().getImageFor(sp); JLabel iconLabel = new JLabel(icon); iconLabel.addMouseListener(ma); ret.add(iconLabel, c); c.gridy += 1; JLabel jLabel = new JLabel(s.getLocalizedName(getMegaFilter())); jLabel.setHorizontalTextPosition(SwingConstants.CENTER); jLabel.setHorizontalAlignment(SwingConstants.CENTER); jLabel.addMouseListener(ma); ret.add(jLabel, c); JComboBox<Integer> level = new JComboBox<Integer>(); for (int i = 0; i <= Species.MAX_LEVEL; i++) { level.addItem(i); } Integer thisLevel = getLevelFor(s); level.setSelectedItem(thisLevel); level.setToolTipText(getString(KEY_POKEMON_LEVEL_TOOLTIP)); c.gridy += 1; // put the level selector below the icon. ret.add(level, c); level.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int index = level.getSelectedIndex(); myData.setLevelForSpecies(s, index); rebuildSelectedLabel(); } }); return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component createTeamComponent(Species s) { Team curTeam = getCurrentTeam();/*from w w w . j ava 2 s. co m*/ JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 1; c.gridy = 1; c.gridwidth = 2; Indicator<SpeciesPaint> ind = new Indicator<SpeciesPaint>(this); boolean isMega = megaProgress >= megaThreshold && s.getName().equals(curTeam.getMegaSlotName()); SpeciesPaint paint = new SpeciesPaint(s, s.equals(Species.FREEZE), isMega); ind.setVisualized(paint); ret.add(ind, c); c.gridy += 1; c.gridwidth = 1; JButton removeButton = new JButton(getString(KEY_REMOVE)); removeButton.setToolTipText(getString(KEY_REMOVE_TOOLTIP)); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { removeSpeciesFromTeam(s.getName()); updateTeamPanel(); } }); removeButton.setEnabled( s.getEffect(getUser().getRosterManager()).isPickable() && !s.getType().equals(PkmType.NONE)); ret.add(removeButton, c); c.gridx += 1; JComboBox<Character> keybindsComboBox = new JComboBox<Character>(); Character curBinding = curTeam.getBinding(s); LinkedHashSet<Character> allBindingsFor = new LinkedHashSet<Character>(Arrays.asList(curBinding)); LinkedHashSet<Character> availableBindings = myData.getAllAvailableBindingsFor(s.getName(), curTeam); allBindingsFor.addAll(availableBindings); for (Character ch : allBindingsFor) { keybindsComboBox.addItem(ch); } keybindsComboBox.setSelectedItem(curBinding); final ItemListener bindingListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { JComboBox<?> source = (JComboBox<?>) e.getSource(); int selectedIndex = source.getSelectedIndex(); Character selected = (Character) source.getItemAt(selectedIndex); setBinding(s, selected); updateKeybindComboBoxes(); } }; nameToKeybindComboboxMap.put(s.getName(), keybindsComboBox); nameToItemListenerMap.put(s.getName(), bindingListener); keybindsComboBox.addItemListener(bindingListener); keybindsComboBox.setToolTipText(getString(KEY_KEYBINDS_TOOLTIP)); ret.add(keybindsComboBox, c); MouseAdapter ma = new PressToggleMouseAdapter() { @Override protected void onRight(MouseEvent e) { doToggle(); } @Override protected void onLeft(MouseEvent e) { doToggle(); } private void doToggle() { toggleSupport(s); updateTeamPanel(); } }; ret.addMouseListener(ma); setBorderFor(ret, false, false); if (!Species.FIXED_SPECIES.contains(s)) { boolean isSupport = !curTeam.isNonSupport(s); Color indColor = isSupport ? Color.GREEN : Color.RED; ret.setBackground(indColor); ret.setOpaque(true); } return ret; }
From source file:statemachinedesigner.EditorApplet.java
/** * create an instance of a simple graph with popup controls to * create a graph.// w ww .j a v a2s . c om * */ public EditorApplet(SimulatorController controller) { // create a simple graph for the demo _controller = controller; _graph = new DirectedSparseGraph<Number, Number>(); this.layout = new StaticLayout<Number, Number>(_graph, new Dimension(600, 600)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Number, String>getInstance( LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>()))); vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<Number, String>getInstance( LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); Factory<Number> vertexFactory = new VertexFactory(); Factory<Number> edgeFactory = new EdgeFactory(); final EditingModalGraphMouse<Number, Number> graphMouse = new EditingModalGraphMouse<Number, Number>( vv.getRenderContext(), vertexFactory, edgeFactory); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); JButton submitButton = new JButton("Submit"); submitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LinkedList<Number> vertices = new LinkedList<Number>(); vertices.addAll(_graph.getVertices()); for (Number n : vertices) { if (_graph.getNeighborCount(n) == 0) { _graph.removeVertex(n); } } LinkedList<Number> edges = new LinkedList<Number>(); edges.addAll(_graph.getEdges()); for (Number n : edges) { if (_graph.getDest(n) == null) { _graph.removeEdge(n); } else if (_graph.getSource(n) == _graph.getDest(n)) { _graph.removeEdge(n); } } vv.repaint(); } }); JButton clearButton = new JButton("Clear All"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //add code to clear all nodes vertexCount = 0; edgeCount = 0; LinkedList<Number> vertices = new LinkedList<Number>(); vertices.addAll(_graph.getVertices()); for (Number n : vertices) { _graph.removeVertex(n); } vv.repaint(); } }); JButton clearEdgesButton = new JButton("Clear All Edges"); clearEdgesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { edgeCount = 0; LinkedList<Number> edges = new LinkedList<Number>(); edges.addAll(_graph.getEdges()); for (Number n : edges) { _graph.removeEdge(n); } vv.repaint(); } }); //to be removed JButton helpButton = new JButton("Help"); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.removeItemAt(0); //transforming modeBox.removeItemAt(2); //annotating modeBox.setToolTipText( "Editing mode allows for insertion and removal of edges/vertices; Picking mode is for placement"); JPanel controlPanel = new JPanel(); controlPanel.add(new JLabel("Mouse Mode")); controlPanel.add(modeBox); controlPanel.add(submitButton); controlPanel.add(clearButton); controlPanel.add(clearEdgesButton); controlPanel.add(helpButton); content.add(controlPanel, BorderLayout.SOUTH); }