-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formulario37.java
71 lines (53 loc) · 1.7 KB
/
Formulario37.java
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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Formulario37 extends JFrame implements ActionListener{
private JMenuBar menubar;
private JMenu menu1, menu2, menu3;
private JMenuItem menuitem1, menuitem2, menuitem3, menuitem4;
public Formulario37(){
setLayout(null);
menubar = new JMenuBar();
setJMenuBar(menubar);
menu1= new JMenu("Opciones");
menubar.add(menu1);
menu2= new JMenu("Tamaño de la ventana");
menu1.add(menu2);
menu3= new JMenu("Color de fondo");
menu1.add(menu3);
menuitem1= new JMenuItem("300x200");
menu2.add(menuitem1);
menuitem1.addActionListener(this);
menuitem2= new JMenuItem("640x480");
menu2.add(menuitem2);
menuitem2.addActionListener(this);
menuitem3= new JMenuItem("Rojo");
menu3.add(menuitem3);
menuitem3.addActionListener(this);
menuitem4= new JMenuItem("Verde");
menu3.add(menuitem4);
menuitem4.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
// Container fondo = this.getContentPane ();
if (e.getSource() == menuitem1){
setSize(300,200);
}
if (e.getSource() == menuitem2){
setSize(640,480);
}
if (e.getSource() == menuitem3){
getContentPane().setBackground (new Color(255,0,0));
}
if (e.getSource() == menuitem4){
getContentPane().setBackground (new Color(0,255,0));
}
}
public static void main (String args[]){
Formulario37 formulario1 = new Formulario37();
formulario1.setBounds(0,0,400,300);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
formulario1.setResizable(true);
}
}