Reputation: 1120
I need to have a GUI
like this:
Here all the rectangles must be buttons. How can I achieve this? Suggest me some tools like JFormDesigner
.
Upvotes: 1
Views: 4214
Reputation: 4403
I have had a lot of good experience with JGraph!
See the docs and some examples of what you can achieve here
Each node in the diagrams can be clicked and events can be listened for and acted upon, just like buttons. In fact I think you can put JButton
s into the nodes in the diagram, but I may be wrong.
EDIT: Just the layout using regular Java Swing code would be something like this
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class LayoutTest {
public static void main(String[] args) {
JFrame window = new JFrame();
Container container = window.getContentPane();
container.setLayout(new BorderLayout());
JPanel centerPanel = new JPanel();
centerPanel.add(new JButton("Center"));
container.add(centerPanel, BorderLayout.CENTER);
JPanel topPanel = new JPanel();
topPanel.add(new JButton("b1"));
container.add(topPanel, BorderLayout.NORTH);
JPanel rightPanel = new JPanel();
rightPanel.add(new JButton("b3"));
container.add(rightPanel, BorderLayout.EAST);
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BorderLayout());
JPanel bottomNorthPanel = new JPanel();
bottomNorthPanel.add(new JButton("b2"));
bottomPanel.add(bottomNorthPanel, BorderLayout.NORTH);
JPanel bottomSouthPanel = new JPanel();
bottomSouthPanel.add(new JButton("b2-1"));
bottomSouthPanel.add(new JButton("b2-2"));
bottomPanel.add(bottomSouthPanel, BorderLayout.SOUTH);
container.add(bottomPanel, BorderLayout.SOUTH);
window.setSize(320, 240);
window.setVisible(true);
}
}
Upvotes: 2
Reputation: 316
I suppose you're asking for things on Java Swing. You can use drawLine(), and drawRect(), and you've to take control of painting over component. Once you understand this well, and create basic classes that suit your need, you can you do really well.
For info: refer to Schildt's examples on Swing: A Beginner's Guide. on page 495.
For listing- http://www.mhprofessional.com/getpage.php?c=computing_downloads.php&cat=112 (go to bottom)
Hope this helps..
Upvotes: 0