Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

In this page you can find the example usage for javax.swing JPanel setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:op.controlling.PnlControlling.java

private void prepareSearchArea() {

    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

    JPanel mypanel = new JPanel();
    mypanel.setLayout(new VerticalLayout(5));
    mypanel.setBackground(Color.WHITE);

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);/*from   w ww  . j  a  v a 2  s .co m*/

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}

From source file:op.FrmMain.java

private CollapsiblePane addNursingRecords(final Station station) {
    //        bwButtonMap = new HashMap<Resident, JideButton>();

    EntityManager em = OPDE.createEM();/*from  w ww. ja va2s.  c  o m*/
    Query query;
    if (station == null) {
        query = em.createQuery("SELECT b FROM Resident b WHERE b.station IS NULL ORDER BY b.name, b.firstname");
    } else {
        query = em.createQuery(
                "SELECT b FROM Resident b WHERE b.station = :station ORDER BY b.name, b.firstname");
        query.setParameter("station", station);
    }
    ArrayList<Resident> residentList = new ArrayList<Resident>(query.getResultList());
    em.close();

    CollapsiblePane mypane = new CollapsiblePane(
            station == null ? SYSTools.xx("misc.msg.Archive") : station.getName());
    mypane.setFont(SYSConst.ARIAL14);
    mypane.setEmphasized(station != null && station.equals(StationTools.getStationForThisHost()));
    mypane.setStyle(CollapsiblePane.PLAIN_STYLE);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new VerticalLayout());
    labelPanel.setBackground(Color.WHITE);

    try {
        mypane.setCollapsed(!mypane.isEmphasized());
    } catch (PropertyVetoException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    if (!residentList.isEmpty() && station != null) {
        JideButton button = GUITools.createHyperlinkButton("opde.mainframe.printdailyplan",
                SYSConst.icon22print2, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                            PrescriptionTools.printDailyPlan(station, "html");
                        } else {
                            PrescriptionTools.printDailyPlan(station, "pdf");
                        }
                    }
                });
        button.setBackground(Color.WHITE);
        labelPanel.add(button);
    }

    for (final Resident resident : residentList) {
        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (currentResident != resident) {

                    if (previousProgButton != null) {
                        previousProgButton.setBackground(Color.WHITE);
                        previousProgButton.setOpaque(false);
                    }

                    previousProgButton = (JideButton) actionEvent.getSource();
                    previousProgButton.setBackground(Color.YELLOW);
                    previousProgButton.setOpaque(true);

                    currentResident = resident;

                    if (currentVisiblePanel instanceof PnlCare) {
                        ((NursingRecordsPanel) currentVisiblePanel).switchResident(resident);
                    } else {
                        setPanelTo(new PnlCare(resident, jspSearch));
                    }

                }
            }
        };

        JPanel singleButtonPanel = new JPanel();
        singleButtonPanel.setLayout(new BoxLayout(singleButtonPanel, BoxLayout.X_AXIS));
        singleButtonPanel.setBorder(null);

        singleButtonPanel.setOpaque(false);

        String titel = resident.getName() + ", " + resident.getFirstname() + " [" + resident.getRIDAnonymous()
                + "]";
        JideButton button = GUITools.createHyperlinkButton(titel, null, actionListener);
        button.setForegroundOfState(ThemePainter.STATE_DEFAULT,
                resident.getGender() == ResidentTools.FEMALE ? Color.red : Color.blue);
        button.setBackground(Color.WHITE);

        singleButtonPanel.add(button);

        OPDE.getDisplayManager().clearSubMessages();

        if (station != null) { // not for the archive
            JPanel pnl = new JPanel();
            pnl.setLayout(new BoxLayout(pnl, BoxLayout.X_AXIS));
            pnl.setOpaque(false);
            pnl.setBorder(null);

            setIconPanel(pnl, resident);

            synchronized (iconPanels) {
                iconPanels.put(resident, pnl);
            }

            singleButtonPanel.add(pnl);
        }

        labelPanel.add(singleButtonPanel);
    }

    mypane.setContentPane(labelPanel);
    listOfNursingrecords.add(mypane);
    return mypane;
}

From source file:org.apache.jmeter.config.gui.ArgumentsPanel.java

/**
 * Create a panel containing the add and delete buttons.
 *
 * @return a GUI panel containing the buttons
 *///w ww  .  j a va 2s .com
