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

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

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

JCheckBox.setFont介绍

暂无

代码示例

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

@Override
public Component getComponent(
  final JTree tree, Object nodeRenderer, final boolean isSelected, boolean isLeaf, boolean hasFocus
) {
  JCheckBox checkbox = new JCheckBox(this.toString(), this.isSelected());
  checkbox.setFont(
    checkbox.getFont().deriveFont(
      Font.PLAIN | Font.ITALIC,
      checkbox.getFont().getSize()
    )
  );
  
  checkbox.setText(StringUtil.detectUtf8HtmlNoWrap(this.toString()));
  
  if (isSelected) {
    if (hasFocus) {
      checkbox.setBackground(HelperUi.COLOR_FOCUS_GAINED);
      checkbox.setBorder(HelperUi.BORDER_FOCUS_GAINED);
    } else {
      checkbox.setBackground(HelperUi.COLOR_FOCUS_LOST);
      checkbox.setBorder(HelperUi.BORDER_FOCUS_LOST);
    }
  } else {
    checkbox.setBackground(Color.WHITE);
    checkbox.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
  }
  
  checkbox.setComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
  return checkbox;
}

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

@Override
public void setFont(Font font) {
  if (font instanceof FontUIResource) {
    return;
  }
  super.setFont(font);
}

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

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

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

@Override
public void setFont(Font font) {
  super.setFont(font);
  getIconLabel().setFont(font);
}

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

private void setCheckBoxValue(Boolean value, boolean defValue, JCheckBox component) {
  if (value != null) {
    component.setSelected(value.booleanValue());
    component.setToolTipText(""); //NOI18N
    inherited = false;
    component.setFont(component.getFont().deriveFont(Font.BOLD));
  } else {
    component.setSelected(defValue);
    component.setToolTipText(NbBundle.getMessage(CheckBoxUpdater.class, "MSG_Value_Inherited")); //NOI18N
    inherited = true;
    component.setFont(component.getFont().deriveFont(Font.PLAIN));
 }
}

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

/**
 * Returns an {@code Object} to pass to the {@code JOptionPane} methods.
 * @return an {@code Object} to pass to the {@code JOptionPane} methods.
 */
public Object getMessage() {
  if (this.component == null) {
    this.component = new JPanel(new BorderLayout());
    
    JLabel label = new JLabel(this.message);
    Font font = label.getFont().deriveFont(Font.PLAIN);
    label.setFont(font);
    this.showMessageCB.setFont(font);
    this.showMessageCB.setHorizontalAlignment(JCheckBox.RIGHT);
    
    this.component.add(label, BorderLayout.CENTER);
    this.component.add(showMessageCB, BorderLayout.SOUTH);
  }
  return this.component;
}

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

public CheckBoxNodeRenderer() {
  Font fontValue;
  fontValue = UIManager.getFont("Tree.font");
  if (fontValue != null) {
    leafRenderer.setFont(fontValue);
  }
  Boolean booleanValue = (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
  leafRenderer.setFocusPainted(booleanValue != null && booleanValue);
  selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
  selectionForeground = UIManager.getColor("Tree.selectionForeground");
  selectionBackground = UIManager.getColor("Tree.selectionBackground");
  textForeground = UIManager.getColor("Tree.textForeground");
  textBackground = UIManager.getColor("Tree.textBackground");
}

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

public class ErrorMessagePane {

 private JLabel message;

 private JCheckBox checkBox;

 private JPanel panel;

 public ErrorMessagePane(Container parent, String errorMessage) {

  panel = new JPanel (new MigLayout(""));

  message = new JLabel (errorMessage);
  message.setFont(ApplicationStyles.STANDARD_FONT);
  panel.add(message);

  checkBox = new JCheckBox("Don't Show This Message Again");
  checkBox.setFont(ApplicationStyles.STANDARD_FONT);
  panel.add(checkBox);

  JOptionPane.showMessageDialog(parent, panel, "Error",
      JOptionPane.ERROR_MESSAGE);
 }

 public boolean isCheckBoxSelected () {
  return checkBox.isSelected();
 }
}

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

final JCheckBox DocumentCheckBox = new JCheckBox("Document");
final JCheckBox FilecheckBox = new JCheckBox("File");
ProduceDataDropDown.disable();
DocumentCheckBox.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent arg0) {

    FilecheckBox.setSelected(false);
  }
});     
DocumentCheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 14));
DocumentCheckBox.setBounds(184, 131, 123, 23);
contentPane.add(DocumentCheckBox);

FilecheckBox.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

    DocumentCheckBox.setSelected(false);
  }
});
FilecheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 14));
FilecheckBox.setBounds(184, 157, 123, 23);
contentPane.add(FilecheckBox);

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

/**
 * Instantiates a new tree check box node renderer.
 */
