mercredi 25 février 2015

Java GUI FullScreen window with smaller window inside



I am working on a Java desktop application. It uses MySQL database to store all data etc. I use swing for the GUI.


The GUI of this application is layed out as follows:



  1. Main Window taking the entire screen size (with image in the background)

  2. Internal Window 800 x 600 centered within the Main Window (that holds current content that can be switched between using menu and/or event within the application.


LoginPanel.java:



import javax.swing.*;
import java.awt.*;

public class LoginPanel {

private JPanel loginPanel;

public void loginForm()
{
JButton loginSubmit = new JButton("Login");

loginPanel = new JPanel();
loginPanel.add(loginSubmit);
loginPanel.setSize(800, 600);
}

public JComponent getGUI()
{
return loginPanel;
}

public static void main(String[] args)
{

}


}


Main.java:



import javax.swing.*;
import java.awt.*;

public class Main {

public static void main(String[] args)
{
JFrame mainFrame;
mainFrame = new JFrame();
mainFrame.setLayout(new BorderLayout());
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setTitle("Caledonian Library System");
LoginPanel loginObj = new LoginPanel();
mainFrame.add(loginObj.getGUI());
mainFrame.pack();
mainFrame.setVisible(true);
}

}


Should I maybe use box layout? any suggestions?




Aucun commentaire:

Enregistrer un commentaire