Advance Java Programmiing
Advance Java Programmiing
import java.awt.*;
public class Practice extends Frame{
public static void main(String[] args) {
import java.awt.*;
import java.awt.Frame;
import java.awt.Label;
}
public static void main(String[] args) {
new newpractice();
}
}
2) Button
import java.awt.*;
import java.awt.*;
}
remove(b);
}
public static void main(String[] args) {
new newpractice();
}
}
3) Checkbox
import java.awt.*;
4) checkbox group
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
5) scroll bar
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
6) text field
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
7) text area
import java.awt.*;
}
public static void main(String[] args) {
new newpractice();
}
}
8) List
import java.awt.*;
import java.awt.*;
import java.awt.*;
newpractice()
{
setTitle("use of FlowLayout");
setSize(600, 600);
setVisible(true);
add(b);
add(b1);
add(b2);
add(b3);
add(b4);
}
import java.awt.*;
newpractice()
{
setTitle("use of BorderLayout");
setSize(600, 600);
setVisible(true);
// BorderLayout f = new BorderLayout();
BorderLayout f = new BorderLayout(140, 140);
setLayout(f);
add(b,BorderLayout.EAST);
add(b1,BorderLayout.WEST);
add(b2,BorderLayout.NORTH);
add(b3,BorderLayout.SOUTH);
add(b4,BorderLayout.CENTER);
import java.awt.*;
newpractice()
{
setTitle("use of GridLayout");
setSize(600, 600);
setVisible(true);
// GridLayout f = new GridLayout(); // by defulat its add column in the grid.
GridLayout f = new GridLayout(3, 3);
setLayout(f);
Output:
4) Gridbag Layout
➔ It is same as the grid Layout but in this layout we can set size of the component and also we can set position
of each component individually by giving the value of grid x and grid y.
import java.awt.*;
newpractice()
{
setTitle("use of GridbagLayout");
setSize(600, 600);
setVisible(true);
Output:
5) Card Layout
➔ This layout is dynamically change on the user input.
➔ In this layout the different layouts are created using panel class.
➔ It is the type of layout in which we can combine the other Layout. Like flow Layout, border Layout, grid
Layout and gridbagLayout.
➔ All the layouts are arranged like a card that why it called card layout and one layout can visible at a time in
this layout.
import java.awt.*;
import javax.smartcardio.Card;
newpractice()
{
setTitle("CardLayout");
setSize(600, 600);
setVisible(true);
CardLayout cl = new CardLayout();
setLayout(cl);
add("Card2",b1);
add("Card2",b2);
import java.awt.*;
m3.setEnabled(false);
m3.setLabel("new gen");
m.add(mt1);
m.addSeparator(); //add a line between components
m.add(mt2);
m.add(mt3);
mt1.add(mt1m);
mt1.add(mt2m);
mt1.add(mt3m);
}
public static void main(String[] args)
{
new newpractice();
}
}
Output:
• DIALOG BOXES
> THE DIALOG BOXES ARE USE TO HOLD CONTROLS/ GETTING THE INPUT FROM THE USER.
> TYPES OF DIALOG BOX
1) MODEL
2) MODEL-LESS (IT CAN BE CLOSE)
import java.awt.*;
Output:
• FILE DIALOG
OPERATION OF FILE DIALOGS
1) SAVE
2) OPEN (LOAD)
import java.awt.*;
}
}
/*
<applet code = "A" width = 500 height = 500 >
</applet>
*/