Example usage for javax.swing JPanel setOpaque

List of usage examples for javax.swing JPanel setOpaque

Introduction

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

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the <code>comment</code> details.
 * /*from  w  w  w .  j  a  v a2s  . co m*/
 * @param comment      The comment's text.
 * @param mnemonic       The key-code that indicates a mnemonic key.
 * @return See above.
 */
private JPanel buildCommentAreaPanel(String comment, int mnemonic) {
    JPanel panel = new JPanel();
    panel.setOpaque(false);

    double size[][] = { { TableLayout.FILL }, { 20, TableLayout.FILL } };
    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);
    JScrollPane areaScrollPane = new JScrollPane(commentArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JLabel label = new JLabel(comment);
    label.setOpaque(false);
    label.setDisplayedMnemonic(mnemonic);
    panel.add(label, "0, 0, LEFT, CENTER");
    panel.add(areaScrollPane, "0, 1");
    return panel;
}

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the <code>email</code> details.
 * /*from   www  . ja  v a 2  s .  co m*/
 * @param mnemonic The key-code that indicates a mnemonic key.
 * @return See above.
 */
private JPanel buildEmailAreaPanel(int mnemonic) {
    double[][] size = null;

    JPanel panel = new JPanel();
    panel.setOpaque(false);

    if (EMAIL_SUFFIX.length() == 0)
        size = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL }, { 30 } };
    else
        size = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } };

    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);

    JLabel label = new JLabel(EMAIL_FIELD);
    label.setDisplayedMnemonic(mnemonic);
    label.setLabelFor(emailArea);
    label.setOpaque(false);

    panel.add(label, "0, 0, RIGHT, CENTER");
    panel.add(emailArea, "1, 0, FULL, CENTER");

    if (EMAIL_SUFFIX.length() != 0)
        panel.add(new JLabel(EMAIL_SUFFIX), "2, 0, LEFT, CENTER");

    return panel;
}

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the debug information.
 * //from ww  w.  j  a v  a 2 s  . c o  m
 * @return See above.
 */
private JPanel buildDebugPane() {
    JPanel panel = new JPanel();
    //panel.setBackground(UIUtilities.WINDOW_BACKGROUND_COLOR);
    panel.setOpaque(false);
    double tableSize[][] = { { TableLayout.FILL }, // columns
            { TableLayout.FILL, 32 } }; // rows
    TableLayout layout = new TableLayout(tableSize);
    panel.setLayout(layout);
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JScrollPane pane = new JScrollPane(debugArea);
    //pane.setBackground(UIUtilities.WINDOW_BACKGROUND_COLOR);
    panel.add(pane, "0, 0");
    panel.add(copyButton, "0, 1, CENTER, BOTTOM");
    return panel;
}

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the collection of files to submit.
 * //from w  ww.j av a  2 s .c  o  m
 * @return See above.
 */
