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:medsavant.enrichment.app.OntologyAggregatePanel.java

public OntologyAggregatePanel(String page) {
    super(page);//from  w  ww  . j  ava  2 s.c om
    setLayout(new GridBagLayout());

    chooser = new JComboBox(OntologyListItem.DEFAULT_ITEMS);
    chooser.setMaximumSize(new Dimension(400, chooser.getMaximumSize().height));
    progress = new JProgressBar();
    progress.setPreferredSize(new Dimension(600, progress.getMaximumSize().height));
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new GridBagLayout());
    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Ontology"));

    tree = new TreeTable();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    banner.add(chooser, gbc);
    gbc.anchor = GridBagConstraints.EAST;
    banner.add(progress, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    add(banner, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(tree), gbc);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (termFetcher != null) {
                termFetcher.cancel(true);
                termFetcher = null;
            }
            recalculate();
        }
    });

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);//www .j a v  a 2 s .c o m
    Color c;
    if (color.contains("#")) {
        c = Color.decode(color);
    } else if (color.toLowerCase().contains("rgb")) {
        String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", "");
        String[] stringRGBArr = rgb.split(",");
        c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]),
                Integer.valueOf(stringRGBArr[2]));
    } else {
        c = Color.RED;
    }

    cell.setBackground(c);
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java

private void initLayout() {
    JPanel propertiesPanel = new JPanel(
            new MigLayout("insets 12, novisualpadding, hidemode 3, fillx", "[right][left]"));
    propertiesPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    propertiesPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(204, 204, 204)), "SFTP Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    propertiesPanel.add(authenticationLabel);
    propertiesPanel.add(usePasswordRadio, "split 3");
    propertiesPanel.add(usePrivateKeyRadio);
    propertiesPanel.add(useBothRadio, "push, wrap");

    propertiesPanel.add(keyLocationLabel);
    propertiesPanel.add(keyLocationField, "w 200!, wrap");

    propertiesPanel.add(passphraseLabel);
    propertiesPanel.add(passphraseField, "w 125!, wrap");

    propertiesPanel.add(useKnownHostsLabel);
    propertiesPanel.add(useKnownHostsYesRadio, "split 3");
    propertiesPanel.add(useKnownHostsAskRadio);
    propertiesPanel.add(useKnownHostsNoRadio, "push, wrap");

    propertiesPanel.add(knownHostsLocationLabel);
    propertiesPanel.add(knownHostsField, "w 200!, wrap");

    propertiesPanel.add(configurationsLabel, "aligny top");
    propertiesPanel.add(configurationsScrollPane, "span, grow, split 2");

    JPanel configurationsButtonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    configurationsButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    configurationsButtonPanel.add(newButton, "w 50!, wrap");
    configurationsButtonPanel.add(deleteButton, "w 50!");

    propertiesPanel.add(configurationsButtonPanel, "top");

    add(propertiesPanel, "grow, push, top, wrap");

    JPanel buttonPanel = new JPanel(new MigLayout("insets 0 8 8 8, novisualpadding, hidemode 3, fill"));
    buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    buttonPanel.add(new JSeparator(), "growx, sx, wrap");
    buttonPanel.add(okButton, "newline, w 50!, sx, right, split");
    buttonPanel.add(cancelButton, "w 50!");

    add(buttonPanel, "south, span");
}

From source file:ConfigFiles.java

public JPanel addField(JTextField textfield, String text, int nr) {
    textfield.setMaximumSize(new Dimension(340, 25));
    textfield.setPreferredSize(new Dimension(340, 25));
    if (RunnerRepository.getLogs().size() > 0)
        textfield.setText(RunnerRepository.getLogs().get(nr));
    JLabel l1 = new JLabel(text);
    l1.setMaximumSize(new Dimension(80, 20));
    l1.setPreferredSize(new Dimension(80, 20));
    JPanel p721 = new JPanel();
    p721.setBackground(Color.WHITE);
    p721.add(l1);/*  w ww. j av  a 2s  .c  o m*/
    p721.add(textfield);
    p721.setMaximumSize(new Dimension(800, 28));
    p721.setPreferredSize(new Dimension(800, 28));
    return p721;
}

From source file:graphics.MainWindow.java

