-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewOrOpenProject.java
More file actions
133 lines (111 loc) · 2.63 KB
/
NewOrOpenProject.java
File metadata and controls
133 lines (111 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public class NewOrOpenProject extends JDialog implements ActionListener
{
private JFrame parent;
private JButton nouveau, ouvrir;
private Icon nouveauIcon, ouvrirIcon;
public NewOrOpenProject(final JFrame parent)
{
super(parent, "Bienvenue", true);
this.parent = parent;
setSize(400,200);
setResizable(false);
setLocationRelativeTo(null);
setLayout(new GridLayout(1,2));
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
parent.dispose();
}
});
initComponent();
}
public void initComponent()
{
nouveauIcon = new ImageIcon("icons/new-project-template-icon.png");
ouvrirIcon = new ImageIcon("icons/project-open-icon.png");
JPanel gauche = new JPanel(new BorderLayout());
JPanel droite = new JPanel(new BorderLayout());
nouveau = new JButton(nouveauIcon);
nouveau.addActionListener(this);
ouvrir = new JButton(ouvrirIcon);
ouvrir.addActionListener(this);
gauche.add(nouveau);
droite.add(ouvrir);
gauche.add(new JLabel("Nouveau projet", SwingConstants.CENTER), BorderLayout.SOUTH);
droite.add(new JLabel("Ouvrir un projet", SwingConstants.CENTER), BorderLayout.SOUTH);
add(gauche);
add(droite);
setVisible(true);
}
public JFrame getParent()
{
return parent;
}
public void setParent(JFrame parent)
{
this.parent = parent;
}
public JButton getNouveau()
{
return nouveau;
}
public void setNouveau(JButton nouveau)
{
this.nouveau = nouveau;
}
public JButton getOuvrir()
{
return ouvrir;
}
public void setOuvrir(JButton ouvrir)
{
this.ouvrir = ouvrir;
}
public Icon getNouveauIcon()
{
return nouveauIcon;
}
public void setNouveauIcon(Icon nouveauIcon)
{
this.nouveauIcon = nouveauIcon;
}
public Icon getOuvrirIcon()
{
return ouvrirIcon;
}
public void setOuvrirIcon(Icon ouvrirIcon)
{
this.ouvrirIcon = ouvrirIcon;
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(nouveau))
{
((VueProjet)parent).getListeners().newProject();
}
else if(e.getSource().equals(ouvrir))
{
if(!((VueProjet)parent).getListeners().open())
return;
}
dispose();
}
}