javax.swing.JButton.setFont()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中javax.swing.JButton.setFont()方法的一些代码示例,展示了JButton.setFont()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setFont()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setFont

JButton.setFont介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. JButton b = new JButton("Hello World");
  2. b.setFont(myFont);

代码示例来源:origin: deathmarine/Luyten

  1. protected JDialog createDialog(Component parent) {
  2. Frame frame = parent instanceof Frame ? (Frame) parent
  3. : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
  4. JDialog dialog = new JDialog(frame, ("Select Font"), true);
  5. Action okAction = new DialogOKAction(dialog);
  6. Action cancelAction = new DialogCancelAction(dialog);
  7. JButton okButton = new JButton(okAction);
  8. okButton.setFont(DEFAULT_FONT);
  9. JButton cancelButton = new JButton(cancelAction);
  10. cancelButton.setFont(DEFAULT_FONT);
  11. JPanel buttonsPanel = new JPanel();
  12. buttonsPanel.setLayout(new GridLayout(2, 1));
  13. buttonsPanel.add(okButton);
  14. buttonsPanel.add(cancelButton);
  15. buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
  16. ActionMap actionMap = buttonsPanel.getActionMap();
  17. actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
  18. actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
  19. InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  20. inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
  21. inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
  22. JPanel dialogEastPanel = new JPanel();
  23. dialogEastPanel.setLayout(new BorderLayout());
  24. dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
  25. dialog.getContentPane().add(this, BorderLayout.CENTER);
  26. dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
  27. dialog.pack();
  28. dialog.setLocationRelativeTo(frame);
  29. return dialog;
  30. }

代码示例来源:origin: libgdx/libgdx

  1. upButton.setMargin(new Insets(0, 0, 0, 0));
  2. Font font = upButton.getFont();
  3. upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  4. downButton.setMargin(new Insets(0, 0, 0, 0));
  5. Font font = downButton.getFont();
  6. downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  7. deleteButton.setMargin(new Insets(0, 0, 0, 0));
  8. Font font = deleteButton.getFont();
  9. deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));

代码示例来源:origin: libgdx/libgdx

  1. upButton.setMargin(new Insets(0, 0, 0, 0));
  2. Font font = upButton.getFont();
  3. upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  4. downButton.setMargin(new Insets(0, 0, 0, 0));
  5. Font font = downButton.getFont();
  6. downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  7. deleteButton.setMargin(new Insets(0, 0, 0, 0));
  8. Font font = deleteButton.getFont();
  9. deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));

代码示例来源:origin: wildfly/wildfly

  1. public void go() throws Exception {
  2. if(!no_channel && !use_state)
  3. channel.connect(cluster_name);
  4. mainFrame=new JFrame();
  5. mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  6. panel=new DrawPanel(use_state);
  7. panel.setBackground(background_color);
  8. sub_panel=new JPanel();
  9. mainFrame.getContentPane().add("Center", panel);
  10. clear_button=new JButton("Clear");
  11. clear_button.setFont(default_font);
  12. clear_button.addActionListener(this);
  13. leave_button=new JButton("Leave");
  14. leave_button.setFont(default_font);
  15. leave_button.addActionListener(this);
  16. sub_panel.add("South", clear_button);
  17. sub_panel.add("South", leave_button);
  18. mainFrame.getContentPane().add("South", sub_panel);
  19. mainFrame.setBackground(background_color);
  20. clear_button.setForeground(Color.blue);
  21. leave_button.setForeground(Color.blue);
  22. mainFrame.pack();
  23. mainFrame.setLocation(15, 25);
  24. mainFrame.setBounds(new Rectangle(250, 250));
  25. if(!no_channel && use_state) {
  26. channel.connect(cluster_name, null, state_timeout);
  27. }
  28. mainFrame.setVisible(true);
  29. setTitle();
  30. }

代码示例来源:origin: wildfly/wildfly

  1. mainFrame.getContentPane().add("Center", panel);
  2. clear_button=new JButton("Clear");
  3. clear_button.setFont(default_font);
  4. clear_button.addActionListener(this);
  5. leave_button=new JButton("Leave");
  6. leave_button.setFont(default_font);
  7. leave_button.addActionListener(this);
  8. sub_panel.add("South", clear_button);

代码示例来源:origin: RipMeApp/ripme

  1. optionQueue = new JButton(rb.getString("Queue"));
  2. optionConfiguration = new JButton(rb.getString("Configuration"));
  3. optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  4. optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  5. optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  6. optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  7. try {
  8. Image icon;

代码示例来源:origin: RipMeApp/ripme

  1. configurationPanel.setVisible(false);
  2. if (logPanel.isVisible()) {
  3. optionLog.setFont(optionLog.getFont().deriveFont(Font.BOLD));
  4. } else {
  5. optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  6. optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  7. optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  8. optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  9. pack();
  10. });
  11. queuePanel.setVisible(false);
  12. configurationPanel.setVisible(false);
  13. optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  14. if (historyPanel.isVisible()) {
  15. optionHistory.setFont(optionLog.getFont().deriveFont(Font.BOLD));
  16. } else {
  17. optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  18. optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  19. optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  20. pack();
  21. });
  22. emptyPanel.setVisible(!queuePanel.isVisible());
  23. configurationPanel.setVisible(false);
  24. optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
  25. optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));

代码示例来源:origin: runelite/runelite

  1. clearButton.setFont(FontManager.getRunescapeBoldFont());
  2. clearButton.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
  3. clearButton.setBorder(null);

