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


Java JButton.setFont方法代码示例

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


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

示例1: 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,项目名称:Neukoelln_SER316,代码行数:21,代码来源:CharTablePanel.java

示例2: getContributeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public JButton getContributeButton() {
	JButton contributeB = new JButton();
	contributeB.setLayout(new BorderLayout());
	JLabel label1 = new JLabel("Contribute");
	JLabel label2 = new JLabel("Data");
	label1.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.add(BorderLayout.CENTER,label1);
	label2.setFont(new Font("Arial", Font.BOLD, 11));
	label2.setHorizontalAlignment(SwingConstants.CENTER);
	contributeB.add(BorderLayout.SOUTH,label2);
	contributeB.setSize(new Dimension(115, 30));
	contributeB.setMargin(new Insets(0, 0, 0, 0));
	contributeB.setBackground(new Color( 224, 224, 224)); ;
	contributeB.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.setHorizontalAlignment(SwingConstants.LEFT);
	
	return contributeB;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:MapTools.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: stylizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * JComponent styling wrappers
 */
public void stylizeButton(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_14_bold);
	b.setForeground(Color.WHITE);
	b.setBackground(new Color(102, 0, 153)); // Purple
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:10,代码来源:TrainControllerGUI.java

示例5: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates button with given text.
 * 
 * @param text
 *            Button text.
 * @return Instance of {@link JButton}.
 */
private JButton createButton(String text) {
    JButton button = new JButton(text);
    button.setMinimumSize(new Dimension(40, 40));
    button.setPreferredSize(new Dimension(75, 60));
    button.setFont(new Font(button.getFont().toString(), Font.BOLD, 15));
    buttonMap.put(text, button);
    return button;
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:16,代码来源:Calculator.java

示例6: 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

示例7: unitButtons

import javax.swing.JButton; //导入方法依赖的package包/类
private List<JButton> unitButtons(final Map<UnitType, Suggestion> suggestions,
                                  List<UnitType> have, Colony colony) {
    final String cac = colony.getId();
    List<JButton> result = new ArrayList<>();
    final Comparator<UnitType> buttonComparator
        = Comparator.comparing(ut -> suggestions.get(ut),
                               Suggestion.descendingAmountComparator);
    for (UnitType type : sort(suggestions.keySet(), buttonComparator)) {
        boolean present = have.contains(type);
        Suggestion suggestion = suggestions.get(type);
        String label = Integer.toString(suggestion.amount);
        ImageIcon icon
            = new ImageIcon(this.lib.getTinyUnitImage(type, false));
        StringTemplate tip = (suggestion.oldType == null)
            ? stpld("report.colony.wanting")
                .addName("%colony%", colony.getName())
                .addNamed("%unit%", type)
                .addStringTemplate("%location%",
                    suggestion.workLocation.getLabel())
                .addNamed("%goods%", suggestion.goodsType)
                .addAmount("%amount%", suggestion.amount)
            : stpld("report.colony.improving")
                .addName("%colony%", colony.getName())
                .addNamed("%oldUnit%", suggestion.oldType)
                .addNamed("%unit%", type)
                .addStringTemplate("%location%",
                    suggestion.workLocation.getLabel())
                .addNamed("%goods%", suggestion.goodsType)
                .addAmount("%amount%", suggestion.amount);
        JButton b = newButton(cac, label, icon,
                              (present) ? cGood : cPlain, tip);
        if (present) b.setFont(b.getFont().deriveFont(Font.BOLD));
        result.add(b);
    }
    return result;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:37,代码来源:ReportCompactColonyPanel.java

示例8: createDialog

import javax.swing.JButton; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent)
{
    Frame frame = parent instanceof Frame ? (Frame) parent
        : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, Editor.fromConfiguracao.getValor("Inspector.obj.font.selfonte"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:38,代码来源:JFontChooser.java

示例9: StartPagePanel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the panel.
 */
public StartPagePanel() {
	setLayout(null);
	
	btnNewButton = new JButton("Play");
	btnNewButton.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	btnNewButton.setBounds(141, 84, 149, 52);
	add(btnNewButton);
	
	btnMakeDeck = new JButton("Make Deck");
	btnMakeDeck.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	btnMakeDeck.setBounds(141, 144, 149, 52);
	add(btnMakeDeck);
	
	btnOpenPack = new JButton("Open Pack");
	btnOpenPack.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	btnOpenPack.setEnabled(false);
	btnOpenPack.setBounds(141, 208, 149, 52);
	add(btnOpenPack);
	
	JLabel lblHearthstone = new JLabel("Hearthstone");
	lblHearthstone.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
	lblHearthstone.setBounds(131, 32, 178, 36);
	add(lblHearthstone);
	
	lblWelcome = new JLabel("Welcome, ");
	lblWelcome.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	lblWelcome.setBounds(391, 100, 224, 25);
	add(lblWelcome);
	
	lblYouAreRank = new JLabel("You are rank ");
	lblYouAreRank.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	lblYouAreRank.setBounds(391, 142, 265, 25);
	add(lblYouAreRank);
	
	JLabel lblYouHave = new JLabel("You have ");
	lblYouHave.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	lblYouHave.setBounds(391, 173, 224, 25);
	add(lblYouHave);
	
	JTextArea txtrAllPropertiesBelong = new JTextArea();
	txtrAllPropertiesBelong.setText("All properties belong to their respective owners.\nDeveloped by Imran Khaliq.");
	txtrAllPropertiesBelong.setBounds(391, 262, 303, 32);
	txtrAllPropertiesBelong.setBackground(this.getBackground());
	add(txtrAllPropertiesBelong);
	
	btnLogout = new JButton("Logout");
	btnLogout.setBounds(6, 265, 117, 29);
	add(btnLogout);
	
	btnCollection = new JButton("Collection");
	btnCollection.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
	btnCollection.setBounds(466, 208, 149, 52);
	add(btnCollection);

}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:59,代码来源:StartPagePanel.java

示例10: styleButton

import javax.swing.JButton; //导入方法依赖的package包/类
private void styleButton(JButton button) {
    button.setFont(GettingStartedDialog.OPEN_SANS_SEMIBOLD_14);
    button.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:5,代码来源:OpenProcessCard.java

示例11: Login

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame to login
 */
public Login() {

	this.setTitle("Client IRC");
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	this.setResizable(false);
	this.setBounds(100, 100, 460, 261);
	this.setLocationRelativeTo(null);
	setIconImage(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/swag.png")));
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	contentPane.setLayout(null);
	this.setContentPane(contentPane);
	
	JButton btnLogin = new JButton("Login");
	Icon imgOk = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/ok.png")));
	btnLogin.setIcon(imgOk);
	btnLogin.setFont(new Font("Tahoma", Font.BOLD, 14));
	btnLogin.addActionListener(new ValidateConnectionListener());
	btnLogin.setBounds(217, 154, 139, 30);
	contentPane.add(btnLogin);
	
	JLabel lblNickname = new JLabel("Nickname");
	lblNickname.setHorizontalAlignment(SwingConstants.LEFT);
	lblNickname.setFont(new Font("Tahoma", Font.BOLD, 14));
	lblNickname.setBounds(179, 37, 86, 30);
	contentPane.add(lblNickname);
	
	JLabel lblIpServer = new JLabel("IP Server");		
	lblIpServer.setFont(new Font("Tahoma", Font.BOLD, 14));
	lblIpServer.setBounds(179, 95, 86, 30);
	contentPane.add(lblIpServer);
	
	textFieldNickname = new JTextField();
	textFieldNickname.setFont(new Font("Tahoma", Font.PLAIN, 14));
	textFieldNickname.setBounds(286, 38, 145, 30);
	contentPane.add(textFieldNickname);
	textFieldNickname.setColumns(10);
	
	textFieldServer = new JTextField();
	textFieldServer.setFont(new Font("Tahoma", Font.PLAIN, 14));
	textFieldServer.setBounds(286, 96, 145, 30);
	contentPane.add(textFieldServer);
	textFieldServer.setColumns(10);
	
	JLabel lblImage = new JLabel("");
	lblImage.setBounds(23, 11, 146, 173);
	Icon imgLogin = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/login-msn.png")));
	lblImage.setIcon(imgLogin);
	contentPane.add(lblImage);
	
	this.addWindowListener( new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			closeFrame();
		}
	});
}
 
开发者ID:LittleSnake42,项目名称:java-irc,代码行数:60,代码来源:Login.java

示例12: makeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Makes a {@code JButton} for a given arrow direction.
 * By default, the direction and arrow parameters should
 * be the same literal direction, just formatted for a
 * unique context.
 *
 * @param direction The Direction on the {@code Map} to move
 * @param arrow The Direction of the arrow itself
 * @return A JButton with the correct display and action
 *
 * @since 0.10.6
 */
private JButton makeButton(String direction, String arrow) {
    JButton button
        = new JButton(am.getFreeColAction("moveAction." + direction));
    button.setFont(arrowFont);
    button.setText(arrow);
    return button;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:20,代码来源:ClassicMapControls.java

示例13: addPaintButton

import javax.swing.JButton; //导入方法依赖的package包/类
private void addPaintButton() {
    /* paint button */
    paint = new JButton("paint");
    paint.setBounds(760, 10, 80, 30);
    paint.setFont(buttonFont);
    paint.setMargin(DEFAULT_INSETS);

    /* image */
    imageLabel = new JLabel();
    imageLabel.setBounds(0, 0, 520, 680);

    paint.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            isPainted = false;
        }
    });
}
 
开发者ID:xehoth,项目名称:VisualGraphviz,代码行数:20,代码来源:MainFrame.java


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