private JPanel makeButtonPanel() {
    showDetail = new JButton(JMeterUtils.getResString("detail")); // $NON-NLS-1$
    showDetail.setActionCommand(DETAIL);
    showDetail.setEnabled(true);

    add = new JButton(JMeterUtils.getResString("add")); // $NON-NLS-1$
    add.setActionCommand(ADD);
    add.setEnabled(true);

    // A button for adding new arguments to the table from the clipboard
    JButton addFromClipboard = new JButton(JMeterUtils.getResString("add_from_clipboard")); // $NON-NLS-1$
    addFromClipboard.setActionCommand(ADD_FROM_CLIPBOARD);
    addFromClipboard.setEnabled(true);

    delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$
    delete.setActionCommand(DELETE);

    if (enableUpDown) {
        up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$
        up.setActionCommand(UP);

        down = new JButton(JMeterUtils.getResString("down")); // $NON-NLS-1$
        down.setActionCommand(DOWN);
    }
    checkButtonsStatus();

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
    if (this.background != null) {
        buttonPanel.setBackground(this.background);
    }
    showDetail.addActionListener(this);
    add.addActionListener(this);
    addFromClipboard.addActionListener(this);
    delete.addActionListener(this);
    buttonPanel.add(showDetail);
    buttonPanel.add(add);
    buttonPanel.add(addFromClipboard);
    buttonPanel.add(delete);
    if (enableUpDown) {
        up.addActionListener(this);
        down.addActionListener(this);
        buttonPanel.add(up);
        buttonPanel.add(down);
    }
    return buttonPanel;
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java

@Override
public void refreshView(final ViewState state) {
    Rectangle visibleRect = null;
    if (this.tree != null) {
        visibleRect = this.tree.getVisibleRect();
    }/*from w  ww  .java 2  s .  co  m*/

    this.removeAll();

    this.actionsMenu = this.createPopupMenu(state);

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("WORKFLOWS");
    for (ModelGraph graph : state.getGraphs()) {
        root.add(this.buildTree(graph, state));
    }
    tree = new JTree(root);
    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    tree.add(this.actionsMenu);

    if (state.getSelected() != null) {
        // System.out.println("SELECTED: " + state.getSelected());
        TreePath treePath = this.getTreePath(root, state.getSelected());
        if (state.getCurrentMetGroup() != null) {
            treePath = this.getTreePath(treePath, state);
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_STATIC_METADATA))) {
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("static-metadata")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPreConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("pre-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_POSTCONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPostConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("post-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        }
        this.tree.expandPath(treePath);
        this.tree.setSelectionPath(treePath);
    }

    tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            if (e.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) {
                DefaultTreeView.this.resetProperties(state);
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
                if (node.getUserObject() instanceof ModelGraph) {
                    state.setSelected((ModelGraph) node.getUserObject());
                    state.setCurrentMetGroup(null);
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject().equals("static-metadata")
                        || node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions")) {
                    state.setSelected((ModelGraph) ((DefaultMutableTreeNode) node.getParent()).getUserObject());
                    state.setCurrentMetGroup(null);
                    state.setProperty(EXPAND_STATIC_METADATA,
                            Boolean.toString(node.getUserObject().equals("static-metadata")));
                    state.setProperty(EXPAND_PRECONDITIONS,
                            Boolean.toString(node.getUserObject().equals("pre-conditions")));
                    state.setProperty(EXPAND_POSTCONDITIONS,
                            Boolean.toString(node.getUserObject().equals("post-conditions")));
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                    DefaultMutableTreeNode metNode = null;
                    String group = null;
                    Object[] path = e.getPath().getPath();
                    for (int i = path.length - 1; i >= 0; i--) {
                        if (((DefaultMutableTreeNode) path[i]).getUserObject() instanceof ModelGraph) {
                            metNode = (DefaultMutableTreeNode) path[i];
                            break;
                        } else if (((DefaultMutableTreeNode) path[i])
                                .getUserObject() instanceof ConcurrentHashMap) {
                            if (group == null) {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next();
                            } else {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next() + "/" + group;
                            }
                        }
                    }
                    ModelGraph graph = (ModelGraph) metNode.getUserObject();
                    state.setSelected(graph);
                    state.setCurrentMetGroup(group);
                    DefaultTreeView.this.notifyListeners();
                } else {
                    state.setSelected(null);
                    DefaultTreeView.this.notifyListeners();
                }
            }
        }

    });
    tree.setCellRenderer(new TreeCellRenderer() {

        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (node.getUserObject() instanceof String) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel label = new JLabel((String) node.getUserObject());
                label.setForeground(Color.blue);
                panel.add(label, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ModelGraph) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel iconLabel = new JLabel(
                        ((ModelGraph) node.getUserObject()).getModel().getExecutionType() + ": ");
                iconLabel.setForeground(((ModelGraph) node.getUserObject()).getModel().getColor());
                iconLabel.setBackground(Color.white);
                JLabel idLabel = new JLabel(((ModelGraph) node.getUserObject()).getModel().getModelName());
                idLabel.setBackground(Color.white);
                panel.add(iconLabel, BorderLayout.WEST);
                panel.add(idLabel, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                String group = (String) ((ConcurrentHashMap<String, String>) node.getUserObject()).keySet()
                        .iterator().next();
                JLabel nameLabel = new JLabel(group + " : ");
                nameLabel.setForeground(Color.blue);
                nameLabel.setBackground(Color.white);
                JLabel valueLabel = new JLabel(
                        ((ConcurrentHashMap<String, String>) node.getUserObject()).get(group));
                valueLabel.setForeground(Color.darkGray);
                valueLabel.setBackground(Color.white);
                panel.add(nameLabel, BorderLayout.WEST);
                panel.add(valueLabel, BorderLayout.EAST);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else {
                return new JLabel();
            }
        }

    });
    tree.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultTreeView.this.tree.getSelectionPath() != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) DefaultTreeView.this.tree
                        .getSelectionPath().getLastPathComponent();
                if (node.getUserObject() instanceof String && !(node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions"))) {
                    return;
                }
                orderSubMenu.setEnabled(node.getUserObject() instanceof ModelGraph
                        && !((ModelGraph) node.getUserObject()).isCondition()
                        && ((ModelGraph) node.getUserObject()).getParent() != null);
                DefaultTreeView.this.actionsMenu.show(DefaultTreeView.this.tree, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });
    this.scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    this.add(this.scrollPane, BorderLayout.CENTER);
    if (visibleRect != null) {
        this.tree.scrollRectToVisible(visibleRect);
    }

    this.revalidate();
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.GlobalConfigView.java

