Selasa, 20 Juli 2010

kalkulator sederhana

Tugas Pemrograman Berbasis Objek (java)

kalkulator sederhana tanpa operasi, hanya tampilan ajjah..
buat temen - tmen yg dptin tugas ini.
tinggal COPAS ajjah yang cetak tebal..












tampilannya kayak gini gan..


import java.awt.*;
class ComplexLayout extends Frame {
   public static void main(String args[]) {
      ComplexLayout cl = new ComplexLayout();
      Panel panelNorth = new Panel();
      Panel panelWest = new Panel();
      Panel panelSouth = new Panel();
     
      /* North Panel */
      panelNorth.setLayout(new GridLayout(1,1,2,2));
      panelNorth.add(new TextField(""));
     
      /* West Panel */
      panelWest.setLayout(new GridLayout(1,1,2,2));
      panelWest.add(new Button("Backspace"));
      panelWest.add(new Button("CE"));
      panelWest.add(new Button("C"));
     
      /* South Panel */
      panelSouth.setLayout(new GridLayout(4,6,7,7));
      panelSouth.add(new Button("MC"));
      panelSouth.add(new Button("7"));
      panelSouth.add(new Button("8"));
      panelSouth.add(new Button("9"));
      panelSouth.add(new Button("/"));
      panelSouth.add(new Button("sqrt"));
      panelSouth.add(new Button("MR"));
      panelSouth.add(new Button("4"));
      panelSouth.add(new Button("5"));
      panelSouth.add(new Button("6"));
      panelSouth.add(new Button("x"));
      panelSouth.add(new Button("%"));
      panelSouth.add(new Button("MS"));
      panelSouth.add(new Button("1"));
      panelSouth.add(new Button("2"));
      panelSouth.add(new Button("3"));
      panelSouth.add(new Button("-"));
      panelSouth.add(new Button("1/x"));
      panelSouth.add(new Button("M+"));
      panelSouth.add(new Button("0"));
      panelSouth.add(new Button("+/-"));
      panelSouth.add(new Button("."));
      panelSouth.add(new Button("+"));
      panelSouth.add(new Button("="));
     
       /* memasukkanPanels dalam container Frame */
      //Frame menggunakan BorderLayout secara default
      cl.add(panelNorth, BorderLayout.NORTH);
      cl.add(panelWest, BorderLayout.WEST);
     cl.add(panelSouth, BorderLayout.SOUTH);
      cl.setSize(300,250);
      cl.setVisible(true);
   }
}


cikidot gan......
slamat mencoba.

Tidak ada komentar:

Posting Komentar