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:net.nosleep.superanalyzer.panels.HomePanel.java

public JPanel createRightButtonBarPanel(final PieRotator rotator) {
    URL url = this.getClass().getResource("/media/" + "ButtonPlay.png");
    final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    url = this.getClass().getResource("/media/" + "ButtonPause.png");
    final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    final JButton button = new JButton(playIcon);
    button.setBorder(null);/*  www .jav  a  2s. c o m*/
    button.setBorderPainted(false);
    button.setText(null);
    button.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (rotator.isRunning() == false) {
                rotator.start();
                button.setIcon(pauseIcon);
            } else {
                rotator.stop();
                button.setIcon(playIcon);
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBackground(Color.white);
    toolBar.add(button);

    JPanel barPanel = new JPanel(new BorderLayout());
    barPanel.setBackground(Color.white);
    barPanel.add(toolBar, BorderLayout.SOUTH);

    return barPanel;
}

From source file:compecon.dashboard.panel.AgentsPanel.java

public AgentsPanel() {

    this.setLayout(new BorderLayout());

    JTabbedPane jTabbedPane = new JTabbedPane();

    for (Currency currency : Currency.values()) {
        JPanel panelForCurrency = new JPanel();
        panelForCurrency.setLayout(new GridLayout(0, 2));
        jTabbedPane.addTab(currency.getIso4217Code(), panelForCurrency);

        panelForCurrency.setBackground(Color.lightGray);

        for (Class<? extends Agent> agentType : ApplicationContext.getInstance().getAgentFactory()
                .getAgentTypes()) {//from   w w w.  ja  va 2 s  .  co  m
            panelForCurrency.add(createAgentNumberPanel(currency, agentType));
        }
    }

    add(jTabbedPane, BorderLayout.CENTER);
}

From source file:org.pmedv.jake.app.PlayerView.java

private JPanel createTopPanel() {

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.setBackground(Colors.LIGHT_GRAY);

    ImageIcon playIcon = resources.getIcon("icon.play");
    ImageIcon stopIcon = resources.getIcon("icon.stop");
    ImageIcon nextIcon = resources.getIcon("icon.next");
    ImageIcon prevIcon = resources.getIcon("icon.last");

    prevButton = new CmdJButton(prevIcon, "Plays the previous song", null);
    nextButton = new CmdJButton(nextIcon, "Plays the next song", null);
    startButton = new CmdJButton(playIcon, "Starts playing", null);
    stopButton = new CmdJButton(stopIcon, "Stops playing", null);

    buttonPanel.add(startButton);/*w ww . j  av  a2  s .  c o m*/
    buttonPanel.add(stopButton);

    buttonPanel.add(prevButton);
    buttonPanel.add(nextButton);

    buttonPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0),
            BorderFactory.createLineBorder(Color.LIGHT_GRAY)));

    timeField = new JTextField(5);
    timeField.setEditable(false);
    timeField.setBackground(Colors.SOFT_BLUE_ICE);
    titleField = new JMarqueeTextField(30);
    titleField.setEditable(false);
    titleField.setBackground(Colors.SOFT_BLUE_ICE);

    buttonPanel.add(timeField);
    buttonPanel.add(titleField);

    randomBox = new JCheckBox("R");

    buttonPanel.add(randomBox);

    return buttonPanel;

}

From source file:probe.com.model.util.vaadintoimageutil.Convertor.java

private JPanel convertVerticalLayout(VerticalLayout vaadinVerticalLayout) {

    JPanel verticalComponent = new JPanel();
    verticalComponent.setSize((int) vaadinVerticalLayout.getWidth(), (int) vaadinVerticalLayout.getHeight());
    verticalComponent.setBackground(backgroundMap.get(vaadinVerticalLayout.getStyleName()));
    return verticalComponent;
}

From source file:com.mirth.connect.manager.HeapSizeDialog.java

private void initLayout() {
    setLayout(new MigLayout("insets 8, novisualpadding, hidemode 3, fill"));
    JPanel panel = new JPanel(new MigLayout("insets 4, novisualpadding, hidemode 3, fill"));
    panel.setBackground(Color.white);
    panel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(204, 204, 204)), "Web Start Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    panel.add(new JLabel("Max Heap Size:"), "split");
    panel.add(heapSizeComboBox, "w 75!, left, wrap");

    panel.add(warningLabel, "split");

    add(panel);/*from  www .  j a v a2s .  com*/
    add(new JSeparator(), "newline, growx, sx");
    add(okButton, "newline, h 22!, w 56!, sx, right, split");
    add(cancelButton, "h 22!, w 56!");
}

From source file:SwingGlassExample.java