@Override
public void refreshView(ViewState state) {

    Rectangle visibleRect = null;
    if (this.tree != null) {
        visibleRect = this.tree.getVisibleRect();
    }//from w  w w. jav  a  2  s  . c  o  m

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("GlobalConfig");

    if (state != null && state.getGlobalConfigGroups() != null) {
        if (globalConfig != null && globalConfig.keySet().equals(state.getGlobalConfigGroups().keySet())
                && globalConfig.values().equals(state.getGlobalConfigGroups().values())) {
            return;
        }

        this.removeAll();

        for (ConfigGroup group : (globalConfig = state.getGlobalConfigGroups()).values()) {
            HashSet<String> keys = new HashSet<String>();
            DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new Group(group.getName()));
            root.add(groupNode);
            for (String key : group.getMetadata().getAllKeys()) {
                keys.add(key);
                DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(new Key(key));
                groupNode.add(keyNode);
                DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode(
                        new Value(StringUtils.join(group.getMetadata().getAllMetadata(key), ",")));
                keyNode.add(valueNode);
            }
            if (group.getExtends() != null) {
                List<String> extendsGroups = new Vector<String>(group.getExtends());
                Collections.reverse(extendsGroups);
                for (String extendsGroup : extendsGroups) {
                    List<String> groupKeys = state.getGlobalConfigGroups().get(extendsGroup).getMetadata()
                            .getAllKeys();
                    groupKeys.removeAll(keys);
                    if (groupKeys.size() > 0) {
                        for (String key : groupKeys) {
                            if (!keys.contains(key)) {
                                keys.add(key);
                                DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(
                                        new ExtendsKey(extendsGroup, key));
                                groupNode.add(keyNode);
                                DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode(
                                        new ExtendsValue(StringUtils.join(state.getGlobalConfigGroups()
                                                .get(extendsGroup).getMetadata().getAllMetadata(key), ",")));
                                keyNode.add(valueNode);
                            }
                        }
                    }
                }
            }
        }

        tree = new JTree(root);
        tree.setShowsRootHandles(true);
        tree.setRootVisible(false);

        tree.setCellRenderer(new TreeCellRenderer() {

            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                    boolean expanded, boolean leaf, int row, boolean hasFocus) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                if (node.getUserObject() instanceof Key) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.darkGray);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof ExtendsKey) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    ExtendsKey key = (ExtendsKey) node.getUserObject();
                    JLabel groupLabel = new JLabel("(" + key.getGroup() + ") ");
                    groupLabel.setForeground(Color.black);
                    JLabel keyLabel = new JLabel(key.getValue());
                    keyLabel.setForeground(Color.gray);
                    panel.add(groupLabel, BorderLayout.WEST);
                    panel.add(keyLabel, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof Group) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.black);
                    label.setBackground(Color.white);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof Value) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    panel.setBorder(new EtchedBorder(1));
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.black);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof ExtendsValue) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    panel.setBorder(new EtchedBorder(1));
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.gray);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else {
                    return new JLabel();
                }
            }

        });
    }

    this.setBorder(new EtchedBorder());
    JLabel panelName = new JLabel("Global-Config Groups");
    panelName.setBorder(new EtchedBorder());
    this.add(panelName, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Tree", scrollPane);
    tabbedPane.addTab("Table", new JPanel());

    this.add(tabbedPane, BorderLayout.CENTER);

    if (visibleRect != null) {
        this.tree.scrollRectToVisible(visibleRect);
    }

    this.revalidate();
}

