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

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

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

JCheckBox.setFont介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

  1. @Override
  2. public Component getComponent(
  3. final JTree tree, Object nodeRenderer, final boolean isSelected, boolean isLeaf, boolean hasFocus
  4. ) {
  5. JCheckBox checkbox = new JCheckBox(this.toString(), this.isSelected());
  6. checkbox.setFont(
  7. checkbox.getFont().deriveFont(
  8. Font.PLAIN | Font.ITALIC,
  9. checkbox.getFont().getSize()
  10. )
  11. );
  12. checkbox.setText(StringUtil.detectUtf8HtmlNoWrap(this.toString()));
  13. if (isSelected) {
  14. if (hasFocus) {
  15. checkbox.setBackground(HelperUi.COLOR_FOCUS_GAINED);
  16. checkbox.setBorder(HelperUi.BORDER_FOCUS_GAINED);
  17. } else {
  18. checkbox.setBackground(HelperUi.COLOR_FOCUS_LOST);
  19. checkbox.setBorder(HelperUi.BORDER_FOCUS_LOST);
  20. }
  21. } else {
  22. checkbox.setBackground(Color.WHITE);
  23. checkbox.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
  24. }
  25. checkbox.setComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
  26. return checkbox;
  27. }

代码示例来源:origin: com.jidesoft/jide-oss

  1. @Override
  2. public void setFont(Font font) {
  3. if (font instanceof FontUIResource) {
  4. return;
  5. }
  6. super.setFont(font);
  7. }

代码示例来源:origin: baishui2004/common_gui_tools

  1. /**
  2. * 获取指定标题、是否selected、字体及ActionListener的JCheckbox.
  3. */
  4. public JCheckBox createJCheckBox(String title, boolean isSelected, Font font, ActionListener listener) {
  5. JCheckBox checkBox = new JCheckBox(title);
  6. checkBox.setFont(font);
  7. checkBox.setSelected(isSelected);
  8. checkBox.addActionListener(listener);
  9. return checkBox;
  10. }

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

  1. @Override
  2. public void setFont(Font font) {
  3. super.setFont(font);
  4. getIconLabel().setFont(font);
  5. }

代码示例来源:origin: org.codehaus.mevenide/nb-project

  1. private void setCheckBoxValue(Boolean value, boolean defValue, JCheckBox component) {
  2. if (value != null) {
  3. component.setSelected(value.booleanValue());
  4. component.setToolTipText(""); //NOI18N
  5. inherited = false;
  6. component.setFont(component.getFont().deriveFont(Font.BOLD));
  7. } else {
  8. component.setSelected(defValue);
  9. component.setToolTipText(NbBundle.getMessage(CheckBoxUpdater.class, "MSG_Value_Inherited")); //NOI18N
  10. inherited = true;
  11. component.setFont(component.getFont().deriveFont(Font.PLAIN));
  12. }
  13. }

代码示例来源:origin: sing-group/GC4S

  1. /**
  2. * Returns an {@code Object} to pass to the {@code JOptionPane} methods.
  3. * @return an {@code Object} to pass to the {@code JOptionPane} methods.
  4. */
  5. public Object getMessage() {
  6. if (this.component == null) {
  7. this.component = new JPanel(new BorderLayout());
  8. JLabel label = new JLabel(this.message);
  9. Font font = label.getFont().deriveFont(Font.PLAIN);
  10. label.setFont(font);
  11. this.showMessageCB.setFont(font);
  12. this.showMessageCB.setHorizontalAlignment(JCheckBox.RIGHT);
  13. this.component.add(label, BorderLayout.CENTER);
  14. this.component.add(showMessageCB, BorderLayout.SOUTH);
  15. }
  16. return this.component;
  17. }

