Example usage for javax.swing JPanel getBackground

List of usage examples for javax.swing JPanel getBackground

Introduction

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

Prototype

@Transient
public Color getBackground() 

Source Link

Document

Gets the background color of this component.

Usage

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

@Override
public void configure(JPanel contentPane) {
    this.currentNetPlan = new NetPlan();

    BidiMap<NetworkLayer, Integer> mapLayer2VisualizationOrder = new DualHashBidiMap<>();
    Map<NetworkLayer, Boolean> layerVisibilityMap = new HashMap<>();
    for (NetworkLayer layer : currentNetPlan.getNetworkLayers()) {
        mapLayer2VisualizationOrder.put(layer, mapLayer2VisualizationOrder.size());
        layerVisibilityMap.put(layer, true);
    }//from   w  w  w  . j ava2  s . c o  m
    this.vs = new VisualizationState(currentNetPlan, mapLayer2VisualizationOrder, layerVisibilityMap,
            MAXSIZEUNDOLISTPICK);

    topologyPanel = new TopologyPanel(this, JUNGCanvas.class);

    JPanel leftPane = new JPanel(new BorderLayout());
    JPanel logSection = configureLeftBottomPanel();
    if (logSection == null) {
        leftPane.add(topologyPanel, BorderLayout.CENTER);
    } else {
        JSplitPane splitPaneTopology = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        splitPaneTopology.setTopComponent(topologyPanel);
        splitPaneTopology.setBottomComponent(logSection);
        splitPaneTopology.addPropertyChangeListener(new ProportionalResizeJSplitPaneListener());
        splitPaneTopology.setBorder(new LineBorder(contentPane.getBackground()));
        splitPaneTopology.setOneTouchExpandable(true);
        splitPaneTopology.setDividerSize(7);
        leftPane.add(splitPaneTopology, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, "grow");

    viewEditTopTables = new ViewEditTopologyTablesPane(GUINetworkDesign.this, new BorderLayout());

    reportPane = new ViewReportPane(GUINetworkDesign.this, JSplitPane.VERTICAL_SPLIT);

    setCurrentNetPlanDoNotUpdateVisualization(currentNetPlan);
    Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState
            .generateCanvasDefaultVisualizationLayerInfo(getDesign());
    vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond());

    /* Initialize the undo/redo manager, and set its initial design */
    this.undoRedoManager = new UndoRedoManager(this, MAXSIZEUNDOLISTCHANGES);
    this.undoRedoManager.addNetPlanChange();

    onlineSimulationPane = new OnlineSimulationPane(this);
    executionPane = new OfflineExecutionPanel(this);
    whatIfAnalysisPane = new WhatIfAnalysisPane(this);

    // Closing windows
    WindowUtils.clearFloatingWindows();

    final JTabbedPane tabPane = new JTabbedPane();
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.network),
            viewEditTopTables);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.offline), executionPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.online),
            onlineSimulationPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.whatif),
            whatIfAnalysisPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.report), reportPane);

    // Installing customized mouse listener
    MouseListener[] ml = tabPane.getListeners(MouseListener.class);

    for (int i = 0; i < ml.length; i++) {
        tabPane.removeMouseListener(ml[i]);
    }

    // Left click works as usual, right click brings up a pop-up menu.
    tabPane.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JTabbedPane tabPane = (JTabbedPane) e.getSource();

            int tabIndex = tabPane.getUI().tabForCoordinate(tabPane, e.getX(), e.getY());

            if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) {
                if (tabIndex == tabPane.getSelectedIndex()) {
                    if (tabPane.isRequestFocusEnabled()) {
                        tabPane.requestFocus();

                        tabPane.repaint(tabPane.getUI().getTabBounds(tabPane, tabIndex));
                    }
                } else {
                    tabPane.setSelectedIndex(tabIndex);
                }

                if (!tabPane.isEnabled() || SwingUtilities.isRightMouseButton(e)) {
                    final JPopupMenu popupMenu = new JPopupMenu();

                    final JMenuItem popWindow = new JMenuItem("Pop window out");
                    popWindow.addActionListener(e1 -> {
                        final int selectedIndex = tabPane.getSelectedIndex();
                        final String tabName = tabPane.getTitleAt(selectedIndex);
                        final JComponent selectedComponent = (JComponent) tabPane.getSelectedComponent();

                        // Pops up the selected tab.
                        final WindowController.WindowToTab windowToTab = WindowController.WindowToTab
                                .parseString(tabName);

                        if (windowToTab != null) {
                            switch (windowToTab) {
                            case offline:
                                WindowController.buildOfflineWindow(selectedComponent);
                                WindowController.showOfflineWindow(true);
                                break;
                            case online:
                                WindowController.buildOnlineWindow(selectedComponent);
                                WindowController.showOnlineWindow(true);
                                break;
                            case whatif:
                                WindowController.buildWhatifWindow(selectedComponent);
                                WindowController.showWhatifWindow(true);
                                break;
                            case report:
                                WindowController.buildReportWindow(selectedComponent);
                                WindowController.showReportWindow(true);
                                break;
                            default:
                                return;
                            }
                        }

                        tabPane.setSelectedIndex(0);
                    });

                    // Disabling the pop up button for the network state tab.
                    if (WindowController.WindowToTab.parseString(tabPane
                            .getTitleAt(tabPane.getSelectedIndex())) == WindowController.WindowToTab.network) {
                        popWindow.setEnabled(false);
                    }

                    popupMenu.add(popWindow);

                    popupMenu.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }
    });

    // Building windows
    WindowController.buildTableControlWindow(tabPane);
    WindowController.showTablesWindow(false);

    addAllKeyCombinationActions();
    updateVisualizationAfterNewTopology();
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel dialChart(int w) {
    JPanel panel = new JPanel();
    JPanel panel1 = new JPanel(new BorderLayout());

    panel.setLayout(new BorderLayout());

    pchart = new PowerChart("Power (W)", panel.getBackground());
    dialPanel = pchart.getChart("");
    dialPanel.setPreferredSize(new Dimension(300, 100));

    tplot = new ThermoPlot();
    tplotPanel = tplot.getChart();/* w  w  w . j  av a 2s .c  om*/
    tplotPanel.setPreferredSize(new Dimension(200, 100));

    panel1.add(dialPanel, BorderLayout.CENTER);
    panel1.add(tplotPanel, BorderLayout.LINE_END);

    panel.add(panel1, BorderLayout.CENTER);

    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel plotPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    String[] labels0 = { "S2C0  ", "S2C1  ", "S2C2  ", "S2C3  ", "PCIe Reads  " };
    String[] labels1 = { "C2S0  ", "C2S1  ", "C2S2  ", "C2S3  ", "PCIe Writes  " };

    dma0chart = new DMABarChart("Transmit (S2C) Performance", panel1.getBackground(), labels0);
    dma1chart = new DMABarChart("Receive (C2S) Performance", panel1.getBackground(), labels1);
    panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
    panel1.setSize(new Dimension(panel1.getWidth() - 100, panel1.getHeight() - 100));

    panel1.add(dma0chart.getChart(""));
    panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS));
    panel2.setSize(new Dimension(panel2.getWidth() - 100, panel2.getHeight() - 100));

    panel2.add(dma1chart.getChart(""));
    panel.add(panel1);//  w  w  w.  ja v  a2  s . c  om
    panel.add(panel2);
    return panel;
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