From source file:org.archiviststoolkit.mydomain.DomainTableWorkSurface.java

protected void init(Class clazz, String name, Icon icon, DomainTableFormat tableFormat) {
    this.icon = icon;
    this.name = name;

    filterField = ApplicationFrame.getInstance().getFilterField(clazz);
    resultSizeDisplay = new JLabel("0 Record(s)");
    this.clazz = clazz;

    rootComponent.setLayout(new BorderLayout());
    initTable(false, tableFormat);//from   w  w  w . j  a  va2  s .  c o m

    // build a panel to hold the filter
    JPanel filterPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //      filterPanel.add(new JLabel("Filter:"));
    //      filterPanel.add(filterField);
    filterPanel.add(resultSizeDisplay);
    filterPanel.setBackground(ApplicationFrame.BACKGROUND_COLOR);
    rootComponent.add(filterPanel, BorderLayout.NORTH);

    newAction = new ConcreteAction("new");
    editAction = new ConcreteAction("edit");
    //      copyAction = new ConcreteAction("copy");
    searchAction = new ConcreteAction("search");
    findAllAction = new ConcreteAction("list all");
    showSelectedAction = new ConcreteAction("list selected records");
    showUnSelectedAction = new ConcreteAction("omit selected records");
    //      pasteAction = new ConcreteAction("paste");
    //      cutAction = new ConcreteAction("paste");
    deleteAction = new ConcreteAction("delete");
    assignPersistentIds = new ConcreteAction("assign persistent ids");
    debugAction = new ConcreteAction("Debug");

    pm = new JPopupMenu();
    pm.add(new JMenuItem(newAction));
    pm.add(new JMenuItem(editAction));

    if (Users.doesCurrentUserHaveAccess(Users.ACCESS_CLASS_ADVANCED_DATA_ENTRY)) {
        pm.add(new JMenuItem(deleteAction));
    }

    pm.add(new JMenuItem(searchAction));
    pm.add(new JMenuItem(findAllAction));
    pm.add(new JMenuItem(showSelectedAction));
    pm.add(new JMenuItem(showUnSelectedAction));

    if (this.clazz == Resources.class && Users.doesCurrentUserHaveAccess(Users.ACCESS_CLASS_SUPERUSER)) {
        pm.add(new JMenuItem(assignPersistentIds));
    }

    if (debug) {
        pm.addSeparator();
        pm.add(new JMenuItem(debugAction));
        debugAction.addActionListener(this);
    }

    pm.addMouseListener(this);

    newAction.addActionListener(this);
    editAction.addActionListener(this);
    deleteAction.addActionListener(this);
    searchAction.addActionListener(this);
    findAllAction.addActionListener(this);
    showSelectedAction.addActionListener(this);
    showUnSelectedAction.addActionListener(this);
    assignPersistentIds.addActionListener(this);
    //      cutAction.setEnabled(false);
    //      copyAction.setEnabled(false);
    //      pasteAction.setEnabled(false);
}

From source file:org.broad.igv.hic.MainWindow.java

