List of usage examples for javax.swing JMenuBar setBorderPainted
@BeanProperty(visualUpdate = true, description = "Whether the border should be painted.") public void setBorderPainted(boolean b)
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();/* w w w .j a v a2 s .c om*/ JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); bar.setBorderPainted(false); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:at.tuwien.ifs.commons.gui.controls.MultiOptionToggleButton.java
public MultiOptionToggleButton(final ImageIcon[] icons, final String[] buttonTexts, final String tooltip, final MultiOptionToggleListener listener) { super(icons[0]); this.setToolTipText(tooltip); this.addActionListener(new ActionListener() { @Override// w w w . ja va 2s . co m public void actionPerformed(ActionEvent e) { menu.show(MultiOptionToggleButton.this, 0, MultiOptionToggleButton.this.getHeight()); // highlight current selection final Component[] components = menu.getComponents(); for (Component c : components) { c.setBackground(null); } menu.getComponent(selectedIndex).setBackground(Color.GRAY); } }); for (int i = 0; i < buttonTexts.length; i++) { JMenuItem jMenuItem = new JMenuItem(buttonTexts[i], icons[i]); jMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { listener.performAction(e.getActionCommand()); selectedIndex = ArrayUtils.indexOf(buttonTexts, e.getActionCommand()); setIcon(icons[selectedIndex]); } }); menu.add(jMenuItem); } JMenuBar menuBar = new JMenuBar(); menuBar.setBorderPainted(false); menuBar.add(menu); }
From source file:org.openconcerto.task.TodoListPanel.java
public TodoListPanel() { this.setOpaque(false); this.iconTache = new ImageIcon(TodoListPanel.class.getResource("tache.png")); this.iconPriorite = new ImageIcon(TodoListPanel.class.getResource("priorite.png")); this.userTableCellRenderer = new UserTableCellRenderer(); this.timestampTableCellRendererCreated = new TimestampTableCellRenderer(); this.timestampTableCellRendererDone = new TimestampTableCellRenderer(); this.timestampTableCellRendererDeadLine = new TimestampTableCellRenderer(true); this.timestampTableCellEditorCreated = new TimestampTableCellEditor(); this.timestampTableCellEditorDone = new TimestampTableCellEditor(); this.timestampTableCellEditorDeadLine = new TimestampTableCellEditor(); // Icon renderer List<URL> l = new Vector<URL>(); l.add(TodoListPanel.class.getResource("empty.png")); l.add(TodoListPanel.class.getResource("high.png")); l.add(TodoListPanel.class.getResource("normal.png")); l.add(TodoListPanel.class.getResource("low.png")); this.iconEditor = new IconTableCellRenderer(l); this.iconRenderer = new IconTableCellRenderer(l); final User currentUser = UserManager.getInstance().getCurrentUser(); this.model = new TodoListModel(currentUser); this.sorter = new TableSorter(this.model); this.t = new LightEventJTable(this.sorter) { public JToolTip createToolTip() { return new JMultiLineToolTip(); }//from w ww. j a va 2s . c om @Override public String getToolTipText(MouseEvent event) { String r = null; TodoListElement task = getTaskAt(event.getPoint()); if (task != null && task.getCreatorId() > 1) { final String comment = task.getComment(); if (comment != null) { r = comment; r += "\n\n"; } else { r = ""; } r += getTM().trM("assignedBy", "user", UserManager.getInstance().getUser(task.getCreatorId()).getFullName(), "date", task.getDate()); } return r; } }; this.sorter.setTableHeader(this.t.getTableHeader()); this.model.setTable(this.t); this.comboUser = new JMenu(TM.tr("showTaskAssignedTo")); initViewableUsers(currentUser); // L'utilisateur courant doit voir ses taches + toutes les taches dont il a les droits this.model.addIdListenerSilently(Integer.valueOf(currentUser.getId())); final int size = this.users.size(); for (int i = 0; i < size; i++) { Integer id = Integer.valueOf((this.users.get(i)).getId()); if (this.model.listenToId(id)) { ((JCheckBoxMenuItem) this.comboUser.getMenuComponent(i)).setState(true); } else { ((JCheckBoxMenuItem) this.comboUser.getMenuComponent(i)).setState(false); } } this.addButton = new JButton(TM.tr("addTask")); this.removeButton = new JButton(); this.removeButton.setOpaque(false); updateDeleteBtn(); this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 6; // SEP TitledSeparator sep = new TitledSeparator( currentUser.getFirstName() + " " + currentUser.getName().toUpperCase()); this.add(sep, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.weightx = 0; this.add(this.addButton, c); c.gridx++; this.add(this.removeButton, c); c.anchor = GridBagConstraints.EAST; c.gridx++; final JMenuBar b = new JMenuBar(); b.setOpaque(false); b.setBorderPainted(false); b.add(this.comboUser); // Pour que le menu ne disparaisse pas quand on rapetisse trop la fenetre en bas b.setMinimumSize(b.getPreferredSize()); this.add(b, c); c.gridx++; c.weightx = 1; this.detailCheckBox = new JCheckBox(TM.tr("showDetails")); this.detailCheckBox.setOpaque(false); this.detailCheckBox.setSelected(false); this.add(this.detailCheckBox, c); // c.gridx++; this.hideOldCheckBox = new JCheckBox(TM.tr("hideHistory")); this.hideOldCheckBox.setOpaque(false); this.hideOldCheckBox.setSelected(true); this.add(this.hideOldCheckBox, c); c.gridx++; c.weightx = 0; c.anchor = GridBagConstraints.EAST; this.reloadPanel.setOpaque(false); this.add(this.reloadPanel, c); // Table c.gridwidth = 6; c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.BOTH; c.weighty = 1; c.weightx = 1; initPopUp(); initTable(TodoListModel.SIMPLE_MODE); this.add(new JScrollPane(this.t), c); initListeners(); this.model.asynchronousFill(); }