Sunday, July 2, 2017
Day 3 Java Training
Day 3 Java Training
//Creating Frames SampleFrame.java
import javax.swing.JFrame;
class sampleFrame{
public static void main(String[] args){
JFrame frame= new JFrame("MyFrame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,200);
frame.show();
}
}
// Creating Forms with Textfield
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class SampleForm extends JFrame{
JPanel panel;
JTextField txt;
SampleForm(){
super("My First Form");
panel=new JPanel();
txt=new JTextField("Hello",10);
panel=new JPanel();
panel.add(txt);
setContentPane(panel);
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
}
public static void main(String[] args){
new SampleForm();}
}
//GUI array
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.*;
public class SampleTable extends JFrame{
JPanel panel;
JTable table;
SampleTable(){
super("Table Form");
String[] title={"Name","Address","Age"};
Object[][] cnt={{"Julius","Antipolo","23"},{"Sheryl","Marikina","30"},{"May","Montalban","29"}};
panel=new JPanel();
table = new JTable(cnt,title);
table.setPreferredScrollableViewportSize(new Dimension (500,70));
table.setFillsViewportHeight(true);
panel.add(table);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setContentPane(panel);
show();
}
public static void main(String[] arg)
{
new SampleTable();
}
}
download more info
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment