本文整理汇总了Java中javax.swing.JCheckBox.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setHorizontalAlignment方法的具体用法?Java JCheckBox.setHorizontalAlignment怎么用?Java JCheckBox.setHorizontalAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setHorizontalAlignment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellEditor
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public TableCellEditor getCellEditor(int row, int column) {
if(showParamTypes) {
String paramName = (String) tableModel.getValueAt(row, 0);
Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class;
if (Enum.class.isAssignableFrom(type)) {
JComboBox combo = new JComboBox(type.getEnumConstants());
return new DefaultCellEditor(combo);
} else if (type == Boolean.class || type == Boolean.TYPE) {
JCheckBox cb = new JCheckBox();
cb.setHorizontalAlignment(JLabel.CENTER);
cb.setBorderPainted(true);
return new DefaultCellEditor(cb);
} else if (paramName.toLowerCase().contains(Constants.PASSWORD)) {
return new DefaultCellEditor(new JPasswordField());
}
}
return super.getCellEditor(row, column);
}
示例2: getTableCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
Component ret = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String paramName = (String) tableModel.getValueAt(row, 0);
if (value == null) {
return new JLabel(NbBundle.getMessage(CodeSetupPanel.class, "LBL_NotSet"));
} else if (value instanceof Class) {
return new JLabel(((Class) value).getName());
} else if (value instanceof Boolean) {
JCheckBox cb = new JCheckBox();
cb.setHorizontalAlignment(JLabel.CENTER);
cb.setBorderPainted(true);
cb.setSelected((Boolean) value);
return cb;
} else if (paramName.contains(Constants.PASSWORD)) {
return new JPasswordField((String) value);
}
return ret;
}
示例3: getTableCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JCheckBox checkBox = new JCheckBox();
checkBox.setSelected((Boolean) value);
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
checkBox.setOpaque(true);
GraphGlobals.Colors.setTableCellRendererColors(checkBox, row, isSelected);
return checkBox;
}
示例4: initializeInputFields
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* Initialize the text fields.
*/
private void initializeInputFields() {
this.mBlueSphereMovementOptionsBox = new JCheckBox(EMoveType.BLUE_SPHERE.name(), true);
this.mBlueSphereMovementOptionsBox.setHorizontalAlignment(SwingConstants.LEFT);
this.mBlueSphereMovementOptionsBox.setBounds(0, 20, 150, 20);
this.mMainPanel.add(this.mBlueSphereMovementOptionsBox);
this.mInputElements.add(this.mBlueSphereMovementOptionsBox);
this.mUseProtectionSpell = new JCheckBox("Use protection spell", true);
this.mUseProtectionSpell.setHorizontalAlignment(SwingConstants.LEFT);
this.mUseProtectionSpell.setBounds(0, 70, 150, 20);
this.mMainPanel.add(this.mUseProtectionSpell);
this.mInputElements.add(this.mUseProtectionSpell);
this.mUseSpecialSkill = new JCheckBox("Use special skill", false);
this.mUseSpecialSkill.setHorizontalAlignment(SwingConstants.LEFT);
this.mUseSpecialSkill.setBounds(0, 90, 150, 20);
this.mMainPanel.add(this.mUseSpecialSkill);
this.mInputElements.add(this.mUseSpecialSkill);
final int taskBoxInitialY = 140;
final int taskBoxYPadding = 20;
final EKivaTask[] tasks = EKivaTask.values();
this.mTaskList = new LinkedList<>();
for (int i = 0; i < tasks.length; i++) {
final EKivaTask task = tasks[i];
final JCheckBox taskBox = new JCheckBox(task.name(), true);
taskBox.setHorizontalAlignment(SwingConstants.LEFT);
taskBox.setBounds(0, taskBoxInitialY + (i * taskBoxYPadding), 180, 20);
this.mMainPanel.add(taskBox);
this.mInputElements.add(taskBox);
this.mTaskList.add(taskBox);
}
this.mUsernameField = new JTextField();
this.mUsernameField.setHorizontalAlignment(SwingConstants.LEFT);
this.mUsernameField.setBounds((this.mMainPanel.getWidth() / 2) + 90, 0, 123, 20);
this.mMainPanel.add(this.mUsernameField);
this.mInputElements.add(this.mUsernameField);
this.mUsernameField.setColumns(DEFAULT_FIELD_COLUMNS);
this.mPasswordField = new JPasswordField();
this.mPasswordField.setHorizontalAlignment(SwingConstants.LEFT);
this.mPasswordField.setBounds((this.mMainPanel.getWidth() / 2) + 90, 30, 123, 20);
this.mMainPanel.add(this.mPasswordField);
this.mInputElements.add(this.mPasswordField);
this.mPasswordField.setColumns(DEFAULT_FIELD_COLUMNS);
this.mWorldChoiceBox = new JComboBox<>();
for (final EWorld world : EWorld.values()) {
this.mWorldChoiceBox.addItem(world);
if (world == EWorld.ONE) {
this.mWorldChoiceBox.setSelectedItem(world);
}
}
this.mWorldChoiceBox.setBounds((this.mMainPanel.getWidth() / 2) + 90, 60, 123, 20);
this.mMainPanel.add(this.mWorldChoiceBox);
this.mInputElements.add(this.mWorldChoiceBox);
this.mBrowserChoiceBox = new JComboBox<>();
for (final EBrowser browser : EBrowser.values()) {
this.mBrowserChoiceBox.addItem(browser);
if (browser == EBrowser.CHROME) {
this.mBrowserChoiceBox.setSelectedItem(browser);
}
}
this.mBrowserChoiceBox.setBounds((this.mMainPanel.getWidth() / 2) + 90, 170, 123, 20);
this.mMainPanel.add(this.mBrowserChoiceBox);
this.mInputElements.add(this.mBrowserChoiceBox);
}
示例5: 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;
}
示例6: addNewCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private static JCheckBox addNewCheckbox(String text, String configString, Boolean configBool) {
JCheckBox checkbox = new JCheckBox(text, Utils.getConfigBoolean(configString, configBool));
checkbox.setHorizontalAlignment(JCheckBox.RIGHT);
checkbox.setHorizontalTextPosition(JCheckBox.LEFT);
return checkbox;
}
示例7: BooleanCellRenderer
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public BooleanCellRenderer() {
super();
cb = new JCheckBox();
cb.setOpaque(true);
cb.setHorizontalAlignment(0);
}
示例8: BooleanTableCellEditor
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public BooleanTableCellEditor(JCheckBox cb) {
super(cb);
cb.setOpaque(true);
cb.setHorizontalAlignment(0);
}
示例9: getCheckBoxEdgeWidth
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* Gets the check box edge width.
* @return the check box edge width
*/
private JCheckBox getCheckBoxEdgeWidth() {
JCheckBox checkBox = new JCheckBox();
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
return checkBox;
}
示例10: constructJComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/** Constructs panel containing the main GUI components. */
private JPanel constructJComponent() {
// Selection panel
BoxLayout selectionPanelLayout = new BoxLayout(selectionPanel, BoxLayout.Y_AXIS);
selectionPanel.setLayout(selectionPanelLayout);
ButtonGroup radioButtons = new ButtonGroup();
if (optionsToSelect != null) {
for (int i = 0; i < optionsToSelect.size(); i++) {
JRadioButton radioButton = new JRadioButton(getI18n(optionsToSelect.get(i)));
radioButton.setHorizontalAlignment(JRadioButton.LEFT);
if (i == 0) {
radioButton.setSelected(true);
}
radioButtons.add(radioButton);
selectionPanel.add(radioButton);
}
}
// Checkbox panel
BoxLayout checkboxPanelLayout = new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS);
checkboxPanel.setLayout(checkboxPanelLayout);
if (optionsToCheck != null) {
for (int i = 0; i < optionsToCheck.size(); i++) {
JCheckBox jCheckBox = new JCheckBox(getI18n(optionsToCheck.get(i)));
jCheckBox.setHorizontalAlignment(JCheckBox.LEFT);
checkboxPanel.add(jCheckBox);
}
}
// Overall panel
JPanel panel = new JPanel();
BoxLayout panelLayout = new BoxLayout(panel, BoxLayout.Y_AXIS);
panel.setLayout(panelLayout);
panel.add(selectionPanel);
if (optionsToSelect != null && !optionsToSelect.isEmpty() && optionsToCheck != null || !optionsToCheck.isEmpty()) {
panel.add(Box.createRigidArea(new Dimension(0, GAP_BETWEEN_SELECTIONS)));
}
panel.add(checkboxPanel);
JPanel leftMarginPanel = new JPanel();
BoxLayout leftMarginPanelLayout = new BoxLayout(leftMarginPanel, BoxLayout.X_AXIS);
leftMarginPanel.setLayout(leftMarginPanelLayout);
leftMarginPanel.add(Box.createRigidArea(new Dimension(getInfoIcon().getIconWidth() + BUTTON_DIALOG_LEFT_GAP, 0)));
leftMarginPanel.add(panel);
return leftMarginPanel;
}
示例11: BooleanControl
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public BooleanControl(final Object f, PropertyDescriptor p) {
super();
final String name = p.getName();
final Method r = p.getReadMethod(), w = p.getWriteMethod();
setterMap.put(name, this);
clazz = f;
write = w;
read = r;
setLayout(new GridLayout(1, 0));
// setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(ALIGNMENT);
// setLayout(new FlowLayout(FlowLayout.LEADING));
JLabel label=new JLabel(name);
label.setAlignmentX(ALIGNMENT);
label.setHorizontalTextPosition(SwingConstants.LEFT);
label.setFont(label.getFont().deriveFont(fontSize));
add(label);
addTip(p,label);
checkBox = new JCheckBox();
refresh();
checkBox.setAlignmentX(ALIGNMENT);
checkBox.setHorizontalAlignment(SwingConstants.LEFT);
checkBox.setHorizontalTextPosition(SwingConstants.LEFT);
// checkBox.setBorder(new EmptyBorder(0,0,0,0));
// Border border=checkBox.getBorder();
// Insets insets=border.getBorderInsets(this);
// insets.left=0;
addTip(p, checkBox);
add(checkBox);
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
w.invoke(clazz, checkBox.isSelected());
} catch (InvocationTargetException ite) {
ite.printStackTrace();
} catch (Exception iae) {
iae.printStackTrace();
}
}
});
}