SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 27th, 2002, 01:44 PM
H@voc_!nc.'s Avatar
H@voc_!nc. H@voc_!nc. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Belgium
Posts: 39 H@voc_!nc. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 48 sec
Reputation Power: 8
Send a message via ICQ to H@voc_!nc.
Prob with stupid exercise from school

underneath is an excercise in model viewer stuff of java (the 1.1 model)
you need to build 2 canvasses a control-panel with 5 buttons and a canvas for painting a square on with the size of the value on the button (my english is crap )
the buttons have to be in an array (she showed it with button[1], button[2] but whats the point of that????...)

this source-code isn't complete yet but try to expalin me
PHP Code:
 package modelviewconoef1;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;



public class 
clsOef1 extends Applet {
  private 
paintCanvas paintBoard;
  
//private controlsPanel controlPanel;
  //initialize applet
  
public void init(){
    
setLayout(new BorderLayout());

    
//paintCanvas = new Canvas(controlPanel);


    /*
    controlPanel = new Panel();
    add(controlPanel,BorderLayout.NORTH);
    */
  
}
  
/*
  public void paint(Graphics g){
      paintBoard = new paintCanvas(10);
      paintBoard.paint(g);
  }
  */
}
class 
paintCanvas extends Canvas{
  private 
int sideSquare 0;
  private 
Color bgColor Color.orange;
  private 
Color fgColor Color.blue;
  private 
int posX 50;
  private 
int posY 50;

  
//constructor
  
paintCanvas(int sideSquare){
    
this.sideSquare sideSquare;

    
//Set Background for canvas
    
setBackground(this.bgColor);
  }
  public 
void paint(Graphics g){
    
g.setColor(this.fgColor);
    
g.fillRect(this.posX,this.posY,this.posX this.sideSquare,this.posY this.sideSquare);
  }
}
class 
controlPanel extends Panel{
  private 
paintCanvas paintBoard;
  private 
Button[] controlButton = new Button[4];
  private ????  
postion = new ...[4]  //has to be aan array with the places of the button

  
controlPanel(paintCanvas paintBoard){
           
this.paintBoard paintBoard;
      
      for(
int i 0;controlButton.length ;i++){
    
this.controlButton[i] = new Button("" 10);
    
this.controlButton[i].addActionListener(new controlPanelHandler(i*10));
                
// here has to go the  place of the button
    
add(this.controlButton[i],????????);

      }
  }
}
class 
controlPanelHandler implements ActionListener{
    private 
int sideSquare;
    
controlPanelHandler(int sideSquare){
        
this.sideSquare sideSquare;
    }
    
// this has to be the action handler but it gives an error because he doesnt knwo paintBoard...
        
public void actionPerformed(ActionEvent e){
        
paintBoard.sideSquare this.sideSquare;
        
paintBoard.repaint();
    }



I tried to clearify the meaning as good as possible.
but imho the lessons in JAVA an any other programming-language (Visual basic )SUX in our school

does anyone know good tutorials on the net ( I'm interested in making a chatapplet... but I want to learn something not copy-paste source-code ....

sincerely

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Prob with stupid exercise from school


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway