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:org.openconcerto.erp.graph.GraphFamilleArticlePanel.java

private Component createColorPanel(final Color color) {
    final JPanel p = new JPanel();
    p.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    p.setMinimumSize(new Dimension(40, 16));
    p.setPreferredSize(new Dimension(40, 16));
    p.setOpaque(true);//from   w  w w .ja v  a2 s . co m
    p.setBackground(color);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds the panel hosting the time fields.
 * //from www  .j a  v a 2  s.c om
 * @return See above;
 */
private JPanel buildTimeRange() {
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("From: "));
    p.add(fromDate);
    p.add(UIUtilities.setTextFont("To: "));
    p.add(toDate);
    p.add(clearDate);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds and lays out the component displaying the various options.
 * //from  w  w  w  .  ja v a  2 s. co m
 * @return See above.
 */
private JPanel buildFields() {
    List<SearchObject> nodes = model.getNodes();
    SearchObject n;
    int m = nodes.size();
    JCheckBox box;
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1.0;
    c.gridy = 1;
    List<Integer> ctxNodes = null;
    SearchContext ctx = model.getSearchContext();
    if (ctx != null)
        ctxNodes = ctx.getContext();
    if (ctxNodes == null) {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);

            if (i % 2 == 0) {
                c.gridy++;
            }

            p.add(box, c);
            scopes.put(n.getIndex(), box);
        }
    } else {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);
            box.setSelected(ctxNodes.contains(n.getIndex()));

            if (i % 2 == 0)
                c.gridy++;

            p.add(box, c);
            scopes.put(n.getIndex(), box);
        }
    }
    c.gridy++;
    UIUtilities.setBoldTitledBorder("Restrict by Field", p);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds and lays out the component displaying the various options.
 * //from   w ww  .j  a  v  a2  s.c o  m
 * @return See above.
 */
private JPanel buildScope() {
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;

    p.add(new JLabel("Groups:"), c);
    c.gridx = 1;
    p.add(groupsBox, c);

    groupsBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            updateUsersBox();
        }
    });

    c.gridx = 0;
    c.gridy++;

    p.add(new JLabel("Data owned by:"), c);
    c.gridx = 1;
    p.add(usersBox, c);

    UIUtilities.setBoldTitledBorder("Scope", p);

    return p;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds and lays out the component displaying the various types.
 * //from   ww w  . j  a  va  2  s  .  co  m
 * @return See above.
 */
private JPanel buildType() {
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new GridBagLayout());
    // p.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(3, 3, 3, 3);
    List<SearchObject> nodes = model.getTypes();
    List<Integer> ctxNodes = null;
    SearchContext ctx = model.getSearchContext();
    if (ctx != null)
        ctxNodes = ctx.getType();

    SearchObject n;
    int m = nodes.size();
    JCheckBox box;
    c.weightx = 1.0;

    if (ctxNodes == null) {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);
            box.setSelected(true);
            p.add(box, c);
            if (i % 2 == 0)
                c.gridy++;
            types.put(n.getIndex(), box);
        }
    } else {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);
            box.setSelected(ctxNodes.contains(n.getIndex()));
            p.add(box, c);
            if (i % 2 == 0)
                c.gridy++;
            types.put(n.getIndex(), box);
        }
    }

    UIUtilities.setBoldTitledBorder(TYPE_TITLE, p);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds the UI component hosting the time interval.
 * /* ww w . j a v  a 2s.  c om*/
 * @return See above.
 */
private JPanel buildDate() {

    JPanel p = new JPanel();

    p.setBackground(UIUtilities.BACKGROUND_COLOR);

    p.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 0;
    c.gridy = 0;
    dateBox = new JComboBox();
    dateBox.setToolTipText(DATE_TYPE_TOOLTIP);
    dateBox.addItem(ITEM_IMPORTDATE);
    dateBox.addItem(ITEM_ACQUISITIONDATE);
    p.add(dateBox);

    c.gridy++;

    p.add(buildTimeRange(), c);

    UIUtilities.setBoldTitledBorder("Date", p);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setLayout(new BorderLayout(0, 0));
    JPanel p = new JPanel();
    p.setBorder(null);//from  ww w  .java  2s.  c om
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(buildQuotaPane());
    p.add(table);
    tabbedPane.add("Files to import", p);
    tabbedPane.add("Options", buildOptionsPane());

    double[][] tablePanelDesign = { { TableLayout.PREFERRED, 10, 5, TableLayout.FILL },
            { TableLayout.PREFERRED, TableLayout.FILL } };
    JPanel tablePanel = new JPanel(new TableLayout(tablePanelDesign));
    tablePanel.add(table.buildControls(), "0, 1, LEFT, CENTER");
    tablePanel.add(tabbedPane, "2, 1, 3, 1");
    int plugin = ImporterAgent.runAsPlugin();
    JSplitPane pane;
    if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        JLabel label = UIUtilities.setTextFont("Select where to import the image(s).");
        panel.add(UIUtilities.buildComponentPanel(label));
        panel.add(locationDialog.getContentPane());
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, tablePanel);
    } else {
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chooser, tablePanel);
    }

    JPanel mainPanel = new JPanel();
    double[][] mainPanelDesign = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } };
    mainPanel.setLayout(new TableLayout(mainPanelDesign));
    mainPanel.setBackground(UIUtilities.BACKGROUND);
    mainPanel.add(pane, "0, 1");

    this.add(mainPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel();
    controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));

    // Lays out the buttons.
    JPanel bar = new JPanel();
    bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS));
    bar.add(buildToolBarLeft());
    bar.add(buildToolBarRight());
    controls.add(new JSeparator());
    controls.add(bar);

    add(controls, BorderLayout.SOUTH);
    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations)
            getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
    }
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java

