Java Code Examples for javax.swing.JCheckBox#setBorder()

The following examples show how to use javax.swing.JCheckBox#setBorder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MuleModulesCheckBoxList.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(
                JList<? extends JCheckBox> list, JCheckBox value, int index,
                boolean isSelected, boolean cellHasFocus) {
            JCheckBox checkbox = value;

            //Drawing checkbox, change the appearance here
/*
            checkbox.setBackground(isSelected ? getSelectionBackground()
                    : getBackground());
            checkbox.setForeground(isSelected ? getSelectionForeground()
                    : getForeground());
*/
            checkbox.setEnabled(isEnabled());
            checkbox.setFont(getFont());
            checkbox.setFocusPainted(false);
            checkbox.setBorderPainted(true);
            checkbox.setBorder(isSelected ? UIManager
                    .getBorder("List.focusCellHighlightBorder") : noFocusBorder);
            return checkbox;
        }
 
Example 2
Source File: ViewElementBoolean.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public ViewElementBoolean(RobotOverlord ro,BooleanEntity e) {
	super(ro);
	this.e=e;
	
	e.addObserver(this);
	
	field = new JCheckBox();
	field.setSelected(e.get());
	field.addItemListener(this);
	field.setBorder(new EmptyBorder(0,0,0,0));
	field.addFocusListener(this);
	
	JLabel label=new JLabel(e.getName(),SwingConstants.LEFT);
	label.setLabelFor(field);
	
	panel.setLayout(new BorderLayout());
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.LINE_END);
}
 
Example 3
Source File: CollapsiblePanel.java    From littleluck with Apache License 2.0 6 votes vote down vote up
protected Component createCollapseControl(String title, String tooltip) {
    // Add upper panel to hold collapse control
    Box box = Box.createHorizontalBox();
    expandCheckBox = new JCheckBox(title);
    expandCheckBox.setOpaque(false);
    expandCheckBox.setBorder(new EmptyBorder(0,4,0,0));
    expandCheckBox.setToolTipText(tooltip);
    expandCheckBox.setHorizontalTextPosition(JCheckBox.RIGHT);
    expandCheckBox.setSelectedIcon(new ArrowIcon(ArrowIcon.SOUTH));
    expandCheckBox.setIcon(new ArrowIcon(ArrowIcon.EAST));
    expandCheckBox.setSelected(isExpanded());
    
    expandCheckBox.addChangeListener(new CollapseListener());
    box.add(expandCheckBox);
    
    return box;                       
}
 
Example 4
Source File: CollapsiblePanel.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
protected Component createCollapseControl(String title, String tooltip) {
    // Add upper panel to hold collapse control
    Box box = Box.createHorizontalBox();
    
    expandCheckBox = new JCheckBox(title);
    expandCheckBox.setBorder(new EmptyBorder(0,4,0,0));
    expandCheckBox.setToolTipText(tooltip);
    expandCheckBox.setHorizontalTextPosition(JCheckBox.RIGHT);
    expandCheckBox.setSelectedIcon(new ArrowIcon(ArrowIcon.SOUTH));
    expandCheckBox.setIcon(new ArrowIcon(ArrowIcon.EAST));
    expandCheckBox.setSelected(isExpanded());
    
    expandCheckBox.addChangeListener(new CollapseListener());
    box.add(expandCheckBox);
    
    return box;                       
}
 
Example 5
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JCheckBox getIconCheckBox(String iconPath, String pressIconPath,
		String rolloverIconPath,String selectedIconPath) {
	JCheckBox checkBox = new JCheckBox();
	checkBox.setIcon(new ImageIcon(iconPath));
	checkBox.setPressedIcon(new ImageIcon(pressIconPath));
	checkBox.setRolloverIcon(new ImageIcon(rolloverIconPath));
	checkBox.setSelectedIcon(new ImageIcon(selectedIconPath));
	checkBox.setBorder(null);
	checkBox.setFocusPainted(false);
	checkBox.setContentAreaFilled(false);
	return checkBox;
}
 
Example 6
Source File: IntervalFileChooser.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public IntervalFileChooser(NMONVisualizerGui gui) {
    super(gui, "Select Interval File", "intervals.properties");

    useRelativeTime = new JCheckBox();
    useRelativeTime.setText("Relative Time?");
    useRelativeTime.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    useRelativeTime.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    useRelativeTime.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

    addComponentToChooser(this, null, useRelativeTime);
}
 
