Java Code Examples for javax.swing.JButton#setFocusable()
The following examples show how to use
javax.swing.JButton#setFocusable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluggableTreeTableView.java From visualvm with GNU General Public License v2.0 | 6 votes |
PluginContainer(HeapViewPlugin plugin, final PluginPresenter pluginPresenter) { super(new BorderLayout()); this.plugin = plugin; JButton closeButton = CloseButton.create(new Runnable() { public void run() { pluginPresenter.setSelected(false); } }); closeButton.setFocusable(true); JPanel detailHeader = new JPanel(null); detailHeader.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, SEPARATOR_COLOR)); detailHeader.setLayout(new BoxLayout(detailHeader, BoxLayout.LINE_AXIS)); detailHeader.setBackground(UIUtils.getDarker(UIUtils.getProfilerResultsBackground())); JLabel captionL = new JLabel(plugin.getName(), plugin.getIcon(), JLabel.LEADING); captionL.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); detailHeader.add(captionL); detailHeader.add(Box.createGlue()); detailHeader.add(closeButton); add(detailHeader, BorderLayout.NORTH); setVisible(pluginPresenter.isSelected()); }
Example 2
Source File: NotificationImpl.java From netbeans with Apache License 2.0 | 6 votes |
private JComponent createDetails( String text, ActionListener action ) { if( null == action ) { return new JLabel(text); } try { text = "<html><u>" + XMLUtil.toElementContent(text); //NOI18N } catch( CharConversionException ex ) { throw new IllegalArgumentException(ex); } JButton btn = new JButton(text); btn.setFocusable(false); btn.setBorder(BorderFactory.createEmptyBorder()); btn.setBorderPainted(false); btn.setFocusPainted(false); btn.setOpaque(false); btn.setContentAreaFilled(false); btn.addActionListener(action); btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N if (c != null) { btn.setForeground(c); } return btn; }
Example 3
Source File: NotifyExcPanel.java From netbeans with Apache License 2.0 | 6 votes |
private static JComponent getDetailsPanel(String summary) { JPanel details = new JPanel(new GridBagLayout()); details.setOpaque(false); JLabel lblMessage = new JLabel(summary); JButton reportLink = new JButton("<html><a href=\"_blank\">" + NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionReport")); //NOI18N reportLink.setFocusable(false); reportLink.setBorder(BorderFactory.createEmptyBorder()); reportLink.setBorderPainted(false); reportLink.setFocusPainted(false); reportLink.setOpaque(false); reportLink.setContentAreaFilled(false); reportLink.addActionListener(flash); reportLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); details.add(reportLink, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0)); details.add(lblMessage, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0)); return details; }
Example 4
Source File: JProductsSelector.java From nordpos with GNU General Public License v3.0 | 6 votes |
public void addProduct(Image img, String name, ActionListener al) { JButton btn = new JButton(); btn.applyComponentOrientation(getComponentOrientation()); btn.setText(name); btn.setFont(btn.getFont().deriveFont((float)24)); btn.setIcon(new ImageIcon(img)); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setMargin(new Insets(2, 2, 2, 2)); btn.setMaximumSize(new Dimension(80, 70)); btn.setPreferredSize(new Dimension(80, 70)); btn.setMinimumSize(new Dimension(80, 70)); btn.addActionListener(al); flowpanel.add(btn); }
Example 5
Source File: DialogMainPanel.java From magarena with GNU General Public License v3.0 | 6 votes |
ButtonsPanel() { closeButton = new CloseButton(); closeButton.setFocusable(false); closeButton.addActionListener(getCancelAction()); final JButton helpButton = new JButton(); helpButton.setIcon(MagicImages.getIcon(MagicIcon.MISSING)); helpButton.setFocusable(false); helpButton.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WikiPage.show(WikiPage.IMAGE_DOWNLOADS); } }); hintPanel.addHintSource(helpButton, String.format("<b>%s</b><br>%s", MText.get(_S2), MText.get(_S4) )); setLayout(new MigLayout("insets 0, alignx right, aligny bottom")); add(helpButton); add(backgroundButton, "w 100%"); add(closeButton); }
Example 6
Source File: FlatTitlePane.java From FlatLaf with Apache License 2.0 | 5 votes |
protected JButton createButton( String iconKey, String accessibleName, ActionListener action ) { JButton button = new JButton( UIManager.getIcon( iconKey ) ); button.setFocusable( false ); button.setContentAreaFilled( false ); button.setBorder( BorderFactory.createEmptyBorder() ); button.putClientProperty( AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName ); button.addActionListener( action ); return button; }
Example 7
Source File: DialogedTableCellEditor.java From ramus with GNU General Public License v3.0 | 5 votes |
private JButton createEditButton() { JButton edit = new JButton(); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { edit(); } }); edit.setIcon(new ImageIcon(getClass().getResource( "/com/ramussoft/gui/edit.png"))); edit.setToolTipText(GlobalResourcesManager.getString("edit")); edit.setFocusable(false); edit.setPreferredSize(new Dimension(16, 16)); return edit; }
Example 8
Source File: DashboardToolbar.java From netbeans with Apache License 2.0 | 5 votes |
public void addButton(JButton button) { button.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 2, 2, 2)); button.setBorderPainted(false); button.setFocusable(false); button.setOpaque(false); add(button); }
Example 9
Source File: VariablesViewButtons.java From netbeans with Apache License 2.0 | 5 votes |
private static JButton createButton (String iconPath, String tooltip) { Icon icon = ImageUtilities.loadImageIcon(iconPath, false); final JButton button = new JButton(icon); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); button.setPreferredSize(size); button.setMargin(new Insets(1, 1, 1, 1)); button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button))); button.setToolTipText(tooltip); button.setFocusable(false); return button; }
Example 10
Source File: JPaymentCashPos.java From nordpos with GNU General Public License v3.0 | 5 votes |
public void addButton(String image, double amount) { JButton btn = new JButton(); btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image), Formats.CURRENCY.formatValue(amount)))); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setMargin(new Insets(2, 2, 2, 2)); btn.addActionListener(new AddAmount(amount)); jPanel6.add(btn); }
Example 11
Source File: ButtonFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates button to show drop-down list of documents from the given tab displayer. * @param controller Tab displayer's controller. * @return Drop-down list button. */ public static JButton createDropDownButton( Controller controller ) { final JButton btn = new JButton( new TabListPopupAction(controller) ); Icon icon = UIManager.getIcon("nb.multitabs.button.dropdown.icon"); if (icon == null) { icon = ImageUtilities.loadImageIcon( "org/netbeans/core/multitabs/resources/down.png", true ); //NOI18N } btn.setIcon( icon ); btn.setActionCommand( "pressed"); //NOI18N btn.setFocusable( false ); btn.setToolTipText( NbBundle.getMessage(ButtonFactory.class, "Hint_DocumentList") ); return btn; }
Example 12
Source File: CloseButtonFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a small 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel * * @return JButton with close icons. */ public static JButton createCloseButton() { JButton closeButton = new JButton(); int size = 16; closeButton.setPreferredSize(new Dimension(size, size)); closeButton.setContentAreaFilled(false); closeButton.setFocusable(false); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setBorderPainted(false); closeButton.setRolloverEnabled(true); closeButton.setIcon(getCloseTabImage()); closeButton.setRolloverIcon(getCloseTabRolloverImage()); closeButton.setPressedIcon(getCloseTabPressedImage()); return closeButton; }
Example 13
Source File: CloseButtonFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a big 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel * * @return JButton with close icons. */ public static JButton createBigCloseButton() { JButton closeButton = new JButton(); int size = 19; closeButton.setPreferredSize(new Dimension(size, size)); closeButton.setContentAreaFilled(false); closeButton.setFocusable(false); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setBorderPainted(false); closeButton.setRolloverEnabled(true); closeButton.setIcon(getBigCloseTabImage()); closeButton.setRolloverIcon(getBigCloseTabRolloverImage()); closeButton.setPressedIcon(getBigCloseTabPressedImage()); return closeButton; }
Example 14
Source File: CloseTabPanel.java From zap-extensions with Apache License 2.0 | 5 votes |
public CloseTabPanel(String tabName, NumberedTabbedPane ntp) { super(); this.ntp = ntp; this.setOpaque(false); JLabel lblTitle = new JLabel(tabName); JButton btnClose = new JButton(); btnClose.setOpaque(false); // Configure icon and rollover icon for button btnClose.setRolloverIcon(CLOSE_TAB_RED_ICON); btnClose.setRolloverEnabled(true); btnClose.setContentAreaFilled(false); btnClose.setToolTipText(Constant.messages.getString("all.button.close")); btnClose.setIcon(CLOSE_TAB_GREY_ICON); // Set a border only on the left side so the button doesn't make the tab too big btnClose.setBorder(new EmptyBorder(0, 6, 0, 0)); // This is needed to Macs for some reason btnClose.setBorderPainted(false); // Make sure the button can't get focus, otherwise it looks funny btnClose.setFocusable(false); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; this.add(lblTitle, gbc); gbc.gridx++; gbc.weightx = 0; this.add(btnClose, gbc); btnClose.addActionListener(new CloseActionHandler(this.ntp, tabName)); }
Example 15
Source File: FilterDialog.java From WhiteRabbit with Apache License 2.0 | 4 votes |
public FilterDialog(Window parentWindow){ super(parentWindow,"Filter",ModalityType.MODELESS); this.setResizable(false); this.setLocation(parentWindow.getX()+parentWindow.getWidth()/2, parentWindow.getY()+100); contentPane.setLayout(layout); sourceSearchField = new JTextField(30); sourceSearchField.setName("Source"); targetSearchField = new JTextField(30); targetSearchField.setName("Target"); // Add key listener to send search string as it's being typed sourceSearchField.addKeyListener(new SearchListener() ); sourceSearchField.addFocusListener(new SearchFocusListener()); JLabel sourceLabel = new JLabel("Filter Source:",JLabel.TRAILING); JButton sourceClearBtn = new JButton("Clear"); contentPane.add(sourceLabel); contentPane.add(sourceSearchField); sourceClearBtn.addActionListener(this); sourceClearBtn.setActionCommand("Clear Source"); sourceClearBtn.setFocusable(false); contentPane.add(sourceClearBtn); targetSearchField.addKeyListener(new SearchListener() ); targetSearchField.addFocusListener(new SearchFocusListener()); JLabel targetLabel = new JLabel("Filter Target:",JLabel.TRAILING); JButton targetClearBtn = new JButton("Clear"); contentPane.add(targetLabel); contentPane.add(targetSearchField); targetClearBtn.addActionListener(this); targetClearBtn.setActionCommand("Clear Target"); targetClearBtn.setFocusable(false); contentPane.add(targetClearBtn); layout.putConstraint(SpringLayout.WEST, sourceLabel, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, sourceLabel, 5, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, sourceSearchField, 5, SpringLayout.EAST, sourceLabel); layout.putConstraint(SpringLayout.NORTH, sourceSearchField, 5, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, sourceClearBtn, 5, SpringLayout.EAST, sourceSearchField); layout.putConstraint(SpringLayout.NORTH, sourceClearBtn, 5, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, targetLabel, 5, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, targetLabel, 10, SpringLayout.SOUTH, sourceLabel); layout.putConstraint(SpringLayout.WEST, targetSearchField, 0, SpringLayout.WEST, sourceSearchField); layout.putConstraint(SpringLayout.NORTH, targetSearchField, 0, SpringLayout.NORTH, targetLabel); layout.putConstraint(SpringLayout.WEST, targetClearBtn, 5, SpringLayout.EAST, targetSearchField); layout.putConstraint(SpringLayout.NORTH, targetClearBtn, 0, SpringLayout.NORTH, targetSearchField); layout.putConstraint(SpringLayout.SOUTH, contentPane, 5, SpringLayout.SOUTH, targetLabel); layout.putConstraint(SpringLayout.NORTH, contentPane, 5, SpringLayout.NORTH, sourceLabel); layout.putConstraint(SpringLayout.WEST, contentPane, 5, SpringLayout.WEST, sourceLabel); layout.putConstraint(SpringLayout.EAST, contentPane, 5, SpringLayout.EAST, targetClearBtn); this.pack(); }
Example 16
Source File: UriEditPanel.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; labelBrowseCurrentLink = UI_COMPO_FACTORY.makeLabel(); textFieldURI = UI_COMPO_FACTORY.makeTextField(); textFieldURI.setComponentPopupMenu(SwingUtils.addTextActions(UI_COMPO_FACTORY.makePopupMenu())); labelValidator = UI_COMPO_FACTORY.makeLabel(); setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); setLayout(new java.awt.GridBagLayout()); labelBrowseCurrentLink.setIcon(AllIcons.Buttons.URL_LINK_BIG); java.util.ResourceBundle bundle = BUNDLE; labelBrowseCurrentLink.setToolTipText(bundle.getString("UriEditPanel.labelBrowseCurrentLink.toolTipText")); // NOI18N labelBrowseCurrentLink.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); labelBrowseCurrentLink.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); labelBrowseCurrentLink.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { labelBrowseCurrentLinkMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 10; add(labelBrowseCurrentLink, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1000.0; add(textFieldURI, gridBagConstraints); labelValidator.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); labelValidator.setIcon(AllIcons.Buttons.QUESTION); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 10; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(labelValidator, gridBagConstraints); final JButton resetButton = new JButton(AllIcons.Buttons.CROSS); gridBagConstraints.ipadx = 0; add(resetButton, gridBagConstraints); resetButton.setFocusable(false); resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldURI.setText(""); } }); }
Example 17
Source File: GameStateRunner.java From magarena with GNU General Public License v3.0 | 4 votes |
private JButton getCancelButton() { final JButton btn = new CancelButton(); btn.setFocusable(false); btn.addActionListener(getCancelAction()); return btn; }
Example 18
Source File: FunctionOptionsDialog.java From ramus with GNU General Public License v3.0 | 4 votes |
private void load() { Engine e = dataPlugin.getEngine(); Qualifier qualifier = function.getQualifier(); attributes = new ArrayList<Attribute>(qualifier.getAttributes()); for (int i = attributes.size() - 1; i >= 0; i--) { Attribute attribute = attributes.get(i); AttributePlugin plugin = framework.findAttributePlugin(attribute .getAttributeType()); Element element = ((NFunction) function).getElement(); AttributeEditor editor = plugin.getAttributeEditor(e, dataPlugin .getAccessRules(), element, attribute, "function", null); if (editor == null) continue; attributeEditors.add(0, editor); JComponent component = editor.getComponent(); JPanel panel = new JPanel(new BorderLayout()); panel.add(component, BorderLayout.CENTER); Action[] actions = editor.getActions(); if (actions.length > 0) { JToolBar bar = new JToolBar(); for (Action a : actions) { JButton b = bar.add(a); b.setFocusable(false); bar.add(b); } panel.add(bar, BorderLayout.NORTH); } getJTabbedPane().insertTab(attribute.getName(), null, panel, null, 0); Object value = e.getAttribute(element, attribute); editor.setValue(value); values.add(0, value); } getJColorChooser().setColor(function.getBackground()); getJColorChooser1().setColor(function.getForeground()); getJFontChooser().setSelFont(function.getFont()); functionType.setFunction(function); selectOwner.setFunction(function); }
Example 19
Source File: UserActionPanel.java From magarena with GNU General Public License v3.0 | 4 votes |
public UserActionPanel(final SwingGameController controller) { this.controller=controller; setMinimumSize(new Dimension(0, 114)); setOpaque(false); final JLabel emptyLabel=new JLabel(""); imageLabel.setHorizontalAlignment(SwingConstants.CENTER); busyItem = new ImageThrobber.Builder(BUSY_IMAGE) .antiAlias(true) .spinPeriod(3000) .build(); actionButton=new JButton(); actionButton.setIcon(MagicImages.getIcon(MagicIcon.FORWARD)); actionButton.setFocusable(false); actionButton.addActionListener(this); actionButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { controller.passKeyPressed(); } } }); undoButton=new JButton(MagicImages.getIcon(MagicIcon.UNDO)); undoButton.setMargin(new Insets(1,1,1,1)); undoButton.setIconTextGap(2); undoButton.setEnabled(false); undoButton.setFocusable(false); undoButton.addActionListener(this); actionPanel=new JPanel(); actionCardLayout=new CardLayout(); actionPanel.setLayout(actionCardLayout); actionPanel.setOpaque(false); actionPanel.add(emptyLabel,"0"); actionPanel.add(imageLabel, "4"); actionPanel.add(busyItem,"1"); actionPanel.add(actionButton,"2"); final JPanel rightPanel=new JPanel(new GridLayout(2,1,0,2)); rightPanel.setPreferredSize(new Dimension(60,0)); rightPanel.add(actionPanel); rightPanel.add(undoButton); rightPanel.setOpaque(false); contentPanel=new JPanel(); contentPanel.setLayout(new BorderLayout()); contentPanel.setOpaque(false); final JScrollPane scroller = new JScrollPane(); scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroller.getViewport().setOpaque(false); scroller.getViewport().add(contentPanel); setLayout(new BorderLayout()); add(scroller, BorderLayout.CENTER); add(rightPanel,BorderLayout.EAST); disableButton(false); // add mouse over listeners used to display the card image // associated with the current choice if applicable. setCardPopupOnMouseOverListener(); setComponentOnMouseOverListener(scroller); setComponentOnMouseOverListener(rightPanel); setComponentOnMouseOverListener(actionButton); setComponentOnMouseOverListener(undoButton); }
Example 20
Source File: AddTcpMapRuleFrame.java From xtunnel with GNU General Public License v2.0 | 4 votes |
JButton createButton(String name){ JButton button=new JButton(name); button.setMargin(new Insets(0,5,0,5)); button.setFocusable(false); return button; }