private void createSecondPanel(JPanel panel, int pos) {
    JPanel secondPanel = new JPanel();
    secondPanel.setBackground(new Color(157, 191, 160));
    panel.add("FieldPanel", secondPanel);

    JPanel Panel = new JPanel();
    Panel.setBackground(new Color(157, 191, 160));
    this.buttonDifusion[pos] = new JButton("Difusion Rates");
    this.buttonDifusion[pos].addActionListener(this);
    Panel.add(this.buttonDifusion[pos]);
    panel.add("DifusionPanel", Panel);
    ((CardLayout) panel.getLayout()).show(panel, "DifusionPanel");
}

From source file:flexflux.analyses.result.PP2DResult.java

public void plot() {

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    // one chart by group

    Map<Integer, Integer> correspGroup = new HashMap<Integer, Integer>();

    XYSeriesCollection dataset = new XYSeriesCollection();
    int index = 0;
    XYSeries series = new XYSeries("");
    for (double point : fluxValues) {

        series.add(point, resultValues.get(point));
        correspGroup.put(index, pointIndex.get(point));

        index++;/*  www.  j  a v  a  2 s  .c  om*/
    }

    dataset.addSeries(series);

    if (!expValues.isEmpty()) {
        XYSeries expSeries = new XYSeries("Experimental values");
        if (!expValues.isEmpty()) {
            for (Double d : expValues.keySet()) {
                for (Double d2 : expValues.get(d)) {
                    expSeries.add(d, d2);
                }
            }
        }

        dataset.addSeries(expSeries);
    }

    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart
            // title
            reacName, // domain axis label
            objName, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.GRAY);

    XYLineAndShapeRenderer renderer = new MyRenderer(true, false, correspGroup);

    plot.setRenderer(0, renderer);

    if (!expValues.isEmpty()) {
        renderer.setSeriesLinesVisible(1, false);
        renderer.setSeriesShapesVisible(1, true);
        renderer.setSeriesPaint(1, Color.BLUE);
    }

    ChartPanel chartPanel = new ChartPanel(chart);

    panel.add(chartPanel);

    JPanel fvaPanel = new JPanel();
    fvaPanel.setLayout(new BoxLayout(fvaPanel, BoxLayout.PAGE_AXIS));

    for (int i = 1; i <= groupIndex.size(); i++) {

        Color color = COLORLIST[i % COLORLIST.length];

        JPanel groupPanel = new JPanel();
        groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.PAGE_AXIS));

        List<BioEntity> newEssentialReactions = comparator.getNewEssentialEntities().get(i);

        List<BioEntity> noLongerEssentialReactions = comparator.getNoLongerEssentialEntities().get(i);

        JPanel colorPanel = new JPanel();

        colorPanel.setBackground(color);

        groupPanel.add(colorPanel);
        groupPanel.add(new JLabel(
                "Phenotypic phase " + i + ", " + newEssentialReactions.size() + " new essential reactions"));

        fvaPanel.add(groupPanel);

        if (newEssentialReactions.size() > 0) {
            fvaPanel.add(new JScrollPane(comparator.getNewEssentialEntitiesPanel().get(i)));
        }

        fvaPanel.add(new JLabel("Phenotypic phase " + i + ", " + noLongerEssentialReactions.size()
                + " no longer essential reactions"));

        if (noLongerEssentialReactions.size() > 0) {
            fvaPanel.add(fvaPanel.add(new JScrollPane(comparator.getNoLongerEssentialEntitiesPanel().get(i))));
        }

    }

    JScrollPane fvaScrollPane = new JScrollPane(fvaPanel);

    JFrame frame = new JFrame("Phenotypic phase analysis results");

    if (expValues.size() > 0) {
        frame.setTitle("Pareto analysis two dimensions results");
    }

    if (groupIndex.size() > 0) {

        JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, fvaScrollPane);
        frame.setContentPane(splitPane);
        frame.setSize(600, 1000);

    } else {
        frame.setContentPane(panel);
        frame.setSize(600, 600);
    }

    panel.setPreferredSize(new Dimension(600, 600));
    panel.setMinimumSize(new Dimension(600, 600));

    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

}

From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java