Example 7
Source File: NeuriteTracerResultsDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
private JPanel tracingPanel() {

		final JPanel tracingOptionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		useSnapWindow = new JCheckBox("Enable cursor [s]napping within: XY", plugin.snapCursor);
		useSnapWindow.setBorder(new EmptyBorder(0, 0, 0, 0));
		useSnapWindow.addItemListener(this);
		tracingOptionsPanel.add(useSnapWindow);

		final SpinnerModel xy_model = new SpinnerNumberModel(plugin.cursorSnapWindowXY * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_XY, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_XY * 2, 2);
		snapWindowXYsizeSpinner = new JSpinner(xy_model);
		((DefaultEditor) snapWindowXYsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowXYsizeSpinner.addChangeListener(this);
		tracingOptionsPanel.add(snapWindowXYsizeSpinner);

		final JLabel z_spinner_label = leftAlignedLabel("Z", isStackAvailable());
		z_spinner_label.setBorder(new EmptyBorder(0, 2, 0, 0));
		tracingOptionsPanel.add(z_spinner_label);
		final SpinnerModel z_model = new SpinnerNumberModel(plugin.cursorSnapWindowZ * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_Z, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_Z * 2, 2);
		snapWindowZsizeSpinner = new JSpinner(z_model);
		((DefaultEditor) snapWindowZsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowZsizeSpinner.addChangeListener(this);
		snapWindowZsizeSpinner.setEnabled(isStackAvailable());
		tracingOptionsPanel.add(snapWindowZsizeSpinner);
		// tracingOptionsPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
		return tracingOptionsPanel;
	}
 
Example 8
Source File: JPanel_AppManager.java    From MobyDroid with Apache License 2.0 5 votes vote down vote up
public JCheckBoxTableHeaderCellRenderer() {
    jCheckBox = new JCheckBox();
    jCheckBox.setFont(UIManager.getFont("TableHeader.font"));
    jCheckBox.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    jCheckBox.setBackground(UIManager.getColor("TableHeader.background"));
    jCheckBox.setForeground(UIManager.getColor("TableHeader.foreground"));
    jCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
    jCheckBox.setBorderPainted(true);
}
 
Example 9
Source File: CheckBoxList.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<? extends E> list, E 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(true);
    checkbox.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
    return checkbox;
}
 
Example 10
Source File: CustomCheckBoxList.java    From tmc-intellij with MIT License 5 votes vote down vote up
@Override
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.setFont(getFont());
    checkbox.setFocusPainted(false);
    checkbox.setBorderPainted(false);
    checkbox.setBorder(
            isSelected
                    ? UIManager.getBorder("List.focusCellHighlightBorder")
                    : new EmptyBorder(1, 1, 1, 1));
    return checkbox;
}
 
Example 11
Source File: BooleanDataBind.java    From iec61850bean with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent init() {
  checkbox = new JCheckBox();
  checkbox.setBorder(null);
  checkbox.setSelected(data.getValue());
  return checkbox;
}
 
Example 12
Source File: JPanel_TaskManager.java    From MobyDroid with Apache License 2.0 5 votes vote down vote up
public JCheckBoxTableHeaderCellRenderer() {
    jCheckBox = new JCheckBox();
    jCheckBox.setFont(UIManager.getFont("TableHeader.font"));
    jCheckBox.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    jCheckBox.setBackground(UIManager.getColor("TableHeader.background"));
    jCheckBox.setForeground(UIManager.getColor("TableHeader.foreground"));
    jCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
    jCheckBox.setBorderPainted(true);
}
 
Example 13
Source File: ControlPanel.java    From gepard with MIT License 4 votes vote down vote up
private JCheckBox getCustomCheckbox(String caption) {
	JCheckBox ret = new JCheckBox(caption);
	ret.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	ret.setFont(MAIN_FONT);
	return ret;
}
 
Example 14
Source File: DensityRenderingUI.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
@Override
public JPanel getOptionsPanel() {
    JPanel panel = super.getOptionsPanel();
    //dx
    JCheckBox forceDXCheckBox = new JCheckBox("Force", false);
    forceDXCheckBox.setBorder(BorderFactory.createEmptyBorder());
    parameters.registerComponent(forceDx, forceDXCheckBox);
    JPanel latUncertaintyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    panel.add(new JLabel("Lateral uncertainty [nm]:"), GridBagHelper.leftCol());
    JTextField dxTextField = new JTextField("", 10);
    parameters.registerComponent(dx, dxTextField);
    latUncertaintyPanel.add(dxTextField);
    latUncertaintyPanel.add(Box.createHorizontalStrut(5));
    latUncertaintyPanel.add(forceDXCheckBox);
    panel.add(latUncertaintyPanel, GridBagHelper.rightCol());
    //dz
    final JCheckBox forceDZCheckBox = new JCheckBox("Force", false);
    forceDZCheckBox.setBorder(BorderFactory.createEmptyBorder());
    parameters.registerComponent(forceDz, forceDZCheckBox);
    JPanel axUncertaintyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    final JLabel dzLabel = new JLabel("Axial uncertainty [nm]:");
    panel.add(dzLabel, GridBagHelper.leftCol());
    final JTextField dzTextField = new JTextField("", 10);
    parameters.registerComponent(dz, dzTextField);
    axUncertaintyPanel.add(dzTextField);
    axUncertaintyPanel.add(Box.createHorizontalStrut(5));
    axUncertaintyPanel.add(forceDZCheckBox);
    panel.add(axUncertaintyPanel, GridBagHelper.rightCol());
    //3D
    final JCheckBox threeDCheckBox = (JCheckBox) parameters.getRegisteredComponent(threeD);
    threeDCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dzLabel.setEnabled(threeDCheckBox.isSelected());
            forceDZCheckBox.setEnabled(threeDCheckBox.isSelected());
            dzTextField.setEnabled(threeDCheckBox.isSelected());
        }
    });

    parameters.loadPrefs();
    return panel;
}
 