public SwingGlassExample() {
    super("GlassPane Demo");
    setSize(500, 300);/*from  w ww. j  a  v a  2 s . c  om*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // Now set up a few buttons & images for the main application
    JPanel mainPane = new JPanel();
    mainPane.setBackground(Color.white);
    JButton redB = new JButton("Red");
    JButton blueB = new JButton("Blue");
    JButton greenB = new JButton("Green");
    mainPane.add(redB);
    mainPane.add(greenB);
    mainPane.add(blueB);
    mainPane.add(new JLabel(new ImageIcon("oreilly.gif")));

    // Attach the popup debugger to the main app buttons so you
    // see the effect of making a glass pane visible
    PopupDebugger pd = new PopupDebugger(this);
    redB.addActionListener(pd);
    greenB.addActionListener(pd);
    blueB.addActionListener(pd);

    // And last but not least, our button to launch the glass pane
    JButton startB = new JButton("Start the big operation!");
    startB.addActionListener(new ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent A) {
            // manually control the 1.2/1.3 bug work-around
            glass.setNeedToRedispatch(false);
            glass.setVisible(true);
            startTimer();
        }
    });

    Container contentPane = getContentPane();
    contentPane.add(mainPane, BorderLayout.CENTER);
    contentPane.add(startB, BorderLayout.SOUTH);

    // Set up the glass pane with a little message and a progress bar...
    JPanel controlPane = new JPanel(new GridLayout(2, 1));
    controlPane.setOpaque(false);
    controlPane.add(new JLabel("Please wait..."));
    controlPane.add(waiter);
    glass = new FixedGlassPane(getJMenuBar(), getContentPane());
    glass.setLayout(new GridLayout(0, 1));
    glass.setOpaque(false);
    glass.add(new JLabel()); // padding...
    glass.add(new JLabel());
    glass.add(controlPane);
    glass.add(new JLabel());
    glass.add(new JLabel());
    setGlassPane(glass);
}

From source file:com.itemanalysis.jmetrik.graph.nicc.NonparametricCurvePanel.java

private void createChart(String name, String title, String xLabel, String yLabel, double minScore,
        double maxScore) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // y axis label
            dataset, // data
            chartOrientation, // chart orientation
            showLegend, // include legend
            true, // tooltips
            false // urls
    );//  www.j av a2  s . c o  m

    if (showLegend) {
        LegendTitle chartTitle = chart.getLegend();
        chartTitle.setPosition(legendPosition);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    //        //can use this code to fix the number of tick marks on the y-axis
    //        NumberFormat myFormatter = new DecimalFormat("#.0");
    //        NumberAxis yaxis = (NumberAxis)plot.getRangeAxis();
    //        yaxis.setTickUnit(new NumberTickUnit(.1, myFormatter));

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    panel.setPreferredSize(new Dimension(width, height));

    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    charts.put(name, chart);

    JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph
    subPanel.add(panel);
    subPanel.setBackground(Color.WHITE);
    this.add(subPanel);

}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploaderThumbnailerTester_2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }/*from www  .j a va  2  s  . co  m*/

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}

From source file:es.emergya.ui.gis.popups.ListaCapas.java

private ListaCapas(CustomMapView mapView, final IMapViewer historyMapViewer) {
    super();/*from  w  w  w  . j  a v a2 s  . c o m*/
    setTitle(i18n.getString("window.gpx.titleBar"));
    setLocationRelativeTo(getBasicWindow().getFrame());
    setResizable(false);
    setAlwaysOnTop(true);
    this.mapView = mapView;
    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setIconImage(getBasicWindow().getFrame().getIconImage());
    JPanel dialogo = new JPanel(new BorderLayout());
    dialogo.setBackground(Color.WHITE);
    dialogo.setBorder(new EmptyBorder(10, 10, 10, 10));

    capasGpx = new JPanel();
    capasGpx.setBackground(Color.WHITE);
    capasGpx.setLayout(new BoxLayout(capasGpx, BoxLayout.Y_AXIS));

    JScrollPane lista = new JScrollPane(capasGpx);
    lista.setOpaque(false);
    lista.setBorder(new TitledBorder(i18n.getString("window.gpx.title")));
    dialogo.add(lista, BorderLayout.CENTER);

    JPanel boton = new JPanel(new FlowLayout());
    boton.setOpaque(false);
    JButton cargar = getCargarGPXButton();
    boton.add(cargar, FlowLayout.LEFT);
    dialogo.add(boton, BorderLayout.SOUTH);

    add(dialogo);
    setPreferredSize(new Dimension(400, 250));
    pack();
    setLocationRelativeTo((Component) mapView);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosed(e);
            // historyMapViewer.getGPXButton().setSelected(false);
        }
    });

}

From source file:edu.cornell.mannlib.vitro.webapp.imageprocessor.jai.JaiImageProcessorTester2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }/* w  w w  . ja  v a2  s.  c o m*/

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new javax.media.jai.widget.ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}