代码示例来源:origin: magefree/mage

  1. private void setGUISize() {
  2. renderButton.setFont(GUISizeHelper.tableFont);
  3. editButton.setFont(GUISizeHelper.tableFont);
  4. }

代码示例来源:origin: stackoverflow.com

  1. JButton b = new JButton();
  2. b.setFont(b.getFont().deriveFont(18.0f));

代码示例来源:origin: magefree/mage

  1. private void setGUISize() {
  2. Font font = GUISizeHelper.gameRequestsFont;
  3. lblText.setFont(font);
  4. lblText.setMaximumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
  5. lblText.setMinimumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
  6. lblText.setPreferredSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
  7. btn1.setFont(font);
  8. btn1.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  9. btn1.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  10. btn1.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  11. btn2.setFont(font);
  12. btn2.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  13. btn2.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  14. btn2.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  15. btn3.setFont(font);
  16. btn3.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  17. btn3.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  18. btn3.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
  19. JComponent c = ((BasicInternalFrameUI) this.getUI()).getNorthPane();
  20. c.setMinimumSize(new Dimension(c.getMinimumSize().width, font.getSize() + 10));
  21. c.setMaximumSize(new Dimension(c.getMaximumSize().width, font.getSize() + 10));
  22. c.setPreferredSize(new Dimension(c.getPreferredSize().width, font.getSize() + 10));
  23. c.setFont(font);
  24. }

代码示例来源:origin: magefree/mage

  1. btnLeft.setFont(GUISizeHelper.gameDialogAreaFont);
  2. btnRight.setFont(GUISizeHelper.gameDialogAreaFont);
  3. btnSpecial.setFont(GUISizeHelper.gameDialogAreaFont);
  4. btnUndo.setFont(GUISizeHelper.gameDialogAreaFont);

代码示例来源:origin: nodebox/nodebox

  1. public DataControl(String nodePath, Port port) {
  2. super(nodePath, port);
  3. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  4. clearDataButton = new JButton("Clear");
  5. clearDataButton.setMargin(new Insets(1, 0, 0, 0));
  6. clearDataButton.putClientProperty("JButton.buttonType", "textured");
  7. clearDataButton.putClientProperty("JComponent.sizeVariant", "small");
  8. clearDataButton.setFont(Theme.SMALL_BOLD_FONT);
  9. clearDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  10. clearDataButton.addActionListener(this);
  11. add(clearDataButton);
  12. /*showDataButton = new JButton("Show Data...");
  13. showDataButton.setMargin(new Insets(1, 0, 0, 0));
  14. showDataButton.putClientProperty("JButton.buttonType", "textured");
  15. showDataButton.putClientProperty("JComponent.sizeVariant", "small");
  16. showDataButton.setFont(Theme.SMALL_BOLD_FONT);
  17. showDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  18. showDataButton.addActionListener(this);
  19. add(showDataButton);*/
  20. add(Box.createHorizontalGlue());
  21. }

代码示例来源:origin: magefree/mage

  1. jPanelBottom.setMinimumSize(newDimension);
  2. jPanelBottom.setPreferredSize(newDimension);
  3. jButtonFooterNext.setFont(GUISizeHelper.menuFont);
  4. jLabelFooterLabel.setFont(new Font(GUISizeHelper.menuFont.getName(), Font.BOLD, GUISizeHelper.menuFont.getSize()));
  5. jLabelFooterText.setFont(GUISizeHelper.menuFont);

代码示例来源:origin: nodebox/nodebox

  1. public TextControl(String nodePath, Port port) {
  2. super(nodePath, port);
  3. setLayout(new BorderLayout(0, 0));
  4. textField = new JTextField();
  5. textField.putClientProperty("JComponent.sizeVariant", "small");
  6. textField.setFont(Theme.SMALL_BOLD_FONT);
  7. textField.addActionListener(this);
  8. externalWindowButton = new JButton("...");
  9. externalWindowButton.putClientProperty("JComponent.sizeVariant", "small");
  10. externalWindowButton.putClientProperty("JButton.buttonType", "gradient");
  11. externalWindowButton.setFont(Theme.SMALL_BOLD_FONT);
  12. externalWindowButton.addActionListener(this);
  13. add(textField, BorderLayout.CENTER);
  14. add(externalWindowButton, BorderLayout.EAST);
  15. setValueForControl(port.getValue());
  16. }

代码示例来源:origin: geotools/geotools

  1. btn.setFont(JMapStatusBar.DEFAULT_FONT);
  2. btn.setToolTipText(TOOL_TIP);
  3. add(btn);

代码示例来源:origin: magefree/mage

  1. btnConnect.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
  2. btnConnect.setText("Connect to server");
  3. btnConnect.setMargin(new java.awt.Insets(2, 2, 2, 2));

代码示例来源:origin: freeplane/freeplane

  1. private void initializeMoveColorUpButton() {
  2. moveColorUp.setName("moveColorUp");
  3. moveColorUp.setFont(BUTTON_FONT);
  4. moveColorUp.setText(MOVE_UP);
  5. moveColorUp.addActionListener(new ColorSwapper(-1));
  6. moveColorUp.setVisible(index > 0);
  7. }

代码示例来源:origin: freeplane/freeplane

  1. private void initializeMoveColorDownButton() {
  2. moveColorDown.setName("moveColorDown");
  3. moveColorDown.setFont(BUTTON_FONT);
  4. moveColorDown.setText(MOVE_DOWN);
  5. moveColorDown.addActionListener(new ColorSwapper(+1));
  6. updateMoveColorDownButton();
  7. }

相关文章

JButton类方法