import java.awt.FlowLayout;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import javax.swing.*;
import javax.swing.border.EtchedBorder;

public class FlowLayoutTest {
	public static void main(String args[]) {
		FlowLayoutTest test = new FlowLayoutTest();
	}
	   public FlowLayoutTest() {
	        try {
	            SwingUtilities.invokeAndWait(new Runnable() {
	                public void run() {
//	                	try {
//							UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
//						} catch (ClassNotFoundException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						} catch (InstantiationException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						} catch (IllegalAccessException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						} catch (UnsupportedLookAndFeelException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						}
	                    createGUI();
	                }
	            });
	        } catch (Exception e) {
	            e.printStackTrace();
	        }

	    }
	   private void createGUI() {
		   	JFrame frame = new JFrame("FlowLayoutTest");
	        frame.setLayout(new FlowLayout());
	        JButton button = new JButton("This is a button");
	        JButton button2 = new JButton("This is a button");

	        JTextField tf = new JTextField("Text inside text field");
	        JTextField tf2 = new JTextField("Text inside text field");
	        JSlider slider = new JSlider();
	        JSlider slider2 = new JSlider();
	        

	        slider = new JSlider(-10,100);
	        slider.setValue(15);
	        slider.setMinorTickSpacing(10);
	        slider.setMajorTickSpacing(20);
	        slider.setPaintLabels(true);
	        slider.setPaintTicks(true);
	        slider.setSnapToTicks(true);
	        slider.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(), "Divider Enough Space"));
	        
	        
	        slider2 = new JSlider(-10,550);
	        slider2.setValue(250);
	        slider2.setMinorTickSpacing(40);
	        slider2.setMajorTickSpacing(80);
	        slider2.setPaintLabels(true);
	        slider2.setPaintTicks(true);
	        slider2.setSnapToTicks(true);
	        slider2.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(), "Divider Overlapping Text"));
	        
	        
	        JTree tree = new JTree();
	        JScrollPane treeScrollPane = new JScrollPane(tree);

	        //Content of right/bottom pane
	        JTable table = new JTable(new String[][]{{"invokeLater", "validate"},
	        {"invokeAndWait", "invalidate"},
	        {"Actions", "revalidate"},
	        {"update", "EDT"},
	        {"repaint", "Thread"},
	        {"paint", "is"}},new String[] {"First Column","Second Column"});
	        table.setAutoCreateRowSorter(true);
	        JScrollPane tableScrollPane = new JScrollPane(table);


	        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScrollPane,tableScrollPane);
	        splitPane.setDividerSize(15);
	        splitPane.setDividerLocation(250);

	        //Add a contextpopupMenu for the splitpane
	        javax.swing.JPopupMenu textPopup = new javax.swing.JPopupMenu();
	        textPopup.add("This is a component Menu 1");
	        textPopup.add("This is a component Menu 2");
	        textPopup.add("This is a component Menu 3");
	        splitPane.setComponentPopupMenu(textPopup);

	        frame.add(slider2);

	        frame.add(splitPane);
	        frame.add(button);
	        frame.add(tf);
	        frame.add(slider);
	        frame.add(button2);
	        frame.add(tf2);
	      
	        
	        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	        Rectangle bounds = ge.getMaximumWindowBounds();
	        frame.setBounds(bounds);
	        frame.setVisible(true);
	    }
}
