1.
import javax.swing.JFrame;
public class frame1
{ public static void main(String[]xXx)
{ JFrame frame = new JFrame();
frame.setTitle("bram");
frame.setVisible(true);
}
}
2.
import javax.swing.JFrame;
public class frame2
{ public static void main(String[]xXx)
{ JFrame frame = new JFrame();
frame.setSize(300,300);
frame.setVisible(true);
}
}
3.
import javax.swing.JLabel;
import javax.swing.JFrame;
class Label
{ public static void main(String[]
args)
{ JLabel lbl1 = new JLabel("Nama
Anda :");
JFrame frame = new JFrame();
lbl1.setBounds(100, 100, 75, 25);
frame.add(lbl1);
frame.setSize(500, 200);
frame
.setLayout(null);
frame.setVisible(true);
frame.getContentPane().add(panel1);
}
}
4.
import javax.swing.JTextField;
import javax.swing.JFrame;
class Text
{ public static void main(String[] args)
{ JTextField txt = new JTextField();
JFrame frame = new JFrame();
frame.setSize(500, 200);
frame.add(txt);
txt.setBounds(50, 10, 150, 25);
frame.setLayout(null);
frame.setVisible(true);
}
}
5.
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.*;
public class button
{ public static void main(String[]xXx)
{ JFrame frame = new JFrame();
JButton bttn = new
JButton("pencet aku");
frame.setSize(300,300);
bttn.setBounds(180,
100, 150, 25);
frame
.add(bttn);
frame.setLayout(null);
frame.setVisible(true);
}
}
Menggunakan Constructor
import javax.swing.*;
class m
{ JFrame frame = new JFrame();
JButton btn = new JButton("ok");
m()
{ frame.setSize(300,300);
btn.setBounds(50,50,75,25);
frame.add(btn);
frame.setLayout(null);
frame.setVisible(true);
}
public static void main(String []xXx)
{ m n= new m();
}
}
imp
ort javax.swing.*;
class m
{ JFrame frame = new JFrame();
JButton btn = new JButton("ok");
m()
{ frame.setSize(300,300);
btn.setBounds(50,50,75,25);
frame.add(btn);
frame.setLayout(null);
}
public
static void main(String []xXx)
{ m n= new m();
n.
frame.setVisible(true);
}
}
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο