Example usage for javax.swing JMenuBar setOpaque

List of usage examples for javax.swing JMenuBar setOpaque

Introduction

In this page you can find the example usage for javax.swing JMenuBar setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:components.TopLevelDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w w w .j a va  2  s . c  o  m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TopLevelDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create the menu bar.  Make it have a green background.
    JMenuBar greenMenuBar = new JMenuBar();
    greenMenuBar.setOpaque(true);
    greenMenuBar.setBackground(new Color(154, 165, 127));
    greenMenuBar.setPreferredSize(new Dimension(200, 20));

    //Create a yellow label to put in the content pane.
    JLabel yellowLabel = new JLabel();
    yellowLabel.setOpaque(true);
    yellowLabel.setBackground(new Color(248, 213, 131));
    yellowLabel.setPreferredSize(new Dimension(200, 180));

    //Set the menu bar and add the label to the content pane.
    frame.setJMenuBar(greenMenuBar);
    frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:TopLevelDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//*from w  w  w  .j  av  a 2  s.  com*/
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("TopLevelDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create the menu bar. Make it have a cyan background.
    JMenuBar cyanMenuBar = new JMenuBar();
    cyanMenuBar.setOpaque(true);
    cyanMenuBar.setBackground(Color.cyan);
    cyanMenuBar.setPreferredSize(new Dimension(200, 20));

    //Create a yellow label to put in the content pane.
    JLabel yellowLabel = new JLabel();
    yellowLabel.setOpaque(true);
    yellowLabel.setBackground(Color.yellow);
    yellowLabel.setPreferredSize(new Dimension(200, 180));

    //Set the menu bar and add the label to the content pane.
    frame.setJMenuBar(cyanMenuBar);
    frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

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 av a 2 s  .c o  m*/

        @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();
}