Example usage for javax.swing JLayeredPane PALETTE_LAYER

List of usage examples for javax.swing JLayeredPane PALETTE_LAYER

Introduction

In this page you can find the example usage for javax.swing JLayeredPane PALETTE_LAYER.

Prototype

Integer PALETTE_LAYER

To view the source code for javax.swing JLayeredPane PALETTE_LAYER.

Click Source Link

Document

Convenience object defining the Palette layer.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);//from   w  w w  .j a va  2 s.c om
    desktop.add(new SelfInternalFrame("1"), JLayeredPane.POPUP_LAYER);
    desktop.add(new SelfInternalFrame("2"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(new SelfInternalFrame("3"), JLayeredPane.PALETTE_LAYER);

    f.add(desktop, BorderLayout.CENTER);
    f.setSize(300, 200);
    f.setVisible(true);
}

From source file:InternalTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);//ww w .j av  a2 s .co m
    desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER);
    desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER);
    contentPane.add(desktop, BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.show();
}

From source file:InternalFrameTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Internal Frame Listener");
    Container contentPane = frame.getContentPane();
    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);/*from  w w w.  j a v  a2s.  co  m*/
    desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER);
    desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER);
    contentPane.add(desktop, BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.show();
}

From source file:InternalFrameEventTest.java

public static void main(String[] a) {

    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();

    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);//from w  w w . j  av  a 2  s .co  m
    contentPane.add(desktop, BorderLayout.CENTER);
    desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER);
    desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER);

    frame.setSize(400, 200);
    frame.setVisible(true);

}

From source file:JavaXWin.java

public JavaXWin() {
    setTitle("JavaXWin");
    m_count = m_tencount = 0;/*from  ww  w.  j  a  v a2s .com*/
    m_desktop = new JDesktopPane();

    JScrollPane scroller = new JScrollPane();
    m_wm = new WindowManager(m_desktop);
    m_desktop.setDesktopManager(m_wm);
    m_desktop.add(m_wm.getWindowWatcher(), JLayeredPane.PALETTE_LAYER);
    m_wm.getWindowWatcher().setBounds(555, 5, 200, 150);

    viewport = new JViewport() {
        public void setViewPosition(Point p) {
            super.setViewPosition(p);
            m_wm.getWindowWatcher().setLocation(m_wm.getWindowWatcher().getX() + (getViewPosition().x - m_wmX),
                    m_wm.getWindowWatcher().getY() + (getViewPosition().y - m_wmY));
            m_wmX = getViewPosition().x;
            m_wmY = getViewPosition().y;
        }
    };
    viewport.setView(m_desktop);
    scroller.setViewport(viewport);

    ComponentAdapter ca = new ComponentAdapter() {
        JViewport view = viewport;

        public void componentResized(ComponentEvent e) {
            m_wm.getWindowWatcher().setLocation(
                    view.getViewPosition().x + view.getWidth() - m_wm.getWindowWatcher().getWidth() - 15,
                    view.getViewPosition().y + 5);
        }
    };
    viewport.addComponentListener(ca);

    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newFrame();
        }
    });

    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", scroller);

    topPanel.add(m_newFrame);

    Dimension dim = getToolkit().getScreenSize();
    setSize(800, 600);
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    m_desktop.setPreferredSize(new Dimension(1600, 1200));
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
}

From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java