/**
 * @param nObj/* w  w w.java 2s.c  o  m*/
 * @param panel
 * @return true if a form was effectively rendered, i.e. when at least 1
 *         parameter was available
 * @throws IllegalActionException
 */
private boolean renderModelComponent(final boolean deep, final NamedObj nObj, final JPanel panel) {
    if (logger.isDebugEnabled()) {
        logger.debug("renderModelComponent() - Entity " + nObj.getFullName()); //$NON-NLS-1$ //$NON-NLS-2$
    }
    if (nObj instanceof CompositeActor && deep) {
        return renderCompositeModelComponent((CompositeActor) nObj, panel);
    } else {
        renderModelComponentAnnotations(nObj, panel);
        final IPasserelleEditorPaneFactory epf = getEditorPaneFactoryForComponent(nObj);
        Component component = null;
        // XXX: temp need to use the new isencia api
        final IPasserelleQuery passerelleQuery = epf.createEditorPaneWithAuthorizer(nObj, this, this);
        if (!passerelleQuery.hasAutoSync()) {
            try {
                final Set<ParameterToWidgetBinder> queryBindings = passerelleQuery.getParameterBindings();
                for (final ParameterToWidgetBinder parameterToWidgetBinder : queryBindings) {
                    hmiFields.put(parameterToWidgetBinder.getBoundParameter().getFullName(),
                            parameterToWidgetBinder);
                }
            } catch (final Exception exception) {
                throw new RuntimeException("Error creating bindings for passerelleQuery", exception);
            }
        }

        final IPasserelleComponent passerelleComponent = passerelleQuery.getPasserelleComponent();
        if (!(passerelleComponent instanceof Component)) {
            return false;
        }

        component = (Component) passerelleComponent;
        // System.out.println("renderModelComponent "+passerelleComponent);
        // Component c =
        // EditorPaneFactory.createEditorPaneWithAuthorizer(nObj, this,
        // this);
        if (component != null && !(component instanceof PasserelleEmptyQuery)) {
            final String name = ModelUtils.getFullNameButWithoutModelName(getCurrentModel(), nObj);
            component.setName(name);
            final JPanel globalPanel = new JPanel(new BorderLayout());

            // Panel for title
            final JPanel titlePanel = createTitlePanel(name);

            // Add a nice background to panels
            titlePanel.setBackground(panel.getBackground());
            ((JComponent) component).setBackground(panel.getBackground());
            // Border
            final Border loweredbevel = BorderFactory.createLoweredBevelBorder();
            final TitledBorder border = BorderFactory.createTitledBorder(loweredbevel/* ,name */);
            globalPanel.setBorder(border);

            globalPanel.add(titlePanel, BorderLayout.NORTH);
            globalPanel.add(component, BorderLayout.CENTER);
            panel.add(globalPanel);

            // StateMachine stuff
            StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, component);
            StateMachine.getInstance().compile();
            return true;
        }
        return false;
    }
}

