import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
public class ProjectGUI extends JFrame{
//
//Variable Declaration
//
private JLabel welcome, newProjectLabel, newNameLabel, newManagerLabel;
private JButton newProject, exProject, exit, next, back;
private JPanel contentPane;
private JTextField projectName, projectManager;
public ProjectGUI()
{
super();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
newProject = new JButton("New Project");
newProject.setEnabled(true);
exProject = new JButton("Exit Project");
exProject.setEnabled(true);
welcome = new JLabel();
welcome.setHorizontalAlignment(SwingConstants.LEFT);
welcome.setHorizontalTextPosition(SwingConstants.CENTER);
welcome.setIconTextGap(10);
welcome.setOpaque(true);
welcome.setText(" Welcome to Project Manager!");
welcome.setMaximumSize(new Dimension(500, 15));
exit = new JButton("Exit");
exit.setEnabled(true);
exit.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
exit_mouseClicked(e);
}
});
newProject.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
newProject_mouseClicked(e);
}
});
contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(null);
contentPane.setBackground(new Color (208,212,224));
addComponent(contentPane, welcome, 0, 21, 800, 97);
addComponent(contentPane, newProject, 100, 300, 110, 25);
addComponent(contentPane, exProject, 400, 300, 110, 25);
addComponent(contentPane, exit, 500, 500, 100, 25);
this.setTitle("Project Manager");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(693, 584));
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public class CreateProject extends JFrame{
private JLabel newProjectLabel, newNameLabel, newManagerLabel;
private JButton next, back;
private JPanel contentPane;
private JTextField projectName, projectManager;
public CreateProject()
{
dispose();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
newProjectLabel = new JLabel();
next = new JButton("NEXT");
back = new JButton("BACK");
contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(null);
contentPane.setBackground(new Color (208,212,224));
addComponent(contentPane,newProjectLabel,60,40,800,25);
addComponent(contentPane,newNameLabel,60,150,150,25);
addComponent(contentPane,newManagerLabel,60,190,150,25);
addComponent(contentPane,newProjectLabel,60,40,800,25);
addComponent(contentPane, next, 500, 500, 100, 50);
addComponent(contentPane, back, 100, 500, 100, 50);
this.setTitle("Project Manager");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(693, 584));
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
public void newProject_mouseClicked(MouseEvent e)
{
if(newProject.isEnabled() == true) {
System.out.println("\njnextButton_mouseClicked(MouseEvent e) called.");
new CreateProject();
}
}
public void exit_mouseClicked(MouseEvent e)
{
if(exit.isEnabled() == true) {
System.out.println("\njnextButton_mouseClicked(MouseEvent e) called.");
this.dispose();
}
}
public static void main(String[] args) {
new ProjectGUI();
}
}