Sidebar for NetBeans Platform Applications

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.border.LineBorder;
import org.openide.windows.OnShowing;
import org.openide.windows.WindowManager;
@OnShowing
public class Startable implements Runnable {
    @Override
    public void run() {
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        Container contentPane = 
                ((JRootPane) mainWindow.getComponents()[0]).getContentPane();
        contentPane.add(BorderLayout.WEST, new SideBarPanel());
    }
    private class SideBarPanel extends JPanel {
        public SideBarPanel() {
            setPreferredSize(new Dimension(40, 40));
            setBorder(new LineBorder(Color.RED, 2));
        }
    }
}

The result is the red border on the left of the screenshot below, which could just as easily be BorderLayout.EAST, of course, or any other place:

On the NetBeans Platform mailing list, Djamel Torche from Algeria recently showed off a screenshot of an app that has a sidebar on which the solution above is based:


Comments:

very good!

Posted by Jhonse on March 07, 2014 at 12:41 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2015
SunMonTueWedThuFriSat
   
4
5
11
12
26
27
28
29
30
  
       
Today