From source file:com.xilinx.ultrascale.gui.MainScreen.java

public void loadAllGraphs() {

    JPanel PowerGraphPanel = createPanelForGraph(PowerPanel);
    chart1 = new PowerChart("Power (W)", PowerGraphPanel.getBackground());

    ChartPanel dialPanel;//from w  ww.  j av a2  s . co  m
    dialPanel = chart1.getChart("");
    dialPanel.setPreferredSize(new Dimension(300, 100));
    PowerGraphPanel.add(dialPanel);

    PowerPanel.add(PowerGraphPanel);

    // loading power graph and running timer
    if (screenMode == 3 || screenMode == 4) {
        String[] labels0 = { "S2C PCIe", "AXI Transmit Data Path 0", "AXI Transmit Data Path 1" };
        String[] labels2 = { "C2S PCIe", "AXI Receive Data Path 0", "AXI Receive Data Path 1" };
        chartTopEth = new BarChartsEth("", "", PowerGraphPanel.getBackground(), labels0);

        JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel2.add(chartTopEth.getChart(""));
        topChartperfpanel.add(PowerGraphPanel2);

        chartBottomEth = new BarChartsEth("", "", PowerGraphPanel.getBackground(), labels2);

        JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel3.add(chartBottomEth.getChart(""));
        bottomChartperfpanel.add(PowerGraphPanel3);

        // upper bounds for graphs
        if (screenMode == 3 || screenMode == 4 || screenMode == 7) {
            chartTopEth.upperBounds(35);
            chartBottomEth.upperBounds(35);
        }
    } else {
        if (screenMode == 7) {
            String[] labels0 = { "S2C PCIe", "S2C AXI" };
            String[] labels2 = { "C2S PCIe", "C2S AXI" };
            chartTop = new BarCharts("", "", PowerGraphPanel.getBackground(), labels0);

            JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
            PowerGraphPanel2.add(chartTop.getChart(""));
            topChartperfpanel.add(PowerGraphPanel2);

            chartBottom = new BarCharts("", "", PowerGraphPanel.getBackground(), labels2);

            JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
            PowerGraphPanel3.add(chartBottom.getChart(""));
            bottomChartperfpanel.add(PowerGraphPanel3);

            chartTop.upperBounds(32);
            chartBottom.upperBounds(32);
        } else {
            String[] labels0 = { "S2C PCIe", "DDR Writes" };
            String[] labels2 = { "C2S PCIe", "DDR Reads" };
            chartTop = new BarCharts("", "", PowerGraphPanel.getBackground(), labels0);

            JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
            PowerGraphPanel2.add(chartTop.getChart(""));
            topChartperfpanel.add(PowerGraphPanel2);

            chartBottom = new BarCharts("", "", PowerGraphPanel.getBackground(), labels2);

            JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
            PowerGraphPanel3.add(chartBottom.getChart(""));
            bottomChartperfpanel.add(PowerGraphPanel3);
        }
    }
    if (screenMode == 2) {

        chartTop.upperBounds(4);
        chartBottom.upperBounds(4);
    }
    updateStats();

}

