Pages

Really cool Gui | Java

In todays example, I am gonna make a simple but awesome gui in java. I will use the swing components.
I have worked in a few Desktop application, and I remember the first days of struggle. How to make things resizable, cool etc.
This tutorial is actually for my reference. It does not do anything, just provides a layout to begin. It is more easier to do GUI stuffs in java using the Netbeans IDE.

A snapshot of the GUI in Java.
The code that made it possible is here.

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;

/**
 *
 * @author Rajan Prasad Upadhyay
 */
public class FlexibleGui {

    public static void main(String[] args) {
        javax.swing.JFrame topFrame = new JFrame();
        javax.swing.JPanel topPanel = new JPanel();
        javax.swing.JSplitPane splitPane = new JSplitPane();
        javax.swing.JPanel  leftPanel   = new JPanel();
        javax.swing.JPanel  rightPanel   = new JPanel();
        javax.swing.JScrollPane leftScrollPane = new JScrollPane();
        javax.swing.JScrollPane rightScrollPane = new JScrollPane();
        javax.swing.JTree  leftTree = new JTree();
        
        //layouts
        // with border layout, components take maximum size they could get.
        topFrame.setLayout(new BorderLayout());
        topPanel.setLayout(new BorderLayout());
        leftPanel.setLayout(new BorderLayout());
        rightPanel.setLayout(new BorderLayout());
        
        // addition of components
//        topPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
        topPanel.add(splitPane);
        
        splitPane.setRightComponent(rightPanel);
        splitPane.setLeftComponent(leftPanel);
        //setting the default location of the middle border
        splitPane.setDividerLocation(200);
        
        //add scroll panes
        rightPanel.add(rightScrollPane);
        leftPanel.add(leftScrollPane);
        
        leftScrollPane.getViewport().add(leftTree);
        
        topFrame.setSize(600, 500);
        topFrame.setContentPane(topPanel);
        topFrame.setVisible(true);
    }
}

In later posts, I may be posting about the user interaction, events handeling, changing the icons etc. Depends on my mood.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. An air conditioning channel ought to be changed consistently or at regular intervals for home air conditioning frameworks and each a long time for specific business or modern air conditioning since it's running very nearly 24 hours per day, 7 days every week.
    replacement ducted heating unit

    ReplyDelete

If you like to say anything (good/bad), Please do not hesitate...