@Override
public Component getComponent() {
    if (dockableComponent == null) {
        JScrollPane scrollPane = new ExtendedJScrollPane(this);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setBorder(null);//from   w  w w .j a  v  a2s .  co m

        dockableComponent = new JPanel(new BorderLayout());

        JPanel toolBarPanel = new JPanel(new BorderLayout());
        ViewToolBar toolBar = new ViewToolBar();
        JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton();
        toggleExpertModeButton.setText(null);
        toolBar.add(toggleExpertModeButton);

        showHelpAction.setSelected(isShowParameterHelp());
        JToggleButton helpToggleButton = showHelpAction.createToggleButton();
        helpToggleButton.setText(null);
        toolBar.add(helpToggleButton);

        Action infoOperatorAction = new InfoOperatorAction() {

            private static final long serialVersionUID = 6758272768665592429L;

            @Override
            protected Operator getOperator() {
                return mainFrame.getFirstSelectedOperator();
            }
        };
        toolBar.add(infoOperatorAction);
        JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions())
                .createToggleButton();
        enableOperatorButton.setText(null);
        toolBar.add(enableOperatorButton);
        Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") {

            {
                setCondition(OPERATOR_SELECTED, MANDATORY);
            }

            private static final long serialVersionUID = -3104160320178045540L;

            @Override
            public void actionPerformed(ActionEvent e) {
                Operator operator = mainFrame.getFirstSelectedOperator();
                String name = SwingTools.showInputDialog("rename_operator", operator.getName());
                if (name != null && name.length() > 0) {
                    operator.rename(name);
                }
            }
        };
        toolBar.add(renameOperatorAction);
        toolBar.add(new DeleteOperatorAction());
        breakpointButton.addToToolBar(toolBar);

        // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION);
        toolBarPanel.add(toolBar, BorderLayout.NORTH);

        JPanel headerPanel = new JPanel();
        headerPanel.setBackground(SwingTools.LIGHTEST_BLUE);
        headerPanel.add(headerLabel);
        headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
        toolBarPanel.add(headerPanel, BorderLayout.SOUTH);

        dockableComponent.add(toolBarPanel, BorderLayout.NORTH);
        dockableComponent.add(scrollPane, BorderLayout.CENTER);

        // compatibility level and warnings
        JPanel southPanel = new JPanel(new BorderLayout());
        southPanel.add(expertModeHintLabel, BorderLayout.CENTER);
        compatibilityLabel.setLabelFor(compatibilityLevelSpinner);
        compatibilityLevelSpinner.setPreferredSize(
                new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight()));
        compatibilityPanel.add(compatibilityLabel);
        compatibilityPanel.add(compatibilityLevelSpinner);
        southPanel.add(compatibilityPanel, BorderLayout.SOUTH);

        dockableComponent.add(southPanel, BorderLayout.SOUTH);
    }
    return dockableComponent;
}

From source file:com.alvermont.terraj.stargen.ui.SystemFrame.java

/**
 * Build a list of images to be used for a list of planets and assign them
 * to the panels./*from  w  ww. j a v  a  2 s  . c om*/
 * 
 * @throws java.io.IOException If there is an error building the images
 */
public void buildImages() throws IOException {
    List<JLabel> labels = UIUtils.buildImages(this.planets);

    JPanel panel = new JPanel();

    panel.add(UIUtils.getSunLabel());

    for (JLabel label : labels) {
        panel.add(label);
    }

    panel.setBackground(Color.BLACK);

    systemScrollpane.setViewportView(panel);

    systemScrollpane.validate();

    populateOverview();
}

From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java

/**
 * Initialize the work package calendar panel inclusive the listeners.
 *//*  w  w w.j  av  a  2 s. c  om*/