代码示例来源:origin: GoldenGnu/jeveassets

  1. public CheckBoxNodeRenderer() {
  2. Font fontValue;
  3. fontValue = UIManager.getFont("Tree.font");
  4. if (fontValue != null) {
  5. leafRenderer.setFont(fontValue);
  6. }
  7. Boolean booleanValue = (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
  8. leafRenderer.setFocusPainted(booleanValue != null && booleanValue);
  9. selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
  10. selectionForeground = UIManager.getColor("Tree.selectionForeground");
  11. selectionBackground = UIManager.getColor("Tree.selectionBackground");
  12. textForeground = UIManager.getColor("Tree.textForeground");
  13. textBackground = UIManager.getColor("Tree.textBackground");
  14. }

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

  1. public class ErrorMessagePane {
  2. private JLabel message;
  3. private JCheckBox checkBox;
  4. private JPanel panel;
  5. public ErrorMessagePane(Container parent, String errorMessage) {
  6. panel = new JPanel (new MigLayout(""));
  7. message = new JLabel (errorMessage);
  8. message.setFont(ApplicationStyles.STANDARD_FONT);
  9. panel.add(message);
  10. checkBox = new JCheckBox("Don't Show This Message Again");
  11. checkBox.setFont(ApplicationStyles.STANDARD_FONT);
  12. panel.add(checkBox);
  13. JOptionPane.showMessageDialog(parent, panel, "Error",
  14. JOptionPane.ERROR_MESSAGE);
  15. }
  16. public boolean isCheckBoxSelected () {
  17. return checkBox.isSelected();
  18. }
  19. }

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

  1. final JCheckBox DocumentCheckBox = new JCheckBox("Document");
  2. final JCheckBox FilecheckBox = new JCheckBox("File");
  3. ProduceDataDropDown.disable();
  4. DocumentCheckBox.addActionListener(new ActionListener() {
  5. public void actionPerformed(ActionEvent arg0) {
  6. FilecheckBox.setSelected(false);
  7. }
  8. });
  9. DocumentCheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 14));
  10. DocumentCheckBox.setBounds(184, 131, 123, 23);
  11. contentPane.add(DocumentCheckBox);
  12. FilecheckBox.addActionListener(new ActionListener() {
  13. public void actionPerformed(ActionEvent e) {
  14. DocumentCheckBox.setSelected(false);
  15. }
  16. });
  17. FilecheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 14));
  18. FilecheckBox.setBounds(184, 157, 123, 23);
  19. contentPane.add(FilecheckBox);

代码示例来源:origin: com.jalalkiswani/jk-desktop

  1. /**
  2. * Instantiates a new tree check box node renderer.
  3. */
  4. // ///////////////////////////////////////////////////////////////////////////////////////
  5. public TreeCheckBoxNodeRenderer() {
  6. Font fontValue;
  7. fontValue = UIManager.getFont("Tree.font");
  8. if (fontValue != null) {
  9. this.leafRenderer.setFont(fontValue);
  10. }
  11. final Boolean booleanValue = (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
  12. this.leafRenderer.setFocusPainted(booleanValue != null && booleanValue.booleanValue());
  13. this.selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
  14. this.selectionForeground = UIManager.getColor("Tree.selectionForeground");
  15. this.selectionBackground = UIManager.getColor("Tree.selectionBackground");
  16. this.textForeground = UIManager.getColor("Tree.textForeground");
  17. this.textBackground = UIManager.getColor("Tree.textBackground");
  18. }

代码示例来源:origin: org.codehaus.mevenide/nb-project

  1. private void setModelValue() {
  2. if (inherited) {
  3. inherited = false;
  4. component.setFont(component.getFont().deriveFont(Font.BOLD));
  5. component.setToolTipText(""); //NOI18N
  6. }
  7. boolean val = component.isSelected();
  8. setValue(val == getDefaultValue() ? null : val);
  9. }

代码示例来源:origin: igniterealtime/Spark

  1. @SuppressWarnings({ "unchecked", "rawtypes" })
  2. public void updateTitleFont() {
  3. if (task.isCompleted()) {
  4. Font font = box.getFont();
  5. Map attribs = font.getAttributes();
  6. attribs.put(TextAttribute.STRIKETHROUGH, true);
  7. box.setFont(new Font(attribs));
  8. box.setSelected(true);
  9. }
  10. else {
  11. Font font = box.getFont();
  12. Map Attribs = font.getAttributes();
  13. Attribs.put(TextAttribute.STRIKETHROUGH, false);
  14. box.setFont(new Font(Attribs));
  15. box.setSelected(false);
  16. }
  17. }

代码示例来源:origin: com.jidesoft/jide-oss

  1. private void clearAttribute() {
  2. super.setFont(null);
  3. super.setBackground(null);
  4. super.setForeground(null);
  5. }

代码示例来源:origin: MegaMek/mekhq

  1. private JCheckBox createOptionCheckBox(String text, Icon checkboxIcon, Icon checkboxSelectedIcon) {
  2. JCheckBox checkBox = new JCheckBox(text);
  3. checkBox.setOpaque(false);
  4. checkBox.setForeground(new Color(150, 220, 255));
  5. checkBox.setFocusable(false);
  6. checkBox.setFont(checkBox.getFont().deriveFont(Font.BOLD));
  7. checkBox.setPreferredSize(new Dimension(150, 20));
  8. checkBox.setIcon(checkboxIcon);
  9. checkBox.setSelectedIcon(checkboxSelectedIcon);
  10. checkBox.setSelected(false);
  11. checkBox.addActionListener(new ActionListener() {
  12. @Override
  13. public void actionPerformed(ActionEvent e) {
  14. repaint();
  15. }
  16. });
  17. return checkBox;
  18. }

代码示例来源:origin: abc9070410/JComicDownloader

  1. private JCheckBox getCheckBox( String string, String enString, boolean selected )
  2. {
  3. string = Common.getStringUsingDefaultLanguage( string, enString ); // 使用預設語言
  4. JCheckBox checkBox = new JCheckBox( string, selected );
  5. checkBox.setFont( SetUp.getDefaultFont() );
  6. if ( SetUp.getUsingBackgroundPicOfOptionFrame() )
  7. { // 若設定為透明,就用預定字體。
  8. checkBox.setForeground( SetUp.getOptionFrameOtherDefaultColor() );
  9. checkBox.setOpaque( false );
  10. }
  11. checkBox.addItemListener( new ItemHandler() );
  12. return checkBox;
  13. }

代码示例来源:origin: abc9070410/JComicDownloader

  1. private JCheckBox getCheckBoxBold( String string, String enString, boolean selected )
  2. {
  3. string = Common.getStringUsingDefaultLanguage( string, enString ); // 使用預設語言
  4. JCheckBox checkBox = new JCheckBox( string, selected );
  5. checkBox.setFont( SetUp.getDefaultBoldFont() );
  6. if ( SetUp.getUsingBackgroundPicOfOptionFrame() )
  7. { // 若設定為透明,就用預定字體。
  8. checkBox.setForeground( SetUp.getOptionFrameOtherDefaultColor() );
  9. checkBox.setOpaque( false );
  10. }
  11. checkBox.addItemListener( new ItemHandler() );
  12. return checkBox;
  13. }

代码示例来源:origin: org.biojava.thirdparty/forester

  1. void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
  2. jcb.setFocusPainted( false );
  3. jcb.setFont( ControlPanel.jcb_font );
  4. if ( !_configuration.isUseNativeUI() ) {
  5. jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
  6. jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
  7. }
  8. p.add( jcb, "Center" );
  9. jcb.addActionListener( this );
  10. }

