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:SpringCompactGrid.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from   w w w  .  j av a  2  s  .  co m
 */
private static void createAndShowGUI() {
    JPanel panel = new JPanel(new SpringLayout());

    int rows = 10;
    int cols = 10;
    for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
            int anInt = (int) Math.pow(r, c);
            JTextField textField = new JTextField(Integer.toString(anInt));
            panel.add(textField);
        }
    }

    //Lay out the panel.
    SpringUtilities.makeCompactGrid(panel, //parent
            rows, cols, 3, 3, //initX, initY
            3, 3); //xPad, yPad

    //Create and set up the window.
    JFrame frame = new JFrame("SpringCompactGrid");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Set up the content pane.
    panel.setOpaque(true); //content panes must be opaque
    frame.setContentPane(panel);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public TestPane() {
    setLayout(new BorderLayout());
    JPanel top = new JPanel(new GridBagLayout());
    top.setOpaque(false);
    top.add(new JLabel("OK"));
    JScrollPane sp = new JScrollPane();
    sp.setOpaque(false);/*  w  ww  . ja v  a 2s . co  m*/
    sp.getViewport().setOpaque(false);
    sp.setViewportView(top);
    add(sp);
}

From source file:JDK6TabbedPaneExample.java

public void add() {
    final JPanel content = new JPanel();
    JPanel tab = new JPanel();
    tab.setOpaque(false);

    JLabel tabLabel = new JLabel("Tab " + (++tabCounter));

    JButton tabCloseButton = new JButton(closeXIcon);
    tabCloseButton.setPreferredSize(closeButtonSize);
    tabCloseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int closeTabNumber = tabbedPane.indexOfComponent(content);
            tabbedPane.removeTabAt(closeTabNumber);
        }//from   w  ww.j  ava2  s. c  om
    });

    tab.add(tabLabel, BorderLayout.WEST);
    tab.add(tabCloseButton, BorderLayout.EAST);

    tabbedPane.addTab(null, content);
    tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, tab);
}

From source file:Main.java

public Main() {
    setSize(300, 300);/*w  ww . j  a  v a 2  s  .  c  om*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel controlPane = new JPanel(new GridLayout(2, 1));
    controlPane.setOpaque(false);
    controlPane.add(new JLabel("Please wait..."));
    controlPane.add(waiter);
    glass.setOpaque(false);
    glass.add(padding);
    glass.add(new JLabel());
    glass.add(controlPane);
    glass.add(new JLabel());
    glass.add(new JLabel());
    glass.setSize(new Dimension(300, 300));

    setGlassPane(glass);

    JButton startB = new JButton("Start!");

    startB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent A) {
            glass.setVisible(true);
            padding.requestFocus();
        }
    });
    Container contentPane = getContentPane();
    contentPane.add(startB, BorderLayout.SOUTH);
}

From source file:SpringCompactGrid.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from   w w w . jav a 2 s.  com
private static void createAndShowGUI() {
    JPanel panel = new JPanel(new SpringLayout());

    int rows = 10;
    int cols = 10;
    for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
            int anInt = (int) Math.pow(r, c);
            JTextField textField = new JTextField(Integer.toString(anInt));
            panel.add(textField);
        }
    }

    //Lay out the panel.
    SpringUtilities.makeCompactGrid(panel, //parent
            rows, cols, 3, 3, //initX, initY
            3, 3); //xPad, yPad

    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("SpringCompactGrid");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Set up the content pane.
    panel.setOpaque(true); //content panes must be opaque
    frame.setContentPane(panel);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    super("JLayeredPane Demo");
    setSize(256, 256);/*  w  w w. ja v a  2s  .  c  om*/

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    content.setOpaque(false);

    JLabel label1 = new JLabel("Username:");
    label1.setForeground(Color.white);
    content.add(label1);

    JTextField field = new JTextField(15);
    content.add(field);

    JLabel label2 = new JLabel("Password:");
    label2.setForeground(Color.white);
    content.add(label2);

    JPasswordField fieldPass = new JPasswordField(15);
    content.add(fieldPass);

    setLayout(new FlowLayout());
    add(content);
    ((JPanel) getContentPane()).setOpaque(false);

    ImageIcon earth = new ImageIcon("largeJava2sLogo.png");
    JLabel backlabel = new JLabel(earth);
    getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
    backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight());
    super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
}

From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java

private JPanel createTransparentFillerPanel() {
    JPanel panel = new JPanel();
    panel.setSize(645, 50);//from w  w  w.  ja  v  a 2 s . c  o  m
    panel.setOpaque(false);
    panel.setBorder(null);
    return panel;
}

From source file:MainClass.java

public JPanel createNested(boolean opaque) {
    JPanel outer = new JPanel(new FlowLayout());
    JPanel inner = new JPanel(new FlowLayout());
    outer.setBackground(Color.white);
    inner.setBackground(Color.black);

    inner.setOpaque(opaque);
    inner.setBorder(BorderFactory.createLineBorder(Color.gray));

    inner.add(new JButton("Button"));
    outer.add(inner);/*from  w  w w. ja  v a  2 s.c  om*/

    return outer;
}

From source file:FramewithComponents.java

public FramewithComponents() {
    super("JLayeredPane Demo");
    setSize(256, 256);/*from   ww  w  .  ja  v  a  2s  . co m*/

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    content.setOpaque(false);

    JLabel label1 = new JLabel("Username:");
    label1.setForeground(Color.white);
    content.add(label1);

    JTextField field = new JTextField(15);
    content.add(field);

    JLabel label2 = new JLabel("Password:");
    label2.setForeground(Color.white);
    content.add(label2);

    JPasswordField fieldPass = new JPasswordField(15);
    content.add(fieldPass);

    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(content);
    ((JPanel) getContentPane()).setOpaque(false);

    ImageIcon earth = new ImageIcon("largeJava2sLogo.png");
    JLabel backlabel = new JLabel(earth);
    getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
    backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight());

    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);

    setVisible(true);
}

From source file:com.willwinder.ugs.nbp.core.services.SettingsChangedNotificationService.java

private JComponent createRestartNotificationDetails() {
    JPanel panel = new JPanel(new BorderLayout(10, 10));
    panel.setOpaque(false);

    JLabel label = new JLabel(Localization.getString("platform.window.restart.changed.settings")); //NOI18N
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    panel.add(label, BorderLayout.CENTER);

    label.addMouseListener(new MouseAdapter() {
        @Override//w w w. j  a v a 2s.  c o  m
        public void mouseClicked(MouseEvent e) {
            if (null != restartNotification) {
                restartNotification.clear();
                restartNotification = null;
            }

            LifecycleManager.getDefault().markForRestart();
            LifecycleManager.getDefault().exit();
        }
    });
    return panel;
}