From source file:com.floreantpos.main.SetUpWindow.java

protected void initUI() {
    getContentPane().setLayout(new BorderLayout()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JPanel databaseConfigPanel = new JPanel(new MigLayout("fill,hidemode 3", "[150px][fill, grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    databaseConfigPanel.setBorder(new TitledBorder(Messages.getString("SetUpWindow.3"))); //$NON-NLS-1$
    tfServerAddress = new POSTextField();
    tfServerPort = new POSTextField();
    tfDatabaseName = new POSTextField();
    tfUserName = new POSTextField();
    tfPassword = new POSPasswordField();
    databaseCombo = new JComboBox(Database.values());

    String databaseProviderName = AppConfig.getDatabaseProviderName();
    if (StringUtils.isNotEmpty(databaseProviderName)) {
        databaseCombo.setSelectedItem(Database.getByProviderName(databaseProviderName));
    }/* w  w w. j a v a2s . c  om*/
    btnTestConnection = new PosButton("Test"); //$NON-NLS-1$
    btnTestConnection.setActionCommand(TEST);

    btnCreateDb = new PosButton("Create New"); //$NON-NLS-1$
    btnCreateDb.setActionCommand(CREATE_DATABASE);

    btnCreateSampleData = new PosButton("Create sample data"); //$NON-NLS-1$
    btnCreateSampleData.setActionCommand(CREATE_SAMPLE_DATA);

    databaseConfigPanel.add(new JLabel(Messages.getString("DatabaseConfigurationDialog.8"))); //$NON-NLS-1$
    databaseConfigPanel.add(databaseCombo, "w 200!,grow, split 4"); //$NON-NLS-1$

    databaseConfigPanel.add(btnTestConnection, "w 50!,h 30!"); //$NON-NLS-1$
    databaseConfigPanel.add(btnCreateDb, "w 100!,h 30!"); //$NON-NLS-1$
    databaseConfigPanel.add(btnCreateSampleData, "h 30!,wrap"); //$NON-NLS-1$

    lblServerAddress = new JLabel(Messages.getString("DatabaseConfigurationDialog.10") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    databaseConfigPanel.add(lblServerAddress);
    databaseConfigPanel.add(tfServerAddress, "grow, split 3"); //$NON-NLS-1$
    lblServerPort = new JLabel("Port" + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    databaseConfigPanel.add(lblServerPort);
    tfServerPort.setHorizontalAlignment(JTextField.RIGHT);
    databaseConfigPanel.add(tfServerPort, "w 50!,wrap"); //$NON-NLS-1$
    lblDbName = new JLabel(Messages.getString("DatabaseConfigurationDialog.16") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    databaseConfigPanel.add(lblDbName);
    databaseConfigPanel.add(tfDatabaseName, "grow, wrap"); //$NON-NLS-1$
    lblUserName = new JLabel(Messages.getString("DatabaseConfigurationDialog.19") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    databaseConfigPanel.add(lblUserName);
    databaseConfigPanel.add(tfUserName, "grow, split 3"); //$NON-NLS-1$
    lblDbPassword = new JLabel("Password" + ":"); //$NON-NLS-1$ //$NON-NLS-2$
    databaseConfigPanel.add(lblDbPassword);
    databaseConfigPanel.add(tfPassword, "grow, wrap"); //$NON-NLS-1$

    btnSave = new PosButton(Messages.getString("DatabaseConfigurationDialog.27").toUpperCase()); //$NON-NLS-1$
    btnSave.setActionCommand(SAVE);
    btnExit = new PosButton(Messages.getString("DatabaseConfigurationDialog.28").toUpperCase()); //$NON-NLS-1$
    btnExit.setActionCommand(CANCEL);

    JPanel buttonPanel = new JPanel(new MigLayout("fillx,right")); //$NON-NLS-1$

    buttonPanel.add(btnSave, "h 40!,split 2,right"); //$NON-NLS-1$
    buttonPanel.add(btnExit, "h 40!"); //$NON-NLS-1$

    JPanel contentPanel = new JPanel(new MigLayout("fillx")); //$NON-NLS-1$
    contentPanel.add(databaseConfigPanel, "grow,wrap"); //$NON-NLS-1$
    //contentPanel.add(createUserPanel(), "grow,wrap");
    contentPanel.add(createTerminalConfigPanel(), "grow,wrap"); //$NON-NLS-1$
    getContentPane().add(new JideScrollPane(contentPanel), BorderLayout.CENTER); //$NON-NLS-1$
    getContentPane().add(buttonPanel, BorderLayout.SOUTH); //$NON-NLS-1$

    getContentPane().setBackground(databaseConfigPanel.getBackground());
}

From source file:com.xilinx.ultrascale.gui.MainScreen_video.java

public void loadAllGraphs() {

    JPanel PowerGraphPanel = createPanelForGraph(PowerPanel);
    chart1 = new PowerChart("Power (W)", PowerGraphPanel.getBackground());

    ChartPanel dialPanel;//from  w w w .  j  a  v a 2s. c om
    dialPanel = chart1.getChart("");
    dialPanel.setPreferredSize(new Dimension(300, 100));
    PowerGraphPanel.add(dialPanel);

    PowerPanel.add(PowerGraphPanel);

    // loading power graph and running timer
    if (screenMode == 3 || screenMode == 4) {
        String[] labels0 = { "S2C PCIe", "AXI Writes Data Path 0", "AXI Writes Data Path 1" };
        String[] labels2 = { "C2S PCIe", "AXI Reads Data Path 0", "AXI Reads Data Path 1" };
        chartTopEth = new BarChartsEth("", "", PowerGraphPanel.getBackground(), labels0);

        JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel2.add(chartTopEth.getChart(""));
        topChartperfpanel.add(PowerGraphPanel2);

        chartBottomEth = new BarChartsEth("", "", PowerGraphPanel.getBackground(), labels2);

        JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel3.add(chartBottomEth.getChart(""));
        bottomChartperfpanel.add(PowerGraphPanel3);

    } else if (screenMode == 7) {
        String[] labels0 = { "S2C PCIe", "S2C AXI" };
        String[] labels2 = { "C2S PCIe", "C2S AXI" };
        chartTop = new BarCharts("", "", PowerGraphPanel.getBackground(), labels0);

        JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel2.add(chartTop.getChart(""));
        topChartperfpanel.add(PowerGraphPanel2);

        chartBottom = new BarCharts("", "", PowerGraphPanel.getBackground(), labels2);

        JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel3.add(chartBottom.getChart(""));
        bottomChartperfpanel.add(PowerGraphPanel3);

        chartTop.upperBounds(32);
        chartBottom.upperBounds(32);
    } else {
        String[] labels0 = { "S2C PCIe", "DDR Writes" };
        String[] labels2 = { "C2S PCIe", "DDR Reads" };
        chartTop = new BarCharts("", "", PowerGraphPanel.getBackground(), labels0);

        JPanel PowerGraphPanel2 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel2.add(chartTop.getChart(""));
        topChartperfpanel.add(PowerGraphPanel2);

        chartBottom = new BarCharts("", "", PowerGraphPanel.getBackground(), labels2);

        JPanel PowerGraphPanel3 = createPanelForGraph(topChartperfpanel);
        PowerGraphPanel3.add(chartBottom.getChart(""));
        bottomChartperfpanel.add(PowerGraphPanel3);
    }
    // upper bounds for graphs
    if (screenMode == 3 || screenMode == 4) {
        chartTopEth.upperBounds(35);
        chartBottomEth.upperBounds(35);
    }
    if (screenMode == 7) {
        chartTop.upperBounds(35);
        chartBottom.upperBounds(35);
    }
    if (screenMode == 2) {

        chartTop.upperBounds(4);
        chartBottom.upperBounds(4);
    }
    updateStats();
}

From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java

/** 
 * Builds hosting the various sliders//from   www  . j a  va  2  s. c  o m
 * 
 * @return See above.
 */
private JPanel buildGeneralPane() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridy = 0;
    c.gridx = 0;
    if (model.isGeneralIndex()) {
        content.add(previewToolBar, c);
        c.gridy++;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.HORIZONTAL;
        content.add(new JSeparator(), c);
        c.gridy++;
    }
    content.add(controlsBar, c);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;

    Iterator<ChannelSlider> i = sliders.iterator();
    while (i.hasNext()) {
        c.gridy++;
        content.add(i.next(), c);
    }
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    content.add(viewedBy, c);
    JPanel p = UIUtilities.buildComponentPanel(content);
    p.setBackground(content.getBackground());
    return p;
}

From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java

/** Builds and lays out the UI. */
private void buildGUI() {
    JPanel barPane = new JPanel();
    barPane.setOpaque(false);/* www.  ja va 2  s.c  o  m*/
    barPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    double[][] size = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.PREFERRED } };
    barPane.setLayout(new TableLayout(size));
    barPane.add(type, "0, 0, LEFT, CENTER");
    barPane.add(messageLabel, "0, 1, CENTER, CENTER");

    //icon, message, content, toolbar
    double[][] tl = { { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED },
            { TableLayout.PREFERRED } };
    setLayout(new TableLayout(tl));
    add(statusPane, "0, 0");
    JPanel p = UIUtilities.buildComponentPanel(barPane);
    p.setOpaque(false);
    p.setBackground(barPane.getBackground());
    add(p, "1, 0");
    paneIndex = "2, 0";
    add(resultPane, paneIndex);
    add(createToolBar(), "3, 0");
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

protected void createUI() {
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    tabPane = new JTabbedPane();
    add(tabPane, BorderLayout.CENTER);

    // General pane
    JPanel generalPane = new JPanel();
    tabPane.addTab("General", generalPane);

    // Create the fields & their labels

    // Photographer field
    JLabel photographerLabel = new JLabel("Photographer");
    photographerField = createMvTextField("photographer", 30);
    photographerDoc = photographerField.getDocument();

    // "Fuzzy time" field
    JLabel fuzzyDateLabel = new JLabel("Shooting date");
    fuzzyDateField = new JTextField(30);
    fuzzyDateDoc = fuzzyDateField.getDocument();
    fuzzyDateDoc.putProperty(FIELD, PhotoInfoFields.FUZZY_SHOOT_TIME);
    fuzzyDateDoc.addDocumentListener(this);

    JLabel qualityLabel = new JLabel("Quality");
    qualityField = new JComboBox(qualityStrings);
    qualityField.addActionListener(this);

    StarRating qualityStars = new StarRating(5);
    FieldController<Integer> qfCtrl = ctrl.getFieldController("quality");
    ValueModel qualityFieldValue = new PropertyAdapter(qfCtrl, "value", true);
    ValueModel starCount = new PropertyAdapter(qualityStars, "selection", true);
    PropertyConnector.connect(qualityFieldValue, "value", starCount, "value");

    // Shooting place field
    JLabel shootingPlaceLabel = new JLabel("Shooting place");
    shootingPlaceField = createMvTextField("shotLocation.description", 30);
    shootingPlaceDoc = shootingPlaceField.getDocument();
    JLabel shotLocRoadLabel = new JLabel("Road");
    JTextField shotLocRoadField = createMvTextField("shotLocation.road", 30);
    JLabel shotLocSuburbLabel = new JLabel("Suburb");
    JTextField shotLocSuburbField = createMvTextField("shotLocation.suburb", 30);
    JLabel shotLocCityLabel = new JLabel("City");
    JTextField shotLocCityField = createMvTextField("shotLocation.city", 30);
    JLabel shotLocCountryLabel = new JLabel("Country");
    JTextField shotLocCountryField = createMvTextField("shotLocation.country", 30);
    JLabel shotLocGeohashLabel = new JLabel("Geohash code");
    JTextField shotLocGeohashField = createMvTextField("shotLocation.geoHashString", 30);
    shotLocGeohashField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "fillAddress");
    shotLocGeohashField.getActionMap().put("fillAddress", new FindAddressAction(ctrl));

    // Tags/*from  www . j a  v a2 s.  c o m*/
    JLabel tagLabel = new JLabel("Tags");
    tagList = new TagList2(ctrl.getTagController());
    tagList.setBackground(generalPane.getBackground());

    // Description text
    JLabel descLabel = new JLabel("Description");
    descriptionTextArea = new JTextArea(5, 40);
    descriptionTextArea.setLineWrap(true);
    descriptionTextArea.setWrapStyleWord(true);
    JScrollPane descScrollPane = new JScrollPane(descriptionTextArea);
    descScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    Border descBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    descBorder = BorderFactory.createTitledBorder(descBorder, "Description");
    descScrollPane.setBorder(descBorder);
    descriptionDoc = descriptionTextArea.getDocument();
    descriptionDoc.putProperty(FIELD, PhotoInfoFields.DESCRIPTION);
    descriptionDoc.addDocumentListener(this);

    // Lay out the created controls
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    generalPane.setLayout(layout);
    JLabel[] labels = { photographerLabel, fuzzyDateLabel, shootingPlaceLabel, shotLocGeohashLabel,
            shotLocRoadLabel, shotLocSuburbLabel, shotLocCityLabel, shotLocCountryLabel, qualityLabel,
            tagLabel };
    JComponent[] fields = { photographerField, fuzzyDateField, shootingPlaceField, shotLocGeohashField,
            shotLocRoadField, shotLocSuburbField, shotLocCityField, shotLocCountryField, qualityStars,
            tagList };
    addLabelTextRows(labels, fields, layout, generalPane);
    c = layout.getConstraints(tagList);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;
    c.weighty = 1.0;
    layout.setConstraints(tagList, c);

    generalPane.add(descScrollPane);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    layout.setConstraints(descScrollPane, c);

    c = new GridBagConstraints();
    c.gridwidth = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridy = GridBagConstraints.RELATIVE;

    c.gridy = GridBagConstraints.RELATIVE;

    createTechDataUI();
    createFolderPaneUI();
    createRightsUI();
}