当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setFocusable方法代码示例

本文整理汇总了Java中javax.swing.JButton.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setFocusable方法的具体用法?Java JButton.setFocusable怎么用?Java JButton.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setFocusable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDetails

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createDetails(String text, ActionListener action) {
    try {
        text = (action == null ? "<html>" : "<html><a href=\"_blank\">") + XMLUtil.toElementContent(text); //NOI18N
    } catch (CharConversionException ex) {
        throw new IllegalArgumentException(ex);
    }
    if (null == action) {
        return new JLabel(text);
    }
    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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NotificationImpl.java

示例2: createButtons

import javax.swing.JButton; //导入方法依赖的package包/类
void createButtons() {
    for (int i = 0; i < chars.length; i++) {
        JButton button = new JButton(new CharAction(chars[i]));
        button.setMaximumSize(new Dimension(50, 22));
        //button.setMinimumSize(new Dimension(22, 22));
        button.setPreferredSize(new Dimension(30, 22));
        button.setRequestFocusEnabled(false);
        button.setFocusable(false);
        button.setBorderPainted(false);
        button.setOpaque(false);
        button.setMargin(new Insets(0,0,0,0));
        button.setFont(new Font("serif", 0, 14));
        if (i == chars.length-1) {
            button.setText("nbsp");
            button.setFont(new Font("Dialog",0,10));
            button.setMargin(new Insets(0,0,0,0));
        }
        this.add(button, null);
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:21,代码来源:CharTablePanel.java

示例3: jPanel_srEquipmentBrowseCategoriesComponentShown

import javax.swing.JButton; //导入方法依赖的package包/类
private void jPanel_srEquipmentBrowseCategoriesComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel_srEquipmentBrowseCategoriesComponentShown
    if (!initializedEquipmentBrowse) {
        List<String> categories = mil2525CSymbolController.getCategories();
        for (final String category : categories) {
            final JButton button = new JButton(category);
            button.setFont(BUTTON_FONT);
            button.setHorizontalAlignment(SwingConstants.LEFT);
            button.setFocusable(false);
            button.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    selectedCategory = category;
                    equipmentListJPanel_srEquipmentCategoryResults.removeAll();
                    jLabel_srEquipmentCategory.setText(selectedCategory);
                    showCard("Spot Report Equipment Category Card");
                }
            });
            button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
            button.setMinimumSize(new Dimension(0, 60));
            jPanel_srEquipmentCategories.add(button);
        }

        initializedEquipmentBrowse = true;
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:26,代码来源:MainMenuJPanel.java

示例4: createToolBar

import javax.swing.JButton; //导入方法依赖的package包/类
public JToolBar createToolBar() {
    JToolBar bar = new JToolBar();

    for (Action action : getActions()) {
        if (action != null) {
            String command = (String) action
                    .getValue(Action.ACTION_COMMAND_KEY);
            JButton button = bar.add(action);
            button.setFocusable(false);
            if (action.getValue(Action.SHORT_DESCRIPTION) == null) {
                String text = null;
                StringGetter getter = (StringGetter) action
                        .getValue(StringGetter.ACTION_STRING_GETTER);
                if (getter != null)
                    text = getter.getString(command);
                else
                    text = GlobalResourcesManager.getString(command);
                if (text != null)
                    button.setToolTipText(text);
            }
        } else
            bar.addSeparator();
    }

    return bar;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:27,代码来源:SelectableTableView.java

示例5: createBackButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createBackButton() {
    JButton backButton = new JButton(new ResourceAction("getting_started.back", new Object[0]) {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            CardLayout layout = (CardLayout)OpenProcessCard.this.getLayout();
            layout.show(OpenProcessCard.this, "overview");
            OpenProcessCard.this.isOverviewShown = true;
            if(OpenProcessCard.this.entryList.getModel().getSize() > 0) {
                OpenProcessCard.this.entryList.setSelectedIndex(0);
            }

            OpenProcessCard.this.entryList.requestFocusInWindow();
        }
    });
    backButton.setFocusable(false);
    this.styleButton(backButton);
    return backButton;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:OpenProcessCard.java

示例6: createConfigureButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createConfigureButton() {
    if( null == browserProvider || !browserProvider.hasCustomizer() )
        return null;
    JButton button = new JButton(NbBundle.getMessage(BrowserMenu.class, "Ctl_ConfigurePhoneGap"));
    button.addActionListener( new ActionListener() {

        @Override
        public void actionPerformed( ActionEvent e ) {
            browserProvider.customize();
        }
    });
    button.setBorder( new EmptyBorder(1, 1, 1, 1) );
    button.setMargin( new Insets(0, 0, 0, 0) );

    button.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
    button.setHorizontalAlignment( JLabel.LEFT );
    button.setFocusable( false );

    button.setBorderPainted( false );
    button.setFocusPainted( false );
    button.setRolloverEnabled( true );
    button.setContentAreaFilled( false );

    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:BrowserMenu.java

示例7: createUpDown

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createUpDown() {

        TableLayout layout = new TableLayout(new double[]{TableLayout.FILL},
                new double[]{TableLayout.FILL, 5, TableLayout.FILL});

        JPanel panel = new JPanel(layout);

        JButton upButton = new JButton(up);
        upButton.setFocusable(false);
        JButton downButton = new JButton(down);
        downButton.setFocusable(false);

        panel.add(upButton, "0,0");
        panel.add(downButton, "0,2");

        JPanel p = new JPanel(new FlowLayout());
        p.add(panel);
        return p;
    }
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:20,代码来源:AttributeOrderEditPanel.java

示例8: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:VariablesViewButtons.java

示例9: createSelectButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createSelectButton(final RepositoryLocationChooser chooser) {
    JButton selectButton = new JButton(new ResourceAction("getting_started.open", new Object[0]) {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            if(RapidMinerGUI.getMainFrame().close()) {
                try {
                    GettingStartedDialog.logStats("open_process_card", "open_from_location");
                    String e1 = chooser.getRepositoryLocation();
                    if(e1 != null) {
                        try {
                            RepositoryLocation e11 = new RepositoryLocation(e1);
                            Entry entry = e11.locateEntry();
                            if(entry instanceof ProcessEntry) {
                                OpenAction.open(new RepositoryProcessLocation(e11), true);
                                OpenProcessCard.this.owner.dispose();
                            } else if(entry instanceof IOObjectEntry) {
                                OpenAction.showAsResult((IOObjectEntry)entry);
                                OpenProcessCard.this.owner.dispose();
                            } else {
                                SwingTools.showVerySimpleErrorMessage("no_data_or_process", new Object[0]);
                            }
                        } catch (MalformedRepositoryLocationException | RepositoryException var5) {
                            SwingTools.showSimpleErrorMessage("while_loading", var5, new Object[]{e1, var5.getMessage()});
                        }
                    }
                } catch (MalformedRepositoryLocationException var6) {
                    SwingTools.showSimpleErrorMessage("while_loading", var6, new Object[]{"", var6.getMessage()});
                }

            }
        }
    });
    selectButton.setFocusable(false);
    this.styleButton(selectButton);
    return selectButton;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:38,代码来源:OpenProcessCard.java

示例10: SplashScreen

import javax.swing.JButton; //导入方法依赖的package包/类
public SplashScreen(Image image) {
	this.icon = new ImageIcon(image);

	Container container = getContentPane();
	container.setLayout(null);

	BufferedImage alphaImage = new BufferedImage(this.icon.getIconWidth(), this.icon.getIconHeight(), 2);
	Graphics2D g = alphaImage.createGraphics();
	g.drawImage(image, 0, 0, this.icon.getIconWidth(), this.icon.getIconHeight(), null);
	g.dispose();

	JButton background = new JButton(new ImageIcon(alphaImage));
	background.setBounds(0, 0, this.icon.getIconWidth(), this.icon.getIconHeight());
	background.setRolloverEnabled(true);
	background.setRolloverIcon(background.getIcon());
	background.setSelectedIcon(background.getIcon());
	background.setDisabledIcon(background.getIcon());
	background.setPressedIcon(background.getIcon());
	background.setFocusable(false);
	background.setContentAreaFilled(false);
	background.setBorderPainted(false);
	background.setOpaque(false);
	container.add(background);

	setSize(this.icon.getIconWidth(), this.icon.getIconHeight() + 20);
	try {
		setBackground(new Color(0, 0, 0, 0));
	} catch (UnsupportedOperationException e) {
		setBackground(new Color(0, 0, 0));
	}
	setLocationRelativeTo(null);
}
 
开发者ID:DivergenceBot,项目名称:Bootstrapper,代码行数:33,代码来源:SplashScreen.java

示例11: setEquipmentNames

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Sets the names of the equipment for which buttons should display.
 * @param equipmentNames the names of the equipment for which buttons should display.
 */
public void setEquipmentNames(List<String> equipmentNames) {
    removeAll();

    for (final String name : equipmentNames) {
        JButton button = new JButton(name) {
            @Override
            public void paint(Graphics g) {
                if (null == getIcon()) {
                    //Doing this here because it's expensive, so only
                    //do it when we actually need it.
                    setIcon(new ImageIcon(mil2525CSymbolController.getSymbolImage(name)));
                }
                super.paint(g);
            }
        };
        button.setFont(BUTTON_FONT);
        button.setHorizontalAlignment(SwingConstants.LEFT);
        button.setFocusable(false);
        button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
        button.setMinimumSize(new Dimension(0, 60));
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                for (ActionListener listener : listeners) {
                    listener.actionPerformed(e);
                }
            }
        });
        add(button);
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:36,代码来源:EquipmentListJPanel.java

示例12: addImpl

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected void addImpl( Component comp, Object constraints, int index ) {
    super.addImpl( comp, constraints, index ); 
    if( comp instanceof JButton ) {
        JButton btn = (JButton) comp;
        btn.setContentAreaFilled( false );
        btn.setOpaque( false );
        btn.setBorder( BorderFactory.createEmptyBorder(2,2,2,2) );
        btn.setFocusable( false );
        btn.setBorderPainted( false );
        btn.setRolloverEnabled( false );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ControlsToolbar.java

示例13: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
public static JButton createButton (Icon icon, String tooltip) {
    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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:VariablesViewButtons.java

示例14: createCloseButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CloseButtonFactory.java

示例15: loadInterface

import javax.swing.JButton; //导入方法依赖的package包/类
public static void loadInterface() {
	frame = new JFrame(WINDOW_TITLE);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	fileChooser = new JFileChooser();
	fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	fileChooser.setFileFilter(new PtaFileFilter());

	Container contentPane = frame.getContentPane();
	SpringLayout layout = new SpringLayout();
	contentPane.setLayout(layout);
	contentPane.setPreferredSize(new Dimension(240, 200));

	JPanel panel = new JPanel();
	SpringLayout panelLayout = new SpringLayout();
	panel.setLayout(panelLayout);
	panel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
	layout.putConstraint(SpringLayout.NORTH, panel, 5, SpringLayout.NORTH, contentPane);
	layout.putConstraint(SpringLayout.EAST, panel, -10, SpringLayout.EAST, contentPane);
	layout.putConstraint(SpringLayout.SOUTH, panel, -30, SpringLayout.SOUTH, contentPane);
	layout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, contentPane);
	contentPane.add(panel);

	titleLabel = new JLabel("Directory Details");
	titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, 14));
	panelLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, titleLabel, 0, SpringLayout.HORIZONTAL_CENTER, panel);
	panelLayout.putConstraint(SpringLayout.NORTH, titleLabel, 5, SpringLayout.NORTH, panel);
	panel.add(titleLabel);

	JLabel filePathLabel = new JLabel("Path");
	filePathLabel.setFont(new Font(filePathLabel.getFont().getName(), Font.BOLD, 13));
	panelLayout.putConstraint(SpringLayout.NORTH, filePathLabel, 2, SpringLayout.SOUTH, titleLabel);
	panelLayout.putConstraint(SpringLayout.WEST, filePathLabel, 10, SpringLayout.WEST, panel);
	panel.add(filePathLabel);

	pathLabel = new JLabel();
	pathLabel.setFont(new Font(pathLabel.getFont().getName(), Font.PLAIN, 11));
	panelLayout.putConstraint(SpringLayout.NORTH, pathLabel, 0, SpringLayout.SOUTH, filePathLabel);
	panelLayout.putConstraint(SpringLayout.WEST, pathLabel, 10, SpringLayout.WEST, panel);
	panelLayout.putConstraint(SpringLayout.EAST, pathLabel, 10, SpringLayout.EAST, panel);
	panel.add(pathLabel);

	actionButton = new JButton();
	actionButton.setFocusable(false);
	layout.putConstraint(SpringLayout.NORTH, actionButton, 5, SpringLayout.SOUTH, panel);
	layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, actionButton, 0, SpringLayout.HORIZONTAL_CENTER, contentPane);
	layout.putConstraint(SpringLayout.SOUTH, actionButton, -5, SpringLayout.SOUTH, contentPane);
	contentPane.add(actionButton);

	panel.setVisible(true);
	frame.pack();

	promptForFile();
}
 
开发者ID:Aelexe,项目名称:plain-text-archiver,代码行数:55,代码来源:UserInterface.java


注:本文中的javax.swing.JButton.setFocusable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。