Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 0.83 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import javax.swing.*;
  2. import java.awt.*;
  3. public class paint extends JFrame{
  4.                 public paint(){
  5.                         //Layout
  6.                         BorderLayout bor=new BorderLayout();
  7.                         Panel buttons=new Panel();
  8.                         Panel drawSpace=new Panel();
  9.                         //frame stuff
  10.                         setTitle("My Drawing :)");
  11.                         setVisible(true);
  12.                         setSize(700,500);
  13.                         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  14.                         //buttons
  15.                         JButton greenBtn=new JButton("Green");
  16.                         JButton blueBtn=new JButton("Blue");
  17.                         JButton redBtn=new JButton("Red");
  18.                         JButton eraserBtn=new JButton("Erase");
  19.                         //setup panels
  20.                         buttons.add(greenBtn);
  21.                         buttons.add(blueBtn);
  22.                         buttons.add(redBtn);
  23.                         buttons.add(eraserBtn);
  24.                        
  25.                         //setup frame
  26.                         bor.addLayoutComponent(BorderLayout.SOUTH,buttons);
  27.                         bor.addLayoutComponent(BorderLayout.CENTER, drawSpace);
  28.         }
  29.         public static void main(String[]args){
  30.                 paint MS=new paint();
  31.         }
  32. }