/** 
 * Builds a row.//from   w  w w.  j a va  2s  .  c  om
 * 
 * @return See above.
 */
private JPanel createRow() {
    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java

/** 
 * Builds and lays out the header.//from   w  ww .j  a  v a  2  s  .c  o  m
 * 
 * @return See above.
 */
private JPanel buildHeader() {
    sizeLabel = UIUtilities.createComponent(null);
    sizeLabel.setText(FileUtils.byteCountToDisplaySize(sizeImport));
    reportLabel = UIUtilities.setTextFont("Report:", Font.BOLD);
    importSizeLabel = UIUtilities.setTextFont("Import Size:", Font.BOLD);
    double[][] design = new double[][] { { TableLayout.PREFERRED },
            { TableLayout.PREFERRED, TableLayout.PREFERRED } };
    TableLayout layout = new TableLayout(design);
    JPanel detailsPanel = new JPanel(layout);
    detailsPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    JPanel p = createRow();
    p.add(reportLabel);
    p.add(numberOfImportLabel);
    detailsPanel.add(p, "0, 0");
    p = createRow();
    p.add(importSizeLabel);
    p.add(sizeLabel);
    detailsPanel.add(p, "0, 1");

    JPanel middlePanel = new JPanel();
    middlePanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    middlePanel.add(filterButton);

    JTextArea description = new JTextArea(MESSAGE);
    makeLabelStyle(description);
    description.setBackground(UIUtilities.BACKGROUND_COLOR);

    JPanel descriptionPanel = new JPanel();
    descriptionPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    descriptionPanel.add(description);

    JPanel header = new JPanel();
    header.setBackground(UIUtilities.BACKGROUND_COLOR);
    header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    header.setLayout(new BorderLayout());

    header.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
    header.add(detailsPanel, BorderLayout.WEST);
    header.add(middlePanel, BorderLayout.CENTER);
    header.add(descriptionPanel, BorderLayout.EAST);
    header.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);

    return header;
}

From source file:org.openmicroscopy.shoola.agents.measurement.util.ui.ResultsCellRenderer.java

/**
 * Adds the appropriate shape icon to the label.
 * //w w  w.  j a  v  a 2s.c  o  m
 * @param shape above.
 */
private JComponent makeShapeIcon(JLabel label, String shape) {
    if (FigureUtil.SCRIBBLE_TYPE.equals(shape))
        label.setIcon(SCRIBBLE);
    else if (FigureUtil.LINE_TYPE.equals(shape))
        label.setIcon(LINE);
    else if (FigureUtil.LINE_CONNECTION_TYPE.equals(shape))
        label.setIcon(CONNECTION);
    else if (FigureUtil.POLYGON_TYPE.equals(shape))
        label.setIcon(POLYGON);
    else if (FigureUtil.POINT_TYPE.equals(shape))
        label.setIcon(POINT);
    else if (FigureUtil.RECTANGLE_TYPE.equals(shape))
        label.setIcon(RECTANGLE);
    else if (FigureUtil.ELLIPSE_TYPE.equals(shape))
        label.setIcon(ELLIPSE);
    else if (FigureUtil.TEXT_TYPE.equals(shape))
        label.setIcon(TEXT);
    else if (FigureUtil.MASK_TYPE.equals(shape))
        label.setIcon(MASK);
    else
        label.setText(shape);
    if (label.getIcon() != null) {
        JPanel p = new JPanel();
        FlowLayout layout = new FlowLayout(FlowLayout.CENTER);
        layout.setVgap(0);
        p.setBorder(BorderFactory.createEmptyBorder());
        p.setLayout(layout);
        p.setOpaque(true);
        p.setBackground(getBackground());
        p.add(label);
        return p;
    }
    return label;
}