List of usage examples for javax.swing JCheckBox setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:CheckBoxIcon.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon checked = new CheckBoxIcon(); Icon unchecked = new CheckBoxIcon(); JCheckBox aCheckBox1 = new JCheckBox("Pizza", unchecked); aCheckBox1.setSelectedIcon(checked); JCheckBox aCheckBox2 = new JCheckBox("Calzone"); aCheckBox2.setIcon(unchecked); aCheckBox2.setSelectedIcon(checked); Icon checkBoxIcon = new CheckBoxIcon(); JCheckBox aCheckBox3 = new JCheckBox("Anchovies", checkBoxIcon); JCheckBox aCheckBox4 = new JCheckBox("Stuffed Crust", checked); frame.setLayout(new GridLayout(0, 1)); frame.add(aCheckBox1);//from ww w.j ava 2 s. co m frame.add(aCheckBox2); frame.add(aCheckBox3); frame.add(aCheckBox4); frame.setSize(300, 200); frame.setVisible(true); }
From source file:CheckBoxIcon.java
public static void main(String args[]) { JFrame frame = new JFrame("Iconizing CheckBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon checked = new CheckBoxIcon(); Icon unchecked = new CheckBoxIcon(); JCheckBox aCheckBox1 = new JCheckBox("Pizza", unchecked); aCheckBox1.setSelectedIcon(checked); JCheckBox aCheckBox2 = new JCheckBox("Calzone"); aCheckBox2.setIcon(unchecked); aCheckBox2.setSelectedIcon(checked); Icon checkBoxIcon = new CheckBoxIcon(); JCheckBox aCheckBox3 = new JCheckBox("Anchovies", checkBoxIcon); JCheckBox aCheckBox4 = new JCheckBox("Stuffed Crust", checked); frame.setLayout(new GridLayout(0, 1)); frame.add(aCheckBox1);/*from www. j ava 2s. co m*/ frame.add(aCheckBox2); frame.add(aCheckBox3); frame.add(aCheckBox4); frame.setSize(300, 200); frame.setVisible(true); }
From source file:DiamondAbstractButtonStateIcon.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JCheckBox bn = new JCheckBox("Click to change the icon color"); bn.setIcon(new DiamondAbstractButtonStateIcon()); frame.add(bn);/*w ww . j a v a 2s. c om*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:IconCheckBoxSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Iconizing CheckBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon checked = new DiamondIcon(Color.black, true); Icon unchecked = new DiamondIcon(Color.black, false); JCheckBox aCheckBox1 = new JCheckBox("Pizza", unchecked); aCheckBox1.setSelectedIcon(checked); JCheckBox aCheckBox2 = new JCheckBox("Calzone"); aCheckBox2.setIcon(unchecked); aCheckBox2.setSelectedIcon(checked); Icon checkBoxIcon = new CheckBoxIcon(); JCheckBox aCheckBox3 = new JCheckBox("Anchovies", checkBoxIcon); JCheckBox aCheckBox4 = new JCheckBox("Stuffed Crust", checked); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); contentPane.add(aCheckBox1);/* www .j a v a 2 s . co m*/ contentPane.add(aCheckBox2); contentPane.add(aCheckBox3); contentPane.add(aCheckBox4); frame.setSize(300, 200); frame.setVisible(true); }
From source file:JCheckBoxCustomIcon.java
public JCheckBoxCustomIcon() { setSize(300, 300);/* ww w .j a v a 2 s . co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox("Check me!"); checkBox.setSelected(true); // Set default icon for checkbox checkBox.setIcon(new ImageIcon("icon.png")); // Set selected icon when checkbox state is selected checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png")); // Set disabled icon for checkbox checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png")); // Set disabled-selected icon for checkbox checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png")); // Set checkbox icon when checkbox is pressed checkBox.setPressedIcon(new ImageIcon("pressedIcon.png")); // Set icon when a mouse is over the checkbox checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png")); // Set icon when a mouse is over a selected checkbox checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png")); getContentPane().add(checkBox); }
From source file:Main.java
public Main() { setSize(300, 300);//from w w w.j ava2 s. co m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox("Check me!"); checkBox.setSelected(true); // Set default icon for checkbox checkBox.setIcon(new ImageIcon("icon.png")); // Set selected icon when checkbox state is selected checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png")); // Set disabled icon for checkbox checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png")); // Set disabled-selected icon for checkbox checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png")); // Set checkbox icon when checkbox is pressed checkBox.setPressedIcon(new ImageIcon("pressedIcon.png")); // Set icon when a mouse is over the checkbox checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png")); // Set icon when a mouse is over a selected checkbox checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png")); getContentPane().add(checkBox); }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JCheckBox getIntelCheckBox(String text) { JCheckBox box = new JCheckBox(text); box.setIcon(UIImages.EMPTY_BOX_ICON.getImageIcon()); box.setSelectedIcon(UIImages.CHECK_BOX_ICON.getImageIcon()); box.setBackground(Color.WHITE); return box;//from ww w . j a v a 2 s . c om }
From source file:edu.ku.brc.specify.config.SpecifyExceptionTracker.java
@Override protected FeedBackSenderItem getFeedBackSenderItem(final Class<?> cls, final Exception exception) { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,8px,p,2px, p,4px,p,2px,f:p:g")); Vector<Taskable> taskItems = new Vector<Taskable>(TaskMgr.getInstance().getAllTasks()); Collections.sort(taskItems, new Comparator<Taskable>() { @Override/*w ww.j a v a 2s .co m*/ public int compare(Taskable o1, Taskable o2) { return o1.getName().compareTo(o2.getName()); } }); final JTextArea commentsTA = createTextArea(3, 60); final JTextArea stackTraceTA = createTextArea(15, 60); final JCheckBox moreBtn; commentsTA.setWrapStyleWord(true); commentsTA.setLineWrap(true); //JLabel desc = createI18NLabel("UNHDL_EXCP", SwingConstants.LEFT); JEditorPane desc = new JEditorPane("text/html", getResourceString("UNHDL_EXCP")); desc.setEditable(false); desc.setOpaque(false); //desc.setFont(new Font(Font.SANS_SERIF, Font.BOLD, (new JLabel("X")).getFont().getSize())); JScrollPane sp = new JScrollPane(stackTraceTA, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); int y = 1; pb.add(desc, cc.xyw(1, y, 4)); y += 2; pb.add(createI18NFormLabel("UNHDL_EXCP_CMM"), cc.xy(1, y)); y += 2; pb.add(createScrollPane(commentsTA, true), cc.xyw(1, y, 4)); y += 2; forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); //$NON-NLS-1$ setControlSize(moreBtn); JButton copyBtn = createI18NButton("UNHDL_EXCP_COPY"); PanelBuilder innerPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,2px,p:g,2px,p")); innerPB.add(createI18NLabel("UNHDL_EXCP_STK"), cc.xy(1, 1)); innerPB.add(sp, cc.xyw(1, 3, 3)); innerPB.add(copyBtn, cc.xy(1, 5)); stackTracePanel = innerPB.getPanel(); stackTracePanel.setVisible(false); pb.add(moreBtn, cc.xyw(1, y, 4)); y += 2; pb.add(stackTracePanel, cc.xyw(1, y, 4)); y += 2; ByteArrayOutputStream baos = new ByteArrayOutputStream(); exception.printStackTrace(new PrintStream(baos)); stackTraceTA.setText(baos.toString()); moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (stackTracePanel.isVisible()) { stackTracePanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } else { stackTracePanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (dlg != null) { dlg.pack(); } } }); copyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String taskName = getTaskName(); FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(), stackTraceTA.getText(), cls.getName()); NameValuePair[] pairs = createPostParameters(item); StringBuilder sb = new StringBuilder(); for (NameValuePair pair : pairs) { if (!pair.getName().equals("bug")) { sb.append(pair.getName()); sb.append(": "); if (pair.getName().equals("comments") || pair.getName().equals("stack_trace")) { sb.append("\n"); } sb.append(pair.getValue()); sb.append("\n"); } } // Copy to Clipboard UIHelper.setTextToClipboard(sb.toString()); } }); pb.setDefaultDialogBorder(); dlg = new CustomDialog((Frame) null, getResourceString("UnhandledExceptionTitle"), true, CustomDialog.OK_BTN, pb.getPanel()); dlg.setOkLabel(getResourceString("UNHDL_EXCP_SEND")); dlg.createUI(); stackTracePanel.setVisible(false); centerAndShow(dlg); String taskName = getTaskName(); FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(), stackTraceTA.getText(), cls.getName()); return item; }