private void initCustumComponents() {
    logoLabel = new javax.swing.JLabel();
    icon = new ImageIcon(getCLub());
    logoLabel.setIcon(icon); // NOI18N
    logoLabel.setBounds(this.getWidth() - icon.getIconWidth(), this.getHeight() - icon.getIconHeight(),
            icon.getIconWidth(), icon.getIconHeight());
    LayerdPane.add(logoLabel, JLayeredPane.PALETTE_LAYER);
    clockLabel = new javax.swing.JLabel();
    clockLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    clockLabel.setText("");
    clockLabel.setForeground(Color.YELLOW);
    LayerdPane.add(clockLabel, JLayeredPane.PALETTE_LAYER);
    jTable1.setRowSelectionAllowed(false);
    jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Plaats", "Atleet", "Tijd" }) {
        Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }/*from  w w  w. j  av  a  2s .  c om*/

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });

    jScrollPane1.getViewport().setBackground(Color.black);
    this.setBackground(Color.black);
    JTableHeader header = jTable1.getTableHeader();
    header.setOpaque(false);
    jPanel1.setBackground(Color.black);
    header.setBackground(Color.black);
    header.setForeground(Color.YELLOW);
    DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer();
    headerRenderer.setBackground(Color.BLACK);

    for (int i = 0; i < jTable1.getModel().getColumnCount(); i++) {
        if (jTable1.getModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer);
        }
    }
    DefaultTableCellRenderer LEFTRenderer = new DefaultTableCellRenderer();
    LEFTRenderer.setHorizontalAlignment(JLabel.LEFT);
    jTable1.getColumnModel().getColumn(0).setCellRenderer(LEFTRenderer);
    ChangeFont(fontSize);
}

From source file:savant.view.swing.Frame.java

/**
 * Construct a new Frame for holding a track.
 *
 * @param df the DataFormat, so the frame can do any format-specific
 * initialisation (e.g. smaller height for sequence tracks)
 *//* w  w  w.  j ava 2  s.c  o  m*/
public Frame(DataFormat df) {
    super(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    sequence = df == DataFormat.SEQUENCE;

    // Component which displays the legend component.
    legend = new JComponent() {
        @Override
        public Dimension getPreferredSize() {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    return d;
                }
            }
            return new Dimension(0, 0);
        }

        @Override
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        @Override
        public void paintComponent(Graphics g) {
            for (Track t : tracks) {
                Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode());
                if (d != null) {
                    Graphics2D g2 = (Graphics2D) g;
                    GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 60, new Color(230, 230, 230));
                    g2.setPaint(gp);
                    g2.fillRect(0, 0, d.width, d.height);

                    g2.setColor(Color.BLACK);
                    g2.draw(new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1));
                    t.getRenderer().drawLegend(g2, t.getDrawingMode());
                    return;
                }
            }
        }
    };
    legend.setVisible(false);

    frameLandscape = new JLayeredPane();

    //add graphPane -> jlp -> scrollPane
    jlp = new JLayeredPane();
    jlp.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = 0;

    //scrollpane
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setWheelScrollingEnabled(false);
    scrollPane.setBorder(null);

    graphPane = new GraphPane(this);
    jlp.add(graphPane, gbc, 0);

    scrollPane.getViewport().add(jlp);

    //GRID FRAMEWORK AND COMPONENT ADDING...
    frameLandscape.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    //add sidepanel
    sidePanel = new JPanel() {
        @Override
        public Dimension getMinimumSize() {
            return new Dimension(0, 0);
        }
    };
    sidePanel.setLayout(new GridBagLayout());
    sidePanel.setOpaque(false);
    sidePanel.setVisible(false);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 16); // Leave 16 pixels so that we don't sit on top of the scroll-bar.
    frameLandscape.setLayer(sidePanel, JLayeredPane.PALETTE_LAYER);
    frameLandscape.add(sidePanel, c);

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            Dimension dim = getSize();
            if (dim != null) {
                // TODO: The following shouldn't be necessary, but it seems to be.
                int expectedWidth = frameLandscape.getWidth();
                if (expectedWidth != graphPane.getWidth()) {
                    Dimension goodSize = new Dimension(expectedWidth, graphPane.getHeight());
                    graphPane.setPreferredSize(goodSize);
                    graphPane.setSize(goodSize);
                }

                setLegendVisible(true);
            }
        }
    });

    //add graphPane to all cells
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(0, 0, 0, 0);

    frameLandscape.setLayer(scrollPane, JLayeredPane.DEFAULT_LAYER);
    frameLandscape.add(scrollPane, c);

    // Add our progress-panel.  If setTracks is called promptly, it will be cleared
    // away before it ever has a chance to draw.
    getContentPane().add(new ProgressPanel(null), BorderLayout.CENTER);
}