P. 1
5. Oop Visual

5. Oop Visual

|Views: 1|Likes:
Published by Aulia Ulkhairi

More info:

Published by: Aulia Ulkhairi on Sep 20, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/20/2012

pdf

text

original

OOP VISUAL Contoh 1 : Menampilkan Visual MessageDialog

import javax.swing.*; public class WelcomeSToy { /** Creates a new instance of HelloWorldSToy */ public WelcomeSToy() { } public static void main(String args[]) { JOptionPane.showMessageDialog(null,"Hello World!"); System.exit(0); } }

Contoh 2 : Merancang Form sederhana
import javax.swing.*; import java.awt.*; class visual { public static void main(String args[]) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame GUIku = new JFrame("Tampilan Form Utama"); GUIku.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GUIku.setSize(500,500); GUIku.setLocation(200,150); GUIku.setVisible(true); } }

setLayout(new FlowLayout()).*. } public static void main(String args[]) { new LatihanGUI(). class LatihanGUI extends JFrame { private Container ctn = new Container().Contoh 3 : Merancang Form sederhana dengan Label import javax. import java. setTitle("Tampilan Form Utama"). setLocation(200.swing. ctn.awt.*. ctn = getContentPane(). setVisible(true).150). } } .500). ctn. setSize(500. LatihanGUI() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE).add(new JLabel("Tampilan GUI Pertama")).

add(label4).add(label2). frame.getContentPane().getContentPane().getContentPane().2)).*.setLocation(300. JTextField textField = new JTextField(20).add(label3).getContentPane(). import java.add(label6). label.setVisible(true).pack(). } } . frame. JButton b1 = new JButton("Tombol").*. public class Komponen{ public static void main(String[ ] args){ JFrame frame = new JFrame("Komponen Sederhana"). Font.add(label7). JLabel label = new JLabel("Pemrograman Berorientasi Obyek"). 14)).add(textField). frame.add(label). frame.getContentPane(). frame.setLayout(new GridLayout(0.getContentPane().add(b1).BOLD.setBackground(Color.getContentPane().getContentPane(). JLabel label6 = new JLabel(""). JLabel label4 = new JLabel("").yellow).setOpaque(true).setDefaultCloseOperation(JFrame. frame. frame. label. JLabel label7 = new JLabel(""). JLabel label5 = new JLabel("Nama :").swing.EXIT_ON_CLOSE). frame.event.setLayout(new FlowLayout()).getContentPane(). JLabel label2 = new JLabel("").add(label5).setFont(new Font("SansSerif".awt.getContentPane().getContentPane(). frame. frame.awt. frame. frame. frame. label.150).*. label. frame.setForeground(Color.Contoh 4 : Merancang Form sederhana dengan beberapa Komponen import javax.blue). frame. JLabel label3 = new JLabel(""). import java.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->