private void initComponents() {
    JPanel mainPanel = new JPanel();
    JPanel toolbarPanel = new JPanel();

    //======== this ========

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    mainPanel.setLayout(new BorderLayout());

    toolbarPanel.setBorder(null);//w  ww . j  a v a  2 s .c om
    toolbarPanel.setLayout(new GridLayout());

    JPanel chrSelectionPanel = new JPanel();
    chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder());
    chrSelectionPanel.setMinimumSize(new Dimension(130, 57));
    chrSelectionPanel.setPreferredSize(new Dimension(130, 57));
    chrSelectionPanel.setLayout(new BorderLayout());

    JPanel panel10 = new JPanel();
    panel10.setBackground(new Color(204, 204, 204));
    panel10.setLayout(new BorderLayout());

    JLabel label3 = new JLabel();
    label3.setText("Chromosomes");
    label3.setHorizontalAlignment(SwingConstants.CENTER);
    panel10.add(label3, BorderLayout.CENTER);

    chrSelectionPanel.add(panel10, BorderLayout.PAGE_START);

    JPanel panel9 = new JPanel();
    panel9.setBackground(new Color(238, 238, 238));
    panel9.setLayout(new BoxLayout(panel9, BoxLayout.X_AXIS));

    //---- chrBox1 ----
    chrBox1 = new JComboBox();
    chrBox1.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox1ActionPerformed(e);
        }
    });
    panel9.add(chrBox1);

    //---- chrBox2 ----
    chrBox2 = new JComboBox();
    chrBox2.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox2ActionPerformed(e);
        }
    });
    panel9.add(chrBox2);

    //---- refreshButton ----
    JideButton refreshButton = new JideButton();
    refreshButton
            .setIcon(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshButtonActionPerformed(e);
        }
    });
    panel9.add(refreshButton);

    chrSelectionPanel.add(panel9, BorderLayout.CENTER);

    toolbarPanel.add(chrSelectionPanel);

    //======== displayOptionPanel ========
    JPanel displayOptionPanel = new JPanel();
    JPanel panel1 = new JPanel();
    displayOptionComboBox = new JComboBox();

    displayOptionPanel.setBackground(new Color(238, 238, 238));
    displayOptionPanel.setBorder(LineBorder.createGrayLineBorder());
    displayOptionPanel.setLayout(new BorderLayout());

    //======== panel14 ========

    JPanel panel14 = new JPanel();
    panel14.setBackground(new Color(204, 204, 204));
    panel14.setLayout(new BorderLayout());

    //---- label4 ----
    JLabel label4 = new JLabel();
    label4.setText("Show");
    label4.setHorizontalAlignment(SwingConstants.CENTER);
    panel14.add(label4, BorderLayout.CENTER);

    displayOptionPanel.add(panel14, BorderLayout.PAGE_START);

    //======== panel1 ========

    panel1.setBorder(new EmptyBorder(0, 10, 0, 10));
    panel1.setLayout(new GridLayout(1, 0, 20, 0));

    //---- comboBox1 ----
    displayOptionComboBox
            .setModel(new DefaultComboBoxModel(new String[] { DisplayOption.OBSERVED.toString() }));
    displayOptionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            displayOptionComboBoxActionPerformed(e);
        }
    });
    panel1.add(displayOptionComboBox);

    displayOptionPanel.add(panel1, BorderLayout.CENTER);

    toolbarPanel.add(displayOptionPanel);

    //======== colorRangePanel ========

    JPanel colorRangePanel = new JPanel();
    JLabel colorRangeLabel = new JLabel();
    colorRangeSlider = new RangeSlider();
    colorRangePanel.setBorder(LineBorder.createGrayLineBorder());
    colorRangePanel.setMinimumSize(new Dimension(96, 70));
    colorRangePanel.setPreferredSize(new Dimension(202, 70));
    colorRangePanel.setMaximumSize(new Dimension(32769, 70));
    colorRangePanel.setLayout(new BorderLayout());

    //======== panel11 ========

    JPanel colorLabelPanel = new JPanel();
    colorLabelPanel.setBackground(new Color(204, 204, 204));
    colorLabelPanel.setLayout(new BorderLayout());

    //---- colorRangeLabel ----
    colorRangeLabel.setText("Color Range");
    colorRangeLabel.setHorizontalAlignment(SwingConstants.CENTER);
    colorRangeLabel.setToolTipText("Range of color scale in counts per mega-base squared.");
    colorRangeLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    colorRangeLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
                rangeDialog.setVisible(true);
            }
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
            rangeDialog.setVisible(true);
        }
    });
    colorLabelPanel.add(colorRangeLabel, BorderLayout.CENTER);

    colorRangePanel.add(colorLabelPanel, BorderLayout.PAGE_START);

    //---- colorRangeSlider ----
    colorRangeSlider.setPaintTicks(true);
    colorRangeSlider.setPaintLabels(true);
    colorRangeSlider.setLowerValue(0);
    colorRangeSlider.setMajorTickSpacing(500);
    colorRangeSlider.setMaximumSize(new Dimension(32767, 52));
    colorRangeSlider.setPreferredSize(new Dimension(200, 52));
    colorRangeSlider.setMinimumSize(new Dimension(36, 52));
    colorRangeSlider.setMaximum(2000);
    colorRangeSlider.setUpperValue(500);
    colorRangeSlider.setMinorTickSpacing(100);
    colorRangeSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            colorRangeSliderStateChanged(e);
        }
    });
    colorRangePanel.add(colorRangeSlider, BorderLayout.PAGE_END);

    //        JPanel colorRangeTextPanel = new JPanel();
    //        colorRangeTextPanel.setLayout(new FlowLayout());
    //        JTextField minField = new JTextField();
    //        minField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(minField);
    //        colorRangeTextPanel.add(new JLabel(" - "));
    //        JTextField maxField = new JTextField();
    //        maxField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(maxField);
    //        colorRangeTextPanel.setPreferredSize(new Dimension(200, 52));
    //        colorRangePanel.add(colorRangeTextPanel, BorderLayout.PAGE_END);

    toolbarPanel.add(colorRangePanel);

    //======== resolutionPanel ========

    JLabel resolutionLabel = new JLabel();
    JPanel resolutionPanel = new JPanel();

    resolutionPanel.setBorder(LineBorder.createGrayLineBorder());
    resolutionPanel.setLayout(new BorderLayout());

    //======== panel12 ========

    JPanel panel12 = new JPanel();
    panel12.setBackground(new Color(204, 204, 204));
    panel12.setLayout(new BorderLayout());

    //---- resolutionLabel ----
    resolutionLabel.setText("Resolution");
    resolutionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    resolutionLabel.setBackground(new Color(204, 204, 204));
    panel12.add(resolutionLabel, BorderLayout.CENTER);

    resolutionPanel.add(panel12, BorderLayout.PAGE_START);

    //======== panel2 ========

    JPanel panel2 = new JPanel();
    panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));

    //---- resolutionSlider ----
    resolutionSlider = new JSlider();
    resolutionSlider.setMaximum(8);
    resolutionSlider.setMajorTickSpacing(1);
    resolutionSlider.setPaintTicks(true);
    resolutionSlider.setSnapToTicks(true);
    resolutionSlider.setPaintLabels(true);
    resolutionSlider.setMinorTickSpacing(1);

    Dictionary<Integer, JLabel> resolutionLabels = new Hashtable<Integer, JLabel>();
    Font f = FontManager.getFont(8);
    for (int i = 0; i < HiCGlobals.zoomLabels.length; i++) {
        if ((i + 1) % 2 == 0) {
            final JLabel tickLabel = new JLabel(HiCGlobals.zoomLabels[i]);
            tickLabel.setFont(f);
            resolutionLabels.put(i, tickLabel);
        }
    }
    resolutionSlider.setLabelTable(resolutionLabels);
    // Setting the zoom should always be done by calling resolutionSlider.setValue() so work isn't done twice.
    resolutionSlider.addChangeListener(new ChangeListener() {
        // Change zoom level while staying centered on current location.
        // Centering is relative to the bounds of the data, which might not be the bounds of the window

        public void stateChanged(ChangeEvent e) {
            if (!resolutionSlider.getValueIsAdjusting()) {
                int idx = resolutionSlider.getValue();
                idx = Math.max(0, Math.min(idx, MAX_ZOOM));

                if (hic.zd != null && idx == hic.zd.getZoom()) {
                    // Nothing to do
                    return;
                }

                if (hic.xContext != null) {
                    int centerLocationX = (int) hic.xContext
                            .getChromosomePosition(getHeatmapPanel().getWidth() / 2);
                    int centerLocationY = (int) hic.yContext
                            .getChromosomePosition(getHeatmapPanel().getHeight() / 2);
                    hic.setZoom(idx, centerLocationX, centerLocationY, false);
                }
                //zoomInButton.setEnabled(newZoom < MAX_ZOOM);
                //zoomOutButton.setEnabled(newZoom > 0);
            }
        }
    });
    panel2.add(resolutionSlider);

    resolutionPanel.add(panel2, BorderLayout.CENTER);

    toolbarPanel.add(resolutionPanel);

    mainPanel.add(toolbarPanel, BorderLayout.NORTH);

    //======== hiCPanel ========

    final JPanel hiCPanel = new JPanel();
    hiCPanel.setLayout(new HiCLayout());

    //---- rulerPanel2 ----
    rulerPanel2 = new HiCRulerPanel(hic);
    rulerPanel2.setMaximumSize(new Dimension(4000, 50));
    rulerPanel2.setMinimumSize(new Dimension(1, 50));
    rulerPanel2.setPreferredSize(new Dimension(1, 50));
    rulerPanel2.setBorder(null);

    JPanel panel2_5 = new JPanel();
    panel2_5.setLayout(new BorderLayout());
    panel2_5.add(rulerPanel2, BorderLayout.SOUTH);

    trackPanel = new TrackPanel(hic);
    trackPanel.setMaximumSize(new Dimension(4000, 50));
    trackPanel.setPreferredSize(new Dimension(1, 50));
    trackPanel.setMinimumSize(new Dimension(1, 50));
    trackPanel.setBorder(null);

    //        trackPanelScrollpane = new JScrollPane();
    //        trackPanelScrollpane.getViewport().add(trackPanel);
    //        trackPanelScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //        trackPanelScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //        trackPanelScrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
    //        trackPanelScrollpane.setBackground(new java.awt.Color(237, 237, 237));
    //        trackPanelScrollpane.setVisible(false);
    //        panel2_5.add(trackPanelScrollpane, BorderLayout.NORTH);
    //
    trackPanel.setVisible(false);
    panel2_5.add(trackPanel, BorderLayout.NORTH);

    hiCPanel.add(panel2_5, BorderLayout.NORTH);

    //---- rulerPanel1 ----
    rulerPanel1 = new HiCRulerPanel(hic);
    rulerPanel1.setMaximumSize(new Dimension(50, 4000));
    rulerPanel1.setPreferredSize(new Dimension(50, 500));
    rulerPanel1.setBorder(null);
    rulerPanel1.setMinimumSize(new Dimension(50, 1));
    hiCPanel.add(rulerPanel1, BorderLayout.WEST);

    //---- heatmapPanel ----
    heatmapPanel = new HeatmapPanel(this, hic);
    heatmapPanel.setBorder(LineBorder.createBlackLineBorder());
    heatmapPanel.setMaximumSize(new Dimension(500, 500));
    heatmapPanel.setMinimumSize(new Dimension(500, 500));
    heatmapPanel.setPreferredSize(new Dimension(500, 500));
    heatmapPanel.setBackground(new Color(238, 238, 238));
    hiCPanel.add(heatmapPanel, BorderLayout.CENTER);

    //======== panel8 ========

    JPanel rightSidePanel = new JPanel();
    rightSidePanel.setMaximumSize(new Dimension(120, 100));
    rightSidePanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    rightSidePanel.setLayout(null);

    //---- thumbnailPanel ----
    thumbnailPanel = new ThumbnailPanel(this, hic);
    thumbnailPanel.setMaximumSize(new Dimension(100, 100));
    thumbnailPanel.setMinimumSize(new Dimension(100, 100));
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBorder(LineBorder.createBlackLineBorder());
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBounds(new Rectangle(new Point(20, 0), thumbnailPanel.getPreferredSize()));
    rightSidePanel.add(thumbnailPanel);

    //======== xPlotPanel ========

    xPlotPanel = new JPanel();
    xPlotPanel.setPreferredSize(new Dimension(250, 100));
    xPlotPanel.setLayout(null);

    rightSidePanel.add(xPlotPanel);
    xPlotPanel.setBounds(10, 100, xPlotPanel.getPreferredSize().width, 228);

    //======== yPlotPanel ========

    yPlotPanel = new JPanel();
    yPlotPanel.setPreferredSize(new Dimension(250, 100));
    yPlotPanel.setLayout(null);

    rightSidePanel.add(yPlotPanel);
    yPlotPanel.setBounds(10, 328, yPlotPanel.getPreferredSize().width, 228);

    // compute preferred size
    Dimension preferredSize = new Dimension();
    for (int i = 0; i < rightSidePanel.getComponentCount(); i++) {
        Rectangle bounds = rightSidePanel.getComponent(i).getBounds();
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    }
    Insets insets = rightSidePanel.getInsets();
    preferredSize.width += insets.right;
    preferredSize.height += insets.bottom;
    rightSidePanel.setMinimumSize(preferredSize);
    rightSidePanel.setPreferredSize(preferredSize);

    hiCPanel.add(rightSidePanel, BorderLayout.EAST);

    mainPanel.add(hiCPanel, BorderLayout.CENTER);

    contentPane.add(mainPanel, BorderLayout.CENTER);

    JMenuBar menuBar = createMenuBar(hiCPanel);
    contentPane.add(menuBar, BorderLayout.NORTH);

    // setup the glass pane to display a wait cursor when visible, and to grab all mouse events
    rootPane.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    rootPane.getGlassPane().addMouseListener(new MouseAdapter() {
    });

}

