S2 Psikologi Profesi UGM
6 tahun yang lalu
AWT(Abstract Window Toolkit) merupakan sekulmpulan library yang tidak tergantung pada platfrom serta digunakan untuk menyederhanakan implementasi user-interface, sedangkan Swing merupakan salah satu cara untuk menginplementasikan pemrograman window pada java,
beda swing dengan awt adalah, bentuk komponen komponen dari kelas swing sama bentuknya pada semua sistem operasi.
import java.awt.*; import java.awt.event.*; public class GBCal extends Frame{ Panel pTimes=new Panel(); Panel pAps=new Panel(); TextField txTimes9=new TextField("09.00"); TextField txTimes930=new TextField("09.30"); TextField txAps=new TextField("Meet the boss"); GridBagLayout gbl=new GridBagLayout(); GridBagLayout gbBut=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); public static void main(String argv[]){ GBCal gbc=new GBCal(); gbc.setLayout(new FlowLayout()); } public GBCal() { setLayout(gbl); //Control the Times panel with a GridBagLayout pTimes.setLayout(gbBut); //Ensure the componants sit at //the top of the containers gbc.anchor=GridBagConstraints.NORTH; gbc.gridx=0; gbc.gridy=0; pTimes.add(txTimes9,gbc); gbc.gridx=0; gbc.gridy=1; pTimes.add(txTimes930,gbc); pTimes.setBackground(Color.pink); //Re-using gbc for the main panel layout gbc.gridx=0; gbc.gridy=0; gbc.ipadx=30; add(pTimes,gbc); pAps.setLayout(gbBut); gbc.gridx=0; gbc.gridy=1; gbc.ipady=12; pAps.add(txAps,gbc); gbc.gridx=1; gbc.gridy=0; gbc.ipadx=100; pAps.setBackground(Color.lightGray); add(pAps,gbc); setSize(300,300); setVisible(true); } }
OUTPUT :
Label: JAVA MOKLET
0 komentar:
Posting Komentar