// ///////////////////////////////////////////////////////////////////////////////////////
public TreeCheckBoxNodeRenderer() {
  Font fontValue;
  fontValue = UIManager.getFont("Tree.font");
  if (fontValue != null) {
    this.leafRenderer.setFont(fontValue);
  }
  final Boolean booleanValue = (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
  this.leafRenderer.setFocusPainted(booleanValue != null && booleanValue.booleanValue());
  this.selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
  this.selectionForeground = UIManager.getColor("Tree.selectionForeground");
  this.selectionBackground = UIManager.getColor("Tree.selectionBackground");
  this.textForeground = UIManager.getColor("Tree.textForeground");
  this.textBackground = UIManager.getColor("Tree.textBackground");
}

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

private void setModelValue() {
  if (inherited) {
    inherited = false;
    component.setFont(component.getFont().deriveFont(Font.BOLD));
    
    component.setToolTipText(""); //NOI18N
  }
  boolean val = component.isSelected();
  setValue(val == getDefaultValue() ? null : val);
}

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

@SuppressWarnings({ "unchecked", "rawtypes" })
public void updateTitleFont() {
  if (task.isCompleted()) {
    Font font = box.getFont();
    
  Map attribs = font.getAttributes();
    attribs.put(TextAttribute.STRIKETHROUGH, true);
    box.setFont(new Font(attribs));
    box.setSelected(true);
  }
  else {
    Font font = box.getFont();
  Map Attribs = font.getAttributes();
    Attribs.put(TextAttribute.STRIKETHROUGH, false);
    box.setFont(new Font(Attribs));
    box.setSelected(false);
  }
}

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

private void clearAttribute() {
  super.setFont(null);
  super.setBackground(null);
  super.setForeground(null);
}

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

private JCheckBox createOptionCheckBox(String text, Icon checkboxIcon, Icon checkboxSelectedIcon) {
  JCheckBox checkBox = new JCheckBox(text);
  checkBox.setOpaque(false);
  checkBox.setForeground(new Color(150, 220, 255));
  checkBox.setFocusable(false);
  checkBox.setFont(checkBox.getFont().deriveFont(Font.BOLD));
  checkBox.setPreferredSize(new Dimension(150, 20));
  checkBox.setIcon(checkboxIcon);
  checkBox.setSelectedIcon(checkboxSelectedIcon);
  checkBox.setSelected(false);
  checkBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      repaint();
    }
  });
  return checkBox;
}

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

private JCheckBox getCheckBox( String string, String enString, boolean selected )
{
  string = Common.getStringUsingDefaultLanguage( string, enString ); // 使用預設語言 
  JCheckBox checkBox = new JCheckBox( string, selected );
  checkBox.setFont( SetUp.getDefaultFont() );
  if ( SetUp.getUsingBackgroundPicOfOptionFrame() )
  { // 若設定為透明,就用預定字體。
    checkBox.setForeground( SetUp.getOptionFrameOtherDefaultColor() );
    checkBox.setOpaque( false );
  }
  checkBox.addItemListener( new ItemHandler() );
  return checkBox;
}

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

private JCheckBox getCheckBoxBold( String string, String enString, boolean selected )
{
  string = Common.getStringUsingDefaultLanguage( string, enString ); // 使用預設語言 
  JCheckBox checkBox = new JCheckBox( string, selected );
  checkBox.setFont( SetUp.getDefaultBoldFont() );
  if ( SetUp.getUsingBackgroundPicOfOptionFrame() )
  { // 若設定為透明,就用預定字體。
    checkBox.setForeground( SetUp.getOptionFrameOtherDefaultColor() );
    checkBox.setOpaque( false );
  }
  checkBox.addItemListener( new ItemHandler() );
  return checkBox;
}

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

void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
  jcb.setFocusPainted( false );
  jcb.setFont( ControlPanel.jcb_font );
  if ( !_configuration.isUseNativeUI() ) {
    jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
    jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
  }
  p.add( jcb, "Center" );
  jcb.addActionListener( this );
}

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

@Override
public void installUI (JComponent c) {
  super.installUI (c);
  JCheckBox checkBox = (JCheckBox) c;
  checkBox.setFont (UIManager.getFont ("CheckBox.font"));
  checkBox.setBackground (UIManager.getColor ("CheckBox.background"));
  checkBox.setForeground (UIManager.getColor ("CheckBox.foreground"));
  checkBox.setIcon (UIManager.getIcon ("CheckBox.icon"));
  checkBox.setSelectedIcon (UIManager.getIcon ("CheckBox.selectedIcon"));
}

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

public Component getListCellRendererComponent(JList list, Object value,
   int index, boolean isSelected, boolean cellHasFocus) {
  Layer lyr = (Layer) value;
  checkbox.setBackground(isSelected ? getSelectionBackground()
    : getBackground());
  checkbox.setForeground(isSelected ? getSelectionForeground()
    : getForeground());
  checkbox.setSelected(lyr.isEnabled());
  checkbox.setEnabled(isEnabled());
  checkbox.setFont(getFont());
  checkbox.setFocusPainted(false);
  checkbox.setBorderPainted(true);
  checkbox.setBorder(isSelected ? UIManager
    .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
  checkbox.setText(lyr.getNameInfo());
  return checkbox;
 }
}

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

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    JCheckBox checkbox = (JCheckBox) value;
    checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
    checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
    checkbox.setEnabled(isEnabled());
    checkbox.setFont(getFont());
    checkbox.setFocusPainted(false);
    checkbox.setBorderPainted(false);
    return checkbox;
  }
}

相关文章

JCheckBox类方法