From source file:org.cagrid.installer.steps.PresentLicenseStep.java

public void init(WizardModel m) {
    this.model = (CaGridInstallerModel) m;

    setLayout(new BorderLayout());
    setSize(new Dimension(475, 161));

    JPanel licensePanel = new JPanel();
    licensePanel.setBackground(Color.WHITE);
    JTextPane textPane = new JTextPane();
    licensePanel.add(textPane);//  w  ww  .j  a v a  2 s .c  o  m
    JScrollPane scrollPane = new JScrollPane(licensePanel);
    scrollPane.setPreferredSize(new Dimension(475, 150));
    add(scrollPane, BorderLayout.CENTER);

    try {
        StringBuilder sb = new StringBuilder();
        BufferedReader r = new BufferedReader(
                new InputStreamReader(getClass().getResourceAsStream("/cagrid_license.txt")));
        String line = null;
        while ((line = r.readLine()) != null) {
            sb.append(line).append("\n");
        }
        textPane.setText(sb.toString());
        textPane.setFont(textPane.getFont().deriveFont((float) 10));
    } catch (Exception ex) {
        String msg = "Error loading license: " + ex.getMessage();
        logger.error(msg, ex);
        JOptionPane.showMessageDialog(null, msg, this.model.getMessage("error"), JOptionPane.ERROR_MESSAGE);
    }

    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new GridBagLayout());
    add(controlPanel, BorderLayout.SOUTH);

    JLabel label = new JLabel(this.model.getMessage("accept.license"));
    controlPanel.add(label);

    JCheckBox checkBox = new JCheckBox();
    checkBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent evt) {
            PresentLicenseStep.this.setComplete(evt.getStateChange() == ItemEvent.SELECTED);
        }
    });
    controlPanel.add(checkBox);
}

