package sqlconnect;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class Panels extends JFrame
{
JPanel panelRoot = new JPanel();
JPanel panelLeftMain = new JPanel();
JPanel panelRightMain = new JPanel();
JPanel panelLeftTop = new JPanel();
JPanel panelLeftCenter = new JPanel();
JPanel panelLeftBottom = new JPanel();
JPanel panelRightTop = new JPanel();
JPanel panelRightBottom = new JPanel();
JLabel labelTemp1 = new JLabel("panelLeftTop");
JLabel labelTemp2 = new JLabel("panelLeftCenter");
JLabel labelTemp3 = new JLabel("panelLeftBottom");
JLabel labelTemp4 = new JLabel("panelRightTop");
JLabel labelTemp5 = new JLabel("panelRightBottom");
//--------------------------------------------------------------------------------------------------------------------------------
public Panels()
{
buildChatFrame(); // Create the frame, position it and handle closing it
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildChatFrame()
{
this.setSize(1000,700); // Set frame size
this.setMinimumSize(new Dimension(1000,700)); // Set minimum frame size
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Welcome to...");
this.setExtendedState(Frame.MAXIMIZED_BOTH); // Maximize window
//this.setUndecorated(true); // True full screen, no X button in top right. Add exit button to dispose/exit
panelRoot.setLayout(new BorderLayout()); // Set border between other sub-panel components, but not parent
panelRoot.setBorder(new EmptyBorder(6,6,6,6)); // Set border of panel but not components inside (Top, Left, Bottom, Right)
panelRoot.setBackground(Color.red);
buildLeftPanel();
buildRightPanel();
panelRoot.add(panelLeftMain, BorderLayout.CENTER); // Apply layout manager to LeftMain panel
panelRoot.add(panelRightMain, BorderLayout.EAST); // Apply layout manager to RightMain panel
this.add(panelRoot);
this.setVisible(true);
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildLeftPanel()
{
// Build sub-components
buildLeftTopPanel();
buildLeftCenterPanel();
buildLeftBottomPanel();
panelLeftMain.setLayout(new BorderLayout(6,6)); // Set gap of panel components
panelLeftMain.setBorder(new EmptyBorder(0,0,0,3)); // Set border of panel but not components inside (Top, Left, Bottom, Right)
panelLeftMain.setOpaque(false); // Set panel background to transparent
// Panel height & width
panelLeftTop.setPreferredSize(new Dimension(1,90)); // Set default panel width & height
panelLeftBottom.setPreferredSize(new Dimension(1,150)); // Set default panel width & height
// Temporary background colors to see the individual panels easier
panelLeftTop.setBackground(new Color(30, 30, 30));
panelLeftCenter.setBackground(new Color(30, 30, 30));
panelLeftBottom.setBackground(new Color(30, 30, 30));
panelLeftMain.add(panelLeftTop, BorderLayout.NORTH); // Anything that isn't CENTER will not resize
panelLeftMain.add(panelLeftCenter, BorderLayout.CENTER); // CENTER constraint will expand & contract on resize
panelLeftMain.add(panelLeftBottom, BorderLayout.SOUTH); // Anything that isn't CENTER will not resize
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildRightPanel()
{
// Build sub-components
buildRightTopPanel();
buildRightBottomPanel();
panelRightMain.setLayout(new BorderLayout(6,6)); // Set gap of panel components
panelRightMain.setBorder(new EmptyBorder(0,3,0,0)); // Set border of panel but not components inside (Top, Left, Bottom, Right)
panelRightMain.setOpaque(false); // Set panel background to transparent
// Panel height & width
panelRightBottom.setPreferredSize(new Dimension(200,100)); // Set panel width & height
// Temporary background colors to see the individual panels easier
panelRightTop.setBackground(new Color(30, 30, 30));
panelRightBottom.setBackground(new Color(30, 30, 30));
panelRightMain.add(panelRightTop, BorderLayout.CENTER); // CENTER constraint will expand & contract on resize
panelRightMain.add(panelRightBottom, BorderLayout.SOUTH); // Anything that isn't CENTER will not resize
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildLeftTopPanel()
{
panelLeftTop.setLayout(new BorderLayout(10,10)); // Set gap of panel components
panelLeftTop.setBorder(new EmptyBorder(10,10,10,10)); // Set insets of panel components
labelTemp1.setForeground(Color.white);
panelLeftTop.add(labelTemp1, BorderLayout.NORTH);
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildLeftCenterPanel()
{
panelLeftCenter.setLayout(new BorderLayout(10,10)); // Set gap of panel components
panelLeftCenter.setBorder(new EmptyBorder(10,10,10,10)); // Set insets of panel components
labelTemp2.setForeground(Color.white);
panelLeftCenter.add(labelTemp2, BorderLayout.NORTH);
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildLeftBottomPanel()
{
panelLeftBottom.setLayout(new BorderLayout(10,10)); // Set gap of panel components
panelLeftBottom.setBorder(new EmptyBorder(10,10,10,10)); // Set insets of panel components
labelTemp3.setForeground(Color.white);
panelLeftBottom.add(labelTemp3, BorderLayout.NORTH);
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildRightTopPanel()
{
panelRightTop.setLayout(new BorderLayout(10,10)); // Set gap of panel components
panelRightTop.setBorder(new EmptyBorder(10,10,10,10)); // Set insets of panel components
labelTemp4.setForeground(Color.white);
panelRightTop.add(labelTemp4, BorderLayout.NORTH);
}
//--------------------------------------------------------------------------------------------------------------------------------
public void buildRightBottomPanel()
{
panelRightBottom.setLayout(new BorderLayout(10,10)); // Set gap of panel components
panelRightBottom.setBorder(new EmptyBorder(10,10,10,10)); // Set insets of panel components
labelTemp5.setForeground(Color.white);
panelRightBottom.add(labelTemp5, BorderLayout.NORTH);
}
//--------------------------------------------------------------------------------------------------------------------------------
public static void main(String[] args)
{
new Panels();
}
}