-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGaniAsif4.java
More file actions
131 lines (103 loc) · 3.71 KB
/
GaniAsif4.java
File metadata and controls
131 lines (103 loc) · 3.71 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
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class GaniAsif4 {
public static void main (String args []) {
BannerMaker gui = new BannerMaker ();
gui.setVisible(true);
}
}
class BannerMaker extends JFrame {
private Container content;
private JTextField message;
public BannerMaker () {
super();
setSize (600,600);
setTitle("Banner Maker");
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setTitle ("Banner Maker");
Container content = new Container ();
content = getContentPane ();
content.setLayout(new BorderLayout ());
content.setBackground (Color.WHITE);
JTextField message = new JTextField ();
content.add(message, BorderLayout.CENTER);
JPanel BackgroundPanel = new JPanel ();
content.add(BackgroundPanel, BorderLayout.EAST);
JButton White = new JButton ("WHITE");
White.addActionListener(new ColorButtonListener (message));
BackgroundPanel.add(White);
JButton Blue = new JButton ("BLUE");
Blue.addActionListener(new ColorButtonListener (message));
BackgroundPanel.add(Blue);
JButton Red = new JButton ("RED");
Red.addActionListener(new ColorButtonListener (message));
BackgroundPanel.add(Red);
JPanel Style = new JPanel ();
content.add(Style, BorderLayout.SOUTH);
JButton Bold = new JButton ("BOLD");
Bold.addActionListener(new StyleButtonListener (message));
Style.add(Bold);
JButton Italic = new JButton ("ITALIC");
Italic.addActionListener(new StyleButtonListener (message));
Style.add(Italic);
JButton Plain = new JButton ("PLAIN");
Plain.addActionListener(new StyleButtonListener (message));
Style.add(Plain);
JPanel Font = new JPanel ();
content.add(Font, BorderLayout.WEST);
JButton Serif= new JButton ("SERIF");
Serif.addActionListener(new FontButtonListener (message));
Font.add(Serif);
JButton SanSerif = new JButton ("SAN SERIF");
SanSerif.addActionListener(new FontButtonListener (message));
Font.add(SanSerif);
}
class ColorButtonListener implements ActionListener {
private JTextField message;
ColorButtonListener (JTextField message) {
this.message = message;
}
public void actionPerformed (ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("WHITE")) message.setBackground(Color.WHITE);
if (command.equals ("BLUE")) message.setBackground(Color.BLUE);
if (command.equals ("RED")) message.setBackground(Color.RED);
}
}
class StyleButtonListener implements ActionListener {
private JTextField message;
StyleButtonListener (JTextField message) {
this.message = message;
}
public void actionPerformed (ActionEvent e) {
Font Bold = new Font ("PLAIN", Font.BOLD, 20);
Font Italic = new Font ("ITALIC", Font.ITALIC, 20);
Font Plain = new Font ("PLAIN", Font.PLAIN, 20);
String command = e.getActionCommand();
if (command.equals("BOLD")) message.setFont((Bold));
if (command.equals ("ITALIC")) message.setFont(Italic);
if (command.equals ("PLAIN")) message.setFont(Plain);
}
}
class FontButtonListener implements ActionListener {
private JTextField message;
FontButtonListener (JTextField message) {
this.message = message;
}
public void actionPerformed (ActionEvent e) {
Font Serif = new Font ("SERIF", Font.PLAIN, 20 );
Font San_Serif = new Font ("SAN_SERIF", Font.PLAIN, 20);
String command = e.getActionCommand();
if (command.equals ("SERIF")) message.setFont((Serif));
if (command.equals ("SAN SERIF")) message.setFont((San_Serif));
}
}
}