From source file:org.colombbus.tangara.update.SoftwareUpdateDialog.java

private void addCenterPane() {
    JPanel centerPane = new JPanel();
    BoxLayout layout = new BoxLayout(centerPane, BoxLayout.Y_AXIS);
    centerPane.setLayout(layout);//from   w  w  w .  j  av  a  2 s .  c  o m

    JTextArea descPane = new JTextArea(info.getDescription());
    descPane.setFont(font);
    descPane.setEditable(false);
    centerPane.add(descPane);

    JPanel linkPanel = new JPanel();
    linkPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    String linkTitle = bundle.getString("SoftwareUpdateDialog.linkTitle"); //$NON-NLS-1$
    JLabel linkTitleLabel = new JLabel(linkTitle);
    linkTitleLabel.setFont(font);
    linkPanel.add(linkTitleLabel);
    HyperLinkLabel linkLabel = new HyperLinkLabel(info.getLink(), info.getLink());
    linkLabel.setFont(font);
    linkPanel.add(linkLabel);
    linkPanel.setBackground(Color.white);
    linkPanel.setOpaque(true);
    centerPane.add(linkPanel);
    add(centerPane, BorderLayout.CENTER);
}

From source file:org.ecoinformatics.seek.ecogrid.CheckBoxTableCellRenderer.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    jTable = table;/*  www  . j  a v a  2s. c  o m*/

    JPanel cellPanel = new JPanel();
    cellPanel.setBorder(new LineBorder(Color.lightGray, 1));
    cellPanel.setBackground(Color.WHITE);
    cellPanel.setPreferredSize(
            new Dimension(ServicesDisplayPanel.CELLPREFERREDWIDTH, ServicesDisplayPanel.HEIGHT));

    SelectableDocumentType selectedDocumentType = null;
    boolean isChecked = false;
    boolean isEnable = true;
    String text = null;
    if (value != null && value instanceof SelectableObjectInterface) {
        SelectableObjectInterface selectedObj = (SelectableObjectInterface) value;
        text = selectedObj.getSelectableObjectLabel();
        isChecked = selectedObj.getIsSelected();
        isEnable = selectedObj.getEnabled();
    }

    /*
     * label = (JLabel)renderer.getTableCellRendererComponent(table, text,
     * isSelected, hasFocus, row, column);
     */
    JLabel label = new JLabel(text);
    label.setFont(new Font(FONTNAME, Font.PLAIN, FONTSIZE));
    label.setPreferredSize(new Dimension(ServicesDisplayPanel.LABELPREFERWIDTH, ServicesDisplayPanel.HEIGHT));
    // set a check box name
    String checkBoxName = "" + topRowNum + SEPERATOR + row;
    JCheckBox checkBox = new JCheckBox();
    checkBox.setName(checkBoxName);
    checkBox.setBackground(Color.WHITE);
    checkBox.setSelected(isChecked);
    CheckBoxListener listener = new CheckBoxListener();
    checkBox.addItemListener(listener);
    // checkBox.setEnabled(false);

    /*
     * if (topRowNum != DEFAUTTOPROW ) { // for sub table we need to set up
     * check box enable status checkBox.setEnabled(isEnable); }//if
     */

    // add the label and checkbox to jpanel which has a border layout
    // manager
    BorderLayout layoutManager = new BorderLayout();
    cellPanel.setLayout(layoutManager);
    cellPanel.add(label, BorderLayout.CENTER);
    cellPanel.add(checkBox, BorderLayout.WEST);
    return cellPanel;
}