UI layout similar to NetBeans or Eclipse IDE
Hello All,
I need to develop a UI whose basic layout should be similar that of the popular IDEs like Netbeans or Eclipse. Basically it should look as described below:
- A Menu bar
- Under that a toolbar
- Under that a left section and a right section
- Under that a bottom section
All these sections should be arbitrarily resizable and movable by drag and drop.
May I know if the netbeans IDE is developed using java swing? Do we require any other components to develop this kind of a UI? Is there any sample source code available?
Any help would be highly appreciated with duke dollars :-)
Thanks in advance,
Sandeep
# 5
A basic demo:import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class SplitPaneDemo extends JFrame
{
public SplitPaneDemo()
{
super("SplitPane Demo");
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel leftPanel = new JPanel();
leftPanel.add(new JLabel("Project Navigation goes here"));
JPanel rightPanel = new JPanel();
rightPanel.add(new JLabel("Code would typically be on this side"));
JPanel bottomPanel = new JPanel();
bottomPanel.add(new JLabel("Console/Errors etc. would go typically be on the bottom"));
JSplitPane split1 = new JSplitPane();
split1.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
split1.setDividerLocation(200);
split1.setLeftComponent(new JScrollPane(leftPanel));
split1.setRightComponent(new JScrollPane(rightPanel));
JSplitPane split2 = new JSplitPane();
split2.setOrientation(JSplitPane.VERTICAL_SPLIT);
split2.setDividerLocation(200);
split2.setLeftComponent(split1);
split2.setRightComponent(new JScrollPane(bottomPanel));
JToolBar toolbar = new JToolBar();
toolbar.add(new JButton("OPEN"));
toolbar.add(new JButton("SAVE"));
toolbar.add(new JButton("PRINT"));
JMenu fileMenu = new JMenu("File");
fileMenu.add(new JMenuItem("Print"));
fileMenu.add(new JMenuItem("Save"));
fileMenu.add(new JMenuItem("Close"));
JMenu editMenu = new JMenu("Edit");
editMenu.add(new JMenuItem("Cut"));
editMenu.add(new JMenuItem("Copy"));
editMenu.add(new JMenuItem("Paste"));
JMenuBar menuBar = new JMenuBar();
menuBar.add(fileMenu);
menuBar.add(editMenu);
setJMenuBar(menuBar);
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add(toolbar, BorderLayout.NORTH);
c.add(split2, BorderLayout.CENTER);
setSize(600,400);
}
public static void main(String[] args)
{
JFrame f = new SplitPaneDemo();
f.setVisible(true);
}
}