當前位置: 首頁>>代碼示例>>Java>>正文


Java JCheckBox.setHorizontalAlignment方法代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:CodeSetupPanel.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:CodeSetupPanel.java

示例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;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:10,代碼來源:TableCellRenderer4CheckBox.java

示例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);
}
 
開發者ID:ZabuzaW,項目名稱:KivaBot,代碼行數:73,代碼來源:MainFrameView.java

示例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;
}
 
開發者ID:vimerzhao,項目名稱:gchisto,代碼行數:18,代碼來源:GUIUtilities.java

示例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;
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:7,代碼來源:MainWindow.java

示例7: BooleanCellRenderer

import javax.swing.JCheckBox; //導入方法依賴的package包/類
public BooleanCellRenderer() {
    super();
    cb = new JCheckBox();
    cb.setOpaque(true);
    cb.setHorizontalAlignment(0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:ResultSetCellRenderer.java

示例8: BooleanTableCellEditor

import javax.swing.JCheckBox; //導入方法依賴的package包/類
public BooleanTableCellEditor(JCheckBox cb) {
    super(cb);
    cb.setOpaque(true);
    cb.setHorizontalAlignment(0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:BooleanTableCellEditor.java

示例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;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:10,代碼來源:ComponentTypeDialog.java

示例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;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:52,代碼來源:SelectionDialog.java

示例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();
                    }
                }
            });
        }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:46,代碼來源:ParameterControlPanel.java


注:本文中的javax.swing.JCheckBox.setHorizontalAlignment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。