Example simple Script For java


class Mamalia
{
Boolean menyusui = false;
}
class Carnivora extends Mamalia
{
String makanan =”daging”;
}
class Anjing extends Carnivora
{
int kaki =4;
}

class Contoh
{
public static void main(String[]arguments)
{
Anjing herder = new Anjing();
System.out.println(herder.menyusui);
System.out.println(herder.makanan);
System.out.println(herder.kaki);
}
}

import javax.swing.*;

public class SwingFrame {
public static void main( String args[] ) {
JFrame win = new JFrame( “BELAJAR GUI” );

win.show();
}
} // SwingFrame

import javax.swing.*;

public class SwingFrame {
public static void main( String args[] ) {
JFrame win = new JFrame( “BELAJAR GUI” );

win.setSize( 250, 150 );
win.show();
}
} // SwingFrame

import java.awt.*;
import java.applet.*;
public class HelloApplet extends Applet
{
int x, y;
public void init() {
x = 0;
y = 45;
setSize(250, 100);
}
public void paint(Graphics g)
{
g.drawString(“smk telkom malang”, x, y);
}
}

import javax.swing.*;
import java.awt.*;

public class Main extends JApplet
{

public void paint(Graphics g) {

Graphics2D g2d = (Graphics2D) g;
g2d.drawString(“Ini kotak merah”, 0, 15);
g2d.setPaint(Color.red);
g2d.fillRect(20, 20, 30, 50);
}
}

class Data
{
public void over (String tipe)
{
System.out.println(tipe);
}
public void over (double tipe)
{
System.out.println(tipe);
}
public void over (char tipe)
{
System.out.println(tipe);
}
public void over (int tipe)
{
System.out.println(tipe);
}
}

class Bentuk
{
public static void main (String args[])
{
Data simbol= new Data();
System.out.print(“Mencetak data CHARACTER = “);
simbol.over(‘S’);
System.out.print(“Mencetak data STRING = “);
simbol.over(” smk telkom malang”);
System.out.print(“Mencetak data INTEGER = “);
simbol.over(2008);
System.out.print(“Mencetak data DOUBLE = “);
simbol.over(100/7);
}
}

import javax.swing.*;

public class SwingFrame {
public static void main( String args[] ) {
JFrame win = new JFrame( “My First GUI Program” );

win.setSize( 250, 150 );
win.show();
}
}

import javax.swing.JOptionPane;
class Input
{
public static void main (String[] args )
{
String nama;
nama=JOptionPane.showInputDialog(“ketikkan nama”);
JOptionPane.showMessageDialog (null, “Hallo ” + nama, “Pengisian Identitas”, JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}

class Data
{
public void over (String tipe)
{
System.out.println(tipe);
}
public void over (double tipe)
{
System.out.println(tipe);
}
public void over (char tipe)
{
System.out.println(tipe);
}
public void over (int tipe)
{
System.out.println(tipe);
}
}

class Bentuk
{
public static void main (String args[])
{
Data simbol= new Data();
System.out.print(“Mencetak data CHARACTER = “);
simbol.over(‘S’);
System.out.print(“Mencetak data STRING = “);
simbol.over(” STIMIK PRADNYA PARAMITA”);
System.out.print(“Mencetak data INTEGER = “);
simbol.over(2008);
System.out.print(“Mencetak data DOUBLE = “);
simbol.over(100/7);
}
}

import javax.swing.*;

public class SwingFrame {
public static void main( String args[] ) {
JFrame win = new JFrame( “My First GUI Program” );

win.setSize( 250, 150 );
win.show();
}
} // SwingFrame

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s