private JPanel buildFilesToSubmitPane(List<ImportErrorObject> toSubmit) {
    JPanel panel = new JPanel();
    //panel.setBackground(UIUtilities.WINDOW_BACKGROUND_COLOR);
    panel.setOpaque(false);

    double tableSize[][] = { { TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows
    TableLayout layout = new TableLayout(tableSize);
    panel.setLayout(layout);
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    table = new FileTable(toSubmit);
    JScrollPane pane = new JScrollPane(table);
    //pane.setBackground(UIUtilities.WINDOW_BACKGROUND_COLOR);
    panel.add(pane, "0, 0");
    return panel;
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Adds the specified {@link JComponent} to a {@link JPanel} 
 * with a left flow layout./*from w ww.j a v a  2 s  .  co m*/
 * 
 * @param component The component to add.
 * @param hgap       The horizontal gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @param vgap       The vertical gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @param isOpaque  Pass <code>true</code> if this component should be 
 *                opaque, <code>false</code> otherwise.
 * @return See below.
 */
public static JPanel buildComponentPanel(JComponent component, int hgap, int vgap, boolean isOpaque) {
    JPanel p = new JPanel();
    if (component == null)
        return p;
    if (hgap < 0)
        hgap = 0;
    if (vgap < 0)
        vgap = 0;
    p.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
    p.add(component);
    p.setOpaque(isOpaque);
    return p;
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Adds the specified {@link JComponent} to a {@link JPanel} 
 * with a right flow layout.// w  w  w.  j  a  v a2s  . co  m
 * 
 * @param component The component to add.
 * @param hgap       The horizontal gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @param vgap       The vertical gap between components and between the 
 *                components and the borders of the 
 *                <code>Container</code>.
 * @param isOpaque  Pass <code>true</code> if this component should be 
 *                opaque, <code>false</code> otherwise.
 * @return See below.
 */
public static JPanel buildComponentPanelRight(JComponent component, int hgap, int vgap, boolean isOpaque) {
    JPanel p = new JPanel();
    if (component == null)
        return p;
    if (hgap < 0)
        hgap = 0;
    if (vgap < 0)
        vgap = 0;
    p.setLayout(new FlowLayout(FlowLayout.RIGHT, hgap, vgap));
    p.add(component);
    p.setOpaque(isOpaque);
    return p;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

public PreviewPane(final boolean init) {
    messages = new Messages(getLocale(), SwingPreviewModule.BUNDLE_NAME,
            ObjectUtilities.getClassLoader(SwingPreviewModule.class));
    sizeLimiter = new WindowSizeLimiter();
    zoomActions = new HashMap<ActionCategory, ZoomAction[]>();

    this.menus = PreviewPane.EMPTY_MENU;
    setLayout(new BorderLayout());

    zoomModel = new KeyedComboBoxModel();
    zoomModel.setAllowOtherValue(true);/*from  ww  w. j  a  v a 2s  . com*/
    zoom = PreviewPane.ZOOM_FACTORS[PreviewPane.DEFAULT_ZOOM_INDEX];

    final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
    minZoom = getMinimumZoom(configuration);
    maxZoom = getMaximumZoom(configuration);

    pageDrawable = new PageBackgroundDrawable();

    drawablePanel = new PreviewDrawablePanel();
    drawablePanel.setOpaque(false);
    drawablePanel.setBackground(null);
    drawablePanel.setDoubleBuffered(true);
    drawablePanel.setDrawableAsRawObject(pageDrawable);
    drawablePanel.addReportMouseListener(new HyperLinkEventProcessor());

    swingGuiContext = new PreviewGuiContext();

    final JPanel reportPaneHolder = new ScrollablePanel();
    reportPaneHolder.setOpaque(false);
    reportPaneHolder.setBackground(null);
    reportPaneHolder.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    reportPaneHolder.add(drawablePanel);

    reportPaneScrollPane = new JScrollPane(reportPaneHolder);
    reportPaneScrollPane.getVerticalScrollBar().setUnitIncrement(20);
    reportPaneScrollPane.setBackground(null);
    reportPaneScrollPane.setOpaque(false);
    reportPaneScrollPane.getViewport().setOpaque(false);
    ((JComponent) reportPaneScrollPane.getViewport().getView()).setOpaque(false);

    toolbarHolder = new JPanel();
    toolbarHolder.setLayout(new BorderLayout());

    outerReportControllerHolder = new JPanel();
    outerReportControllerHolder.setOpaque(false);
    outerReportControllerHolder.setBackground(null);
    outerReportControllerHolder.setLayout(new BorderLayout());
    outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
    outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
    add(outerReportControllerHolder, BorderLayout.CENTER);

    addPropertyChangeListener(new PreviewUpdateHandler());
    addPropertyChangeListener("zoom", new UpdateZoomHandler()); //$NON-NLS-1$
    statusListener = new PreviewPaneStatusListener();

    zoomSelectorBox = createZoomSelector(this);
    setReportController(new ParameterReportController());
    if (init) {
        initializeWithoutJob();
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

private void refreshReportController(final ReportController newReportController) {
    for (int i = 0; i < outerReportControllerHolder.getComponentCount(); i++) {
        final Component maybeSplitPane = outerReportControllerHolder.getComponent(i);
        if (maybeSplitPane instanceof JSplitPane) {
            final JSplitPane splitPane = (JSplitPane) maybeSplitPane;
            reportControllerSliderSize = splitPane.getDividerLocation();
            break;
        }/*from w ww  .j a  v  a2 s.  co m*/
    }

    if (newReportController == null) {
        if (reportControllerComponent != null) {
            // thats relatively easy.
            outerReportControllerHolder.removeAll();
            outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
            outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
            reportControllerComponent = null;
            reportControllerInner = false;
            reportControllerLocation = null;
        }
    } else {
        final JComponent rcp = newReportController.getControlPanel();
        if (rcp == null) {
            if (reportControllerComponent != null) {
                outerReportControllerHolder.removeAll();
                outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
                outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
                reportControllerComponent = null;
                reportControllerInner = false;
                reportControllerLocation = null;
            }
        } else if (reportControllerComponent != rcp
                || reportControllerInner != newReportController.isInnerComponent()
                || ObjectUtilities.equal(reportControllerLocation,
                        newReportController.getControllerLocation()) == false) {
            // if either the controller component or its position (inner vs outer)
            // and border-position has changed, then refresh ..
            this.reportControllerLocation = newReportController.getControllerLocation();
            this.reportControllerInner = newReportController.isInnerComponent();
            this.reportControllerComponent = newReportController.getControlPanel();

            outerReportControllerHolder.removeAll();
            if (reportControllerInner) {
                final JSplitPane innerHolder = new JSplitPane();
                innerHolder.setOpaque(false);
                if (BorderLayout.SOUTH.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setTopComponent(reportPaneScrollPane);
                    innerHolder.setBottomComponent(reportControllerComponent);
                } else if (BorderLayout.EAST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setLeftComponent(reportPaneScrollPane);
                    innerHolder.setRightComponent(reportControllerComponent);
                } else if (BorderLayout.WEST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setRightComponent(reportPaneScrollPane);
                    innerHolder.setLeftComponent(reportControllerComponent);
                } else {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setBottomComponent(reportPaneScrollPane);
                    innerHolder.setTopComponent(reportControllerComponent);
                }

                if (reportControllerSliderSize > 0) {
                    innerHolder.setDividerLocation(reportControllerSliderSize);
                }
                outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
                outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
            } else {
                final JPanel reportPaneHolder = new JPanel();
                reportPaneHolder.setOpaque(false);
                reportPaneHolder.setLayout(new BorderLayout());
                reportPaneHolder.add(toolbarHolder, BorderLayout.NORTH);
                reportPaneHolder.add(reportPaneScrollPane, BorderLayout.CENTER);

                final JSplitPane innerHolder = new JSplitPane();
                if (BorderLayout.SOUTH.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setTopComponent(reportPaneHolder);
                    innerHolder.setBottomComponent(reportControllerComponent);
                } else if (BorderLayout.EAST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setLeftComponent(reportPaneHolder);
                    innerHolder.setRightComponent(reportControllerComponent);
                } else if (BorderLayout.WEST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setRightComponent(reportPaneHolder);
                    innerHolder.setLeftComponent(reportControllerComponent);
                } else {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setBottomComponent(reportPaneHolder);
                    innerHolder.setTopComponent(reportControllerComponent);
                }
                if (reportControllerSliderSize > 0) {
                    innerHolder.setDividerLocation(reportControllerSliderSize);
                }
                outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
            }
        }
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

private void createDialog() {

    if (getParent() instanceof XulDialog) {
        Object parentObj = ((SwingDialog) getParent()).getDialog();
        dialog = new JDialog((Dialog) parentObj);
        centerComp = (Component) parentObj;
    } else if (getParent() instanceof XulWindow) {

        Object parentObj = getParent().getManagedObject();
        dialog = new JDialog((Frame) parentObj);
        centerComp = (Component) parentObj;
    } else {/* w w  w.j a  v  a  2s. c  om*/

        Document doc = getDocument();
        Element rootElement = doc.getRootElement();
        XulWindow window = null;
        if (rootElement != this) { // dialog is root, no JFrame Parent
            window = (XulWindow) rootElement;
        }

        if (window != null) {
            frame = (JFrame) window.getManagedObject();
            dialog = new JDialog(frame);
            centerComp = frame;
        } else {

            final Object context = domContainer.getOuterContext();
            if (context instanceof JFrame) {
                frame = (JFrame) context;
                centerComp = (Component) context;
                dialog = new JDialog(frame);
            } else if (context instanceof JDialog) {
                dialog = new JDialog((JDialog) context);
                centerComp = (Component) context;
            } else if (context instanceof JComponent) {
                dialog = new JDialog();
                centerComp = (Component) context;
            } else {
                dialog = new JDialog();
            }
        }
    }

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setResizable(getResizable());
    dialog.setLayout(new BorderLayout());

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setOpaque(true);
    int pad = (this.getPadding() > -1) ? getPadding() : 3;
    mainPanel.setBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad));

    dialog.setTitle(title);
    dialog.setModal(isModal());
    dialog.add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(container, BorderLayout.CENTER);
    container.setOpaque(false);

    if (this.header != null) {

        JPanel headerPanel = new JPanel(new BorderLayout());
        headerPanel.setBackground(Color.decode("#5F86C0"));
        headerPanel.setOpaque(true);
        JPanel headerPanelInner = new JPanel(new BorderLayout());
        headerPanelInner.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
        headerPanelInner.setOpaque(false);

        headerPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.decode("#8FB1E5"),
                Color.decode("#446CA9")));

        JLabel title = new JLabel(this.header.getTitle());

        title.setForeground(Color.white);
        headerPanelInner.add(title, BorderLayout.WEST);

        JLabel desc = new JLabel(this.header.getDescription());
        desc.setForeground(Color.white);
        headerPanelInner.add(desc, BorderLayout.EAST);

        headerPanel.add(headerPanelInner, BorderLayout.CENTER);

        mainPanel.add(headerPanel, BorderLayout.NORTH);
    }

    populateButtonPanel();
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setSize(new Dimension(getWidth(), getHeight()));
    dialog.setPreferredSize(new Dimension(getWidth(), getHeight()));
    dialog.setMinimumSize(new Dimension(getWidth(), getHeight()));

    if (this.getBgcolor() != null) {
        mainPanel.setBackground(Color.decode(this.getBgcolor()));
    }

}

From source file:org.piraso.ui.base.PreferencePanel.java

private void initPreferenceComponentsHorizontalChildLayout() {
    handlers = new ArrayList<ParentChildHandler>();
    CellConstraints c = new CellConstraints();

    int size = CollectionUtils.size(provider.getPreferences());

    int l = 0, r = 2;
    chkPreferences = new JCheckBox[size];
    preferenceKeys = new PreferenceProperty[size];

    JLabel lblHeader = new JLabel(provider.getName());
    Font of = lblHeader.getFont();
    lblHeader.setFont(of.deriveFont(Font.BOLD));

    pnlPreferences.add(lblHeader, c.xyw(2, r, 5));
    r += 2;/*ww  w.j  a v  a  2 s . com*/

    JButton parentToggle = null;
    JPanel childrenPanel = null;
    ParentChildHandler parentChildHandler = null;

    Iterator<? extends PreferenceProperty> itrp = provider.getPreferences().iterator();
    for (int j = 0; j < provider.getPreferences().size(); j++, l++) {
        PreferenceProperty prop = itrp.next();

        preferenceKeys[l] = prop;
        chkPreferences[l] = new JCheckBox();
        chkPreferences[l].setText(provider.getMessage(prop.getName()));
        chkPreferences[l].setSelected(prop.isDefaultValue());

        if (prop.isChild()) {
            if (childrenPanel == null) {
                childrenPanel = new JPanel();
                childrenPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
                childrenPanel.setOpaque(false);
                childrenPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 1));
                childrenPanel.setVisible(false);

                if (parentChildHandler != null) {
                    parentChildHandler.setChildrenPanel(childrenPanel);
                }

                pnlPreferences.add(childrenPanel, c.xy(6, r));

                r += 2;
            }

            if (parentChildHandler != null) {
                parentChildHandler.addPreference(chkPreferences[l]);
            }

            childrenPanel.add(chkPreferences[l]);
            parentToggle = null;
        } else {
            if (parentToggle != null) {
                parentChildHandler.hide();
            }

            JPanel parentPanel = new JPanel();
            parentPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
            parentPanel.setOpaque(false);

            parentToggle = new JButton(expandImage);

            JLabel previewLabel = new JLabel();
            previewLabel.setForeground(new Color(0, 128, 0));
            previewLabel.setFont(previewLabel.getFont().deriveFont(Font.ITALIC));

            parentChildHandler = new ParentChildHandler(parentToggle, previewLabel);
            parentChildHandler.addPreference(chkPreferences[l]);
            handlers.add(parentChildHandler);

            parentToggle.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));

            parentPanel.add(parentToggle);
            parentPanel.add(chkPreferences[l]);
            parentPanel.add(previewLabel);

            pnlPreferences.add(parentPanel, c.xyw(4, r, 3));

            childrenPanel = null;
            r += 2;
        }

        chkPreferences[l].addActionListener(new CheckBoxClickHandler(l, parentChildHandler));
    }
}