本文整理汇总了Java中javax.swing.JCheckBox.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setBackground方法的具体用法?Java JCheckBox.setBackground怎么用?Java JCheckBox.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setBackground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTitlePanel
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private JPanel createTitlePanel() {
JPanel title = new JPanel(new BorderLayout());
title.add(Guitilities.createGradientTitle(getTranslation("components.title")), BorderLayout.NORTH);
JPanel interact = new JPanel();
interact.setBackground(UIManager.getColor(Guitilities.SUB_PANEL_BACKGROUND));
interact.setLayout(new BoxLayout(interact, BoxLayout.X_AXIS));
interact.setBorder(new CompoundBorder(Guitilities.CHISEL_BORDER, new EmptyBorder(12, 8, 12, 8)));
final JCheckBox checkImages = new JCheckBox(getTranslation("group.images"), true);
checkImages.setBackground(UIManager.getColor(Guitilities.SUB_PANEL_BACKGROUND));
checkImages.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent event) {
for(ComponentButton button:componentButtons)
button.setIconVisible(checkImages.isSelected());
for(CollapsiblePanel panel:collapsiblePanels)
panel.setExpanded(false);
}
});
interact.add(checkImages);
title.add(interact, BorderLayout.CENTER);
return title;
}
示例2: getListCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
*/
public Component getListCellRendererComponent(JList list, final Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
final JCheckBox box = new JCheckBox(label.getText());
box.setBackground(label.getBackground());
box.setSelected(((ConfigurableEmitter) value).isEnabled());
checks.put(value, box);
return box;
}
示例3: getListCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(
JList<? extends JCheckBox> list, JCheckBox value, int index,
boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
JCheckBox checkbox = value;
final JCheckBox newCheck = new JCheckBox();
final JLabel newLabel = new JLabel(checkbox.getText());
newCheck.setSelected(checkbox.isSelected());
// Drawing checkbox, change the appearance here
newCheck.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newCheck.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newCheck.setEnabled(isEnabled());
newCheck.setFont(getFont());
newCheck.setFocusPainted(false);
newCheck.setBorderPainted(true);
newCheck.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setOpaque(true);
newLabel.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newLabel.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newLabel.setEnabled(isEnabled());
newLabel.setFocusable(false);
newLabel.setFont(getFont());
newLabel.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setIcon(checkbox.getIcon());
panel.add(newCheck, BorderLayout.WEST);
panel.add(newLabel, BorderLayout.CENTER);
return panel;
}
示例4: setUpCheckBox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
final JCheckBox setUpCheckBox(CheckRenderDataProvider crendata, Object value, JCheckBox cb) {
Boolean chSelected = crendata.isSelected(value);
cb.setEnabled(true);
cb.setSelected(!Boolean.FALSE.equals(chSelected));
// Third state is "selected armed" to be consistent with org.openide.explorer.propertysheet.ButtonModel3Way
cb.getModel().setArmed(chSelected == null);
cb.getModel().setPressed(chSelected == null);
cb.setEnabled(crendata.isCheckEnabled(value));
cb.setBackground(getBackground());
return cb;
}
示例5: createComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private JCheckBox createComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
EclipseProject project = projects[row];
JCheckBox chb = new JCheckBox();
chb.setSelected(selectedProjects.contains(project) ||
requiredProjects.contains(project));
chb.setToolTipText(null);
if (project.isImportSupported() && !requiredProjects.contains(project)) {
chb.setEnabled(true);
} else {
// required and non-java project are disabled
chb.setEnabled(false);
if (!project.isImportSupported()) {
chb.setToolTipText(ProjectImporterWizard.getMessage(
"MSG_NonJavaProject", project.getName())); // NOI18N
}
}
if (isSelected) {
chb.setOpaque(true);
chb.setForeground(table.getSelectionForeground());
chb.setBackground(table.getSelectionBackground());
} else {
chb.setOpaque(false);
chb.setForeground(table.getForeground());
chb.setBackground(table.getBackground());
}
return chb;
}
示例6: CorefTreeCellRenderer
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* Constructor.
*/
public CorefTreeCellRenderer() {
setOpaque(true);
check = new JCheckBox();
check.setBackground(Color.white);
label = new JLabel();
setLayout(new BorderLayout(5, 10));
add(check, BorderLayout.WEST);
add(label, BorderLayout.CENTER);
}
示例7: createJCheckBoxForTable
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* It creates a new check box for inclusion in a table and sets
* its "is selected" attribute to the given value.
*
* @param selected It determines whether the newly-created check box
* will be selected or not.
* @return A new check box for inclusion in a table.
*/
static public JCheckBox createJCheckBoxForTable(boolean selected) {
JCheckBox checkBox = new JCheckBox();
checkBox.setOpaque(true);
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
checkBox.setForeground(TABLE_COMPONENT_FG_COLOR);
checkBox.setBackground(TABLE_COMPONENT_BG_COLOR);
checkBox.setSelected(selected);
return checkBox;
}