1.execute The Following Program and Write Output

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

X.

Program Code:
1.Execute the following program and write output
OUTPUT:
XIII. Exercise
1.Write Java Program to display following output.
CODE:
package Experiment4;

import java.applet.Applet;
import java.awt.*;

public class Exercise1 extends Applet {


Button b1 = new Button("Button One");
Button b2 = new Button("Button Two");
Button b3 = new Button("Button Three");
Button b4 = new Button("Button Four");
Button b5 = new Button("Button Five");
@Override
public void init() {
GridBagConstraints gbc = new GridBagConstraints();
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 0;
gbc.gridy = 0;
add(new Button("Button One"), gbc);
gbc.gridx = 1;
gbc.gridy = 0;
add(new Button("Button two"), gbc);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipady = 20;
gbc.gridx = 0;
gbc.gridy = 1;
add(new Button("Button Three"), gbc);
gbc.gridx = 1;
gbc.gridy = 1;
add(new Button("Button Four"), gbc);
gbc.gridx = 0;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = 2;
add(new Button("Button Five"), gbc);
add(new Label("By Soham Parab 19"));
setSize(300, 300);
setVisible(true);
}
}
OUTPUT
2.Write Java Program to display output.
CODE:
package Experiment4;

import java.applet.Applet;
import java.awt.*;

public class Exercise2 extends Applet {


Label l1 = new Label("Name");;
Label l2 = new Label("Comments");
TextField t1 = new TextField();
TextArea t2 = new TextArea(5,5);
Button b1 = new Button("Submit");
@Override
public void init() {
GridBagConstraints gbc = new GridBagConstraints();
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 0;
gbc.gridy = 0;
add(l1,gbc);

gbc.gridx = 1;
gbc.gridy = 0;
add(t1,gbc);

gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 0;
gbc.gridy = 1;
add(l2,gbc);

gbc.gridx = 1;
gbc.gridy = 1;
add(t2,gbc);

gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 1;
gbc.gridy = 2;
add(b1,gbc);
add(new Label("By Soham Parab 19"));
}
}
OUTPUT

You might also like