代码示例来源:origin: atarw/material-ui-swing

  1. @Override
  2. public void installUI (JComponent c) {
  3. super.installUI (c);
  4. JCheckBox checkBox = (JCheckBox) c;
  5. checkBox.setFont (UIManager.getFont ("CheckBox.font"));
  6. checkBox.setBackground (UIManager.getColor ("CheckBox.background"));
  7. checkBox.setForeground (UIManager.getColor ("CheckBox.foreground"));
  8. checkBox.setIcon (UIManager.getIcon ("CheckBox.icon"));
  9. checkBox.setSelectedIcon (UIManager.getIcon ("CheckBox.selectedIcon"));
  10. }

代码示例来源:origin: locationtech/jts

  1. public Component getListCellRendererComponent(JList list, Object value,
  2. int index, boolean isSelected, boolean cellHasFocus) {
  3. Layer lyr = (Layer) value;
  4. checkbox.setBackground(isSelected ? getSelectionBackground()
  5. : getBackground());
  6. checkbox.setForeground(isSelected ? getSelectionForeground()
  7. : getForeground());
  8. checkbox.setSelected(lyr.isEnabled());
  9. checkbox.setEnabled(isEnabled());
  10. checkbox.setFont(getFont());
  11. checkbox.setFocusPainted(false);
  12. checkbox.setBorderPainted(true);
  13. checkbox.setBorder(isSelected ? UIManager
  14. .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
  15. checkbox.setText(lyr.getNameInfo());
  16. return checkbox;
  17. }
  18. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  2. JCheckBox checkbox = (JCheckBox) value;
  3. checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
  4. checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
  5. checkbox.setEnabled(isEnabled());
  6. checkbox.setFont(getFont());
  7. checkbox.setFocusPainted(false);
  8. checkbox.setBorderPainted(false);
  9. return checkbox;
  10. }
  11. }

相关文章

JCheckBox类方法