-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjcheck.java
More file actions
46 lines (45 loc) · 1.26 KB
/
jcheck.java
File metadata and controls
46 lines (45 loc) · 1.26 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
package mayank;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class jcheck extends JFrame{
private JTextField item1;
private JCheckBox item2;
private JCheckBox item3;
jcheck(){
super("the title bar");
setLayout(new FlowLayout());
item1=new JTextField("Food is soo good!!",25);
item1.setFont(new Font("serif",Font.PLAIN,14));
item2=new JCheckBox("bold");
item2.setToolTipText("for making text bold");
item3=new JCheckBox("itlaic");
item3.setToolTipText("for making text italic");
add(item1);
add(item2);
add(item3);
handlerclass handler=new handlerclass();
item2.addItemListener(handler);
item3.addItemListener(handler);
}
public class handlerclass implements ItemListener{
public void itemStateChanged(ItemEvent event){
Font font=null;
if(item2.isSelected()&&item3.isSelected())
font=new Font("serif",Font.BOLD+Font.ITALIC,14);
else if(item2.isSelected())
font=new Font("serif",Font.BOLD,14);
else if(item3.isSelected())
font=new Font("serif",Font.ITALIC,14);
else
font=new Font("serif",Font.PLAIN,14);
item1.setFont(font);
}
}
public static void main(String[] args) {
jcheck ob=new jcheck();
ob.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ob.setVisible(true);
ob.setSize(350,350);
}
}