Example 15
Source File: HistogramRenderingUI.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
@Override
public JPanel getOptionsPanel() {
    JPanel panel = super.getOptionsPanel();
    //avg
    JTextField avgTextField = new JTextField("", 20);
    parameters.registerComponent(avg, avgTextField);
    panel.add(new JLabel("Averages:"), GridBagHelper.leftCol());
    panel.add(avgTextField, GridBagHelper.rightCol());
    //dx
    JCheckBox forceDXCheckBox = new JCheckBox("Force", false);
    forceDXCheckBox.setBorder(BorderFactory.createEmptyBorder());
    parameters.registerComponent(forceDx, forceDXCheckBox);
    JPanel latUncertaintyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    panel.add(new JLabel("Lateral uncertainty [nm]:"), GridBagHelper.leftCol());
    JTextField dxTextField = new JTextField("", 10);
    parameters.registerComponent(dx, dxTextField);
    latUncertaintyPanel.add(dxTextField);
    latUncertaintyPanel.add(Box.createHorizontalStrut(5));
    latUncertaintyPanel.add(forceDXCheckBox);
    panel.add(latUncertaintyPanel, GridBagHelper.rightCol());
    //dz
    final JCheckBox forceDZCheckBox = new JCheckBox("Force", false);
    forceDZCheckBox.setBorder(BorderFactory.createEmptyBorder());
    parameters.registerComponent(forceDz, forceDZCheckBox);
    JPanel axUncertaintyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    final JLabel dzLabel = new JLabel("Axial uncertainty [nm]:");
    panel.add(dzLabel, GridBagHelper.leftCol());
    final JTextField dzTextField = new JTextField("", 10);
    parameters.registerComponent(dz, dzTextField);
    axUncertaintyPanel.add(dzTextField);
    axUncertaintyPanel.add(Box.createHorizontalStrut(5));
    axUncertaintyPanel.add(forceDZCheckBox);
    panel.add(axUncertaintyPanel, GridBagHelper.rightCol());
    //3D
    final JCheckBox threeDCheckBox = (JCheckBox) parameters.getRegisteredComponent(threeD);
    threeDCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dzLabel.setEnabled(threeDCheckBox.isSelected());
            forceDZCheckBox.setEnabled(threeDCheckBox.isSelected());
            dzTextField.setEnabled(threeDCheckBox.isSelected());
        }
    });
    parameters.loadPrefs();
    return panel;
}
 
Example 16
Source File: FindBox.java    From Luyten with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 17
Source File: ProcessInfoDialog.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
public ProcessInfoDialog(NMONVisualizerGui gui) {
    super(gui);
    setResizable(true);

    setLayout(new BorderLayout());
    setIconImage(PROCESS_ICON.getImage());

    processName = new JLabel();
    processName.setFont(Styles.TITLE);
    processName.setHorizontalAlignment(SwingConstants.CENTER);

    processTime = new JLabel();
    processTime.setFont(Styles.BOLD);
    processTime.setHorizontalAlignment(SwingConstants.CENTER);

    JPanel header = new JPanel();
    header.setLayout(new GridLayout(2, 1));
    header.setBorder(Styles.TITLE_BORDER);
    header.add(processName);
    header.add(processTime);

    add(header, BorderLayout.PAGE_START);

    commandLine = new JTextArea();
    commandLine.setColumns(50);
    commandLine.setRows(15);
    commandLine.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(commandLine);
    scrollPane.setBorder(Styles.DOUBLE_LINE_BORDER);
    add(scrollPane, BorderLayout.CENTER);

    followTree = new JCheckBox("Link with Tree?");
    followTree.setFont(Styles.LABEL);
    followTree.setHorizontalAlignment(SwingConstants.TRAILING);
    followTree.setHorizontalTextPosition(SwingConstants.LEADING);
    followTree.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
    followTree.setSelected(false);

    add(followTree, BorderLayout.PAGE_END);

    tree = null;
}
 
Example 18
Source File: ConfigWindow.java    From rscplus with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Adds a preconfigured JCheckbox to the specified container, setting its alignment constraint to
 * left and adding an empty padding border.
 *
 * @param text The text of the checkbox
 * @param container The container to add the checkbox to.
 * @return The newly created JCheckBox.
 */
private JCheckBox addCheckbox(String text, Container container) {
  JCheckBox checkbox = new JCheckBox(text);
  checkbox.setAlignmentX(Component.LEFT_ALIGNMENT);
  checkbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 5));
  container.add(checkbox);
  return checkbox;
}