JAVAPR20
JAVAPR20
JAVAPR20
import java.applet.*;
import java.awt.*;
</APPLET>
*/
CheckboxGroup radioGroup;
add(c1);
add(c2);
add(radioButton1);
add(radioButton2);
add(tf);
}
2. Write a program to demonstrate choice and list various cities in India
import java.awt.*;
F1.setSize(500, 500);
F1.setLayout(new FlowLayout());
F1.setVisible(true);
Cities.add("Jaipur");
Cities.add("Lucknow");
Cities.add("Patna");
cityChoice.add("Select City");
cityChoice.add("Mumbai");
cityChoice.add("Pune");
cityChoice.add("Hyderabad");
F1.add(L1);
F1.add(Cities);
F1.add(cityChoice);
}
3. Write a program to demonstrate card layout border layout gird layout
import java.awt.*;
import java.applet.*;
add(new Button("0"));
add(new Button("1"));
add(new Button("2"));
add(new Button("3"));
add(new Button("4"));
add(new Button("5"));
add(new Button("6"));
add(new Button("7"));
add(new Button("8"));
F.setLayout(new BorderLayout());
F.setVisible(true);
F.setSize(300,300);
F.add(b1,BorderLayout.NORTH);
F.add(b2,BorderLayout.SOUTH);
F.add(b3,BorderLayout.WEST);
F.add(b4,BorderLayout.EAST);
import java.awt.*;
public Exp() {
me.add(i1);
me.add(i2);
me.add(i3);
me.add(checkboxItem);
mB.add(me);
f.setMenuBar(mB);
f.setSize(300, 300);
f.setVisible(true);
new Exp();
}
5. Write a program to demonstrate card layout
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
CardLayout cardA;
Container c;
CardLayoutExample() {
c = getContentPane();
c.setLayout(card);
b1 = new JButton("Apple");
b2 = new JButton("Boy");
b3 = new JButton("Cat");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
c.add("a", b1);
c.add("b", b2);
c.add("c", b3);
card.next(c);
cl.setSize(400, 400);
cl.setVisible(true);
cl.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
6. Write a program to demonstrate Grid layout
import java.awt.*;
import java.applet.*;
add(new Button("0"));
add(new Button("1"));
add(new Button("2"));
add(new Button("3"));
add(new Button("4"));
add(new Button("5"));
add(new Button("6"));
add(new Button("7"));
add(new Button("8"));
import java.awt.*;
import javax.swing.*;
public JComboBoxDemo() {
Container ct = getContentPane();
ct.setLayout(new FlowLayout());
jc.addItem("Mumbai");
jc.addItem("Patna");
jc.addItem("Gujrat");
ct.add(label);
ct.add(jc);
ct.add(label);
ct.add(jc);
ct.add(selectedCityLabel);
jc.addActionListener(e -> {
});
f1.setTitle("Demonstrating JComboBox");
f1.setSize(300, 400);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setVisible(true);
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
container.setLayout(new BorderLayout());
root.add(a);
a.add(ai);
a.add(a2);
root.add(b);
b.add(bi);
b.add(b2);
container.add(scrollPane, BorderLayout.CENTER);
}
9. Write a program to demonstrate Jtable for various employees in a company
import javax.swing.*;
JFrame frame;
JTableDemo() {
String[][] rows = {
};
frame.add(scrollPane);
frame.setSize(300, 400);
frame.setVisible(true);
new JTableDemo();
}
10. Write a program to demonstrate password field and display username and password on screen
import javax.swing.*;
frame.add(value);
frame.add(label1);
frame.add(label2);
frame.add(button);
frame.add(text);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
button.addActionListener(e -> {
});
}
11. Write a program to demonstrate all Inet address methods in Java
import java.net.*;
try {
InetAddress ip = InetAddress.getByName("www.youtube.com");
} catch (Exception e) {
System.out.println(e);
import java.net.*;
try {
} catch (Exception e) {
System.out.println(e);