-
Notifications
You must be signed in to change notification settings - Fork 0
/
TitleChanger.java
51 lines (46 loc) · 1.36 KB
/
TitleChanger.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
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class TitleChanger extends JFrame implements ActionListener {
JButton b1;
JButton b2;
public TitleChanger() {
super("Title Bar");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setLookAndFeel();
b1 = new JButton("Daamin");
b2 = new JButton("Dawar");
b1.addActionListener(this);
b2.addActionListener(this);
FlowLayout flow = new FlowLayout();
setLayout(flow);
add(b1);
add(b2);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source == b1) {
setTitle("Daamin");
} else if (source == b2) {
setTitle("Dawar");
}
repaint();
}
private void setLookAndFeel() {
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception exc) {
System.err.println("Couldn't use the system "
+ "look and feel: " + exc);
}
}
public static void main(String[] arguments) {
TitleChanger frame = new TitleChanger();
}
}