- AWT (Abstract Window Toolkit)
contoh penggunaan AWT
import java.awt.*; public class FlowAp extends Frame{ public static void main(String argv[]){ FlowAp fa=new FlowAp(); //Change from BorderLayout default fa.setLayout(new FlowLayout()); fa.setSize(400,300); fa.setVisible(true); } FlowAp(){ add(new Button("One")); add(new Button("Two")); add(new Button("Three")); add(new Button("Four")); add(new Button("Five")); add(new Button("Six")); add(new Button("Seven")); add(new Button("Eight")); add(new Button("Nine")); add(new Button("Ten")); }//End of constructor }//End of Application
maka tampilannya akan seperti di bawah ini
import java.awt.*;
import java.awt.event.*;
public class GBCal extends Frame{
Panel pTimes=new Panel();
Panel pAps=new Panel();
TextField txTimes=new TextField("09.00");
TextField txAps=new TextField("Meet the boss");
GridBagLayout gbl=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
public static void main(String argv[]){
GBCal gbc=new GBCal();
gbc.setLayout(new FlowLayout());
}
public GBCal() {
pTimes.add(txTimes);
pAps.add(txAps);
setLayout(gbl);
gbc.gridx=0;
gbc.gridy=0;
pTimes.setBackground(Color.pink);
add(pTimes,gbc);
gbc.gridx=1;
gbc.gridy=0;
pAps.setBackground(Color.lightGray);
add(pAps,gbc);
setSize(300,300);
setVisible(true);
}
}
maka outputnya
No comments:
Post a Comment