private void init() {
    List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser()));

    Collections.sort(userWp, new APLevelComparator());

    dataset = createDataset(userWp);
    chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPopupMenu popup = new JPopupMenu();
    JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine()));
    miSave.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {

            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS
            chooser.setSelectedFile(new File("chart-" //NON-NLS
                    + System.currentTimeMillis() + ".jpg"));
            int returnVal = chooser.showSaveDialog(reference);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    File outfile = chooser.getSelectedFile();
                    ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(),
                            chartPanel.getWidth());
                    Controller.showMessage(
                            LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath()));
                } catch (IOException e) {
                    Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError());
                }
            }
        }

    });
    popup.add(miSave);

    chartPanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                popup.show(e.getComponent(), e.getX(), e.getY());
            }
        }

    });
    chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawWidth(9999);
    chartPanel.setPreferredSize(
            new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size()));

    chartPanel.setPopupMenu(null);

    this.setLayout(new BorderLayout());

    this.removeAll();

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    panel.add(chartPanel, constraints);

    panel.setBackground(Color.white);
    this.add(panel, BorderLayout.CENTER);

    GanttRenderer.setDefaultShadowsVisible(false);
    GanttRenderer.setDefaultBarPainter(new BarPainter() {

        @Override
        public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col,
                final RectangularShape rect, final RectangleEdge arg5) {

            String wpName = (String) dataset.getColumnKey(col);
            int i = 0;
            int spaceCount = 0;
            while (wpName.charAt(i++) == ' ' && spaceCount < 17) {
                spaceCount++;
            }

            g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15));
            g.fill(rect);
            g.setColor(Color.black);
            g.setStroke(new BasicStroke());
            g.draw(rect);
        }

        @Override
        public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2,
                final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) {

        }

    });

    ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() {
        private static final long serialVersionUID = -6078915091070733812L;

        public void drawItem(final Graphics2D g2, final CategoryItemRendererState state,
                final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis,
                final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column,
                final int pass) {
            super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
        }
    });

}

From source file:ConfigFiles.java

public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y,
        boolean withbutton, ActionListener actionlistener) {
    JPanel p1 = new JPanel();
    p1.setBackground(Color.WHITE);
    TitledBorder border = BorderFactory.createTitledBorder(title);
    border.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p1.setBorder(border);//from  ww  w . j  a v a 2 s  .  com
    p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
    p1.setBounds(80, Y, 800, 75);
    paths.add(p1);
    JTextArea tcpath = new JTextArea(description);
    tcpath.setWrapStyleWord(true);
    tcpath.setLineWrap(true);
    tcpath.setEditable(false);
    tcpath.setCursor(null);
    tcpath.setOpaque(false);
    tcpath.setFocusable(false);
    tcpath.setFont(new Font("Arial", Font.PLAIN, 12));
    tcpath.setBackground(getBackground());
    tcpath.setMaximumSize(new Dimension(170, 22));
    tcpath.setPreferredSize(new Dimension(170, 22));
    tcpath.setBorder(null);
    JPanel p11 = new JPanel();
    p11.setBackground(Color.WHITE);
    p11.setLayout(new GridLayout());
    p11.add(tcpath);
    p11.setMaximumSize(new Dimension(700, 18));
    p11.setPreferredSize(new Dimension(700, 18));
    textfield.setMaximumSize(new Dimension(340, 27));
    textfield.setPreferredSize(new Dimension(340, 27));
    textfield.setText(fieldtext);
    JButton b = null;
    if (withbutton) {
        b = new JButton("...");
        if (!PermissionValidator.canChangeFWM()) {
            b.setEnabled(false);
        }
        b.setMaximumSize(new Dimension(50, 20));
        b.setPreferredSize(new Dimension(50, 20));
        if (actionlistener == null) {
            b.addActionListener(new AbstractAction() {
                public void actionPerformed(ActionEvent ev) {
                    Container c;

                    if (RunnerRepository.container != null)
                        c = RunnerRepository.container.getParent();
                    else
                        c = RunnerRepository.window;
                    try {
                        new MySftpBrowser(RunnerRepository.host, RunnerRepository.user,
                                RunnerRepository.password, textfield, c, false);
                    } catch (Exception e) {
                        System.out.println("There was a problem in opening sftp browser!");
                        e.printStackTrace();
                    }
                }
            });
        } else {
            b.addActionListener(actionlistener);
            b.setText("Save");
            b.setMaximumSize(new Dimension(70, 20));
            b.setPreferredSize(new Dimension(70, 20));
        }
    }
    JPanel p12 = new JPanel();
    p12.setBackground(Color.WHITE);
    p12.add(textfield);
    if (withbutton)
        p12.add(b);
    p12.setMaximumSize(new Dimension(700, 32));
    p12.setPreferredSize(new Dimension(700, 32));
    p1.add(p11);
    p1.add(p12);
    return p12;
}