当前位置: 首页>>代码示例>>Java>>正文


Java JCheckBox.setBorder方法代码示例

本文整理汇总了Java中javax.swing.JCheckBox.setBorder方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setBorder方法的具体用法?Java JCheckBox.setBorder怎么用?Java JCheckBox.setBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JCheckBox的用法示例。


在下文中一共展示了JCheckBox.setBorder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:38,代码来源:JCheckBoxList.java

示例2: createCollapseControl

import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createCollapseControl(String title, String tooltip) {
	Box box = Box.createHorizontalBox();
	expand = new JCheckBox(title);
	expand.setBorder(new EmptyBorder(0, 4, 0, 0));
	expand.setToolTipText(tooltip);
	expand.setHorizontalTextPosition(JCheckBox.RIGHT);
	expand.setIcon(new ArrowIcon(ArrowIcon.EAST));
	setCollapsedIcon(new ArrowIcon(ArrowIcon.EAST));
	setExpandedIcon(new ArrowIcon(ArrowIcon.SOUTH));
	expand.setSelected(isExpanded());
	expand.setFocusPainted(false);
	expand.addChangeListener(new CollapseListener());
	box.add(expand);
	return box;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:16,代码来源:CollapsiblePanel.java

示例3: FindBox

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public FindBox(final MainWindow mainWindow) {
	this.mainWindow = mainWindow;
	this.setDefaultCloseOperation(HIDE_ON_CLOSE);
	this.setHideOnEscapeButton();

	JLabel label = new JLabel("Find What:");
	textField = new JTextField();

	RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea();
	if (pane != null) {
		textField.setText(pane.getSelectedText());
	}
	mcase = new JCheckBox("Match Case");
	regex = new JCheckBox("Regex");
	wholew = new JCheckBox("Whole Words");
	reverse = new JCheckBox("Search Backwards");
	wrap = new JCheckBox("Wrap");

	findButton = new JButton("Find");
	findButton.addActionListener(new FindButton());
	this.getRootPane().setDefaultButton(findButton);

	KeyStroke funcF3 = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, false);
	this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(funcF3, "FindNext");
	this.getRootPane().getActionMap().put("FindNext", new FindExploreAction(true));

	KeyStroke sfuncF3 = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_DOWN_MASK, false);
	this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sfuncF3, "FindPrevious");
	this.getRootPane().getActionMap().put("FindPrevious", new FindExploreAction(false));

	mcase.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	regex.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	wholew.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	reverse.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	wrap.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	final Dimension center = new Dimension((int) (screenSize.width * 0.35),
			Math.min((int) (screenSize.height * 0.20), 200));
	final int x = (int) (center.width * 0.2);
	final int y = (int) (center.height * 0.2);
	this.setBounds(x, y, center.width, center.height);
	this.setResizable(false);

	GroupLayout layout = new GroupLayout(getRootPane());
	getRootPane().setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);

	layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(label)
			.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(textField)
					.addGroup(layout.createSequentialGroup()
							.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(mcase)
									.addComponent(wholew).addComponent(wrap))
					.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex)
							.addComponent(reverse))))
			.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton)));

	layout.linkSize(SwingConstants.HORIZONTAL, findButton);
	layout.setVerticalGroup(layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(label).addComponent(textField)
					.addComponent(findButton))
			.addGroup(layout.createParallelGroup(Alignment.LEADING)
					.addGroup(layout.createSequentialGroup()
							.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase)
									.addComponent(regex))
							.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wholew)
									.addComponent(reverse))
							.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wrap)))));

	this.adjustWindowPositionBySavedState();
	this.setSaveWindowPositionOnClosing();

	this.setName("Find");
	this.setTitle("Find");
	this.setVisible(true);
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:78,代码来源:FindBox.java


注:本文中的javax.swing.JCheckBox.setBorder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。