Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a canvas with scrollbars

Status
Not open for further replies.

MandyProg

Technical User
Jan 19, 2005
2
0
0
US
Hiya. Im studying Java where I work and figured I could do this easily enough, but it only made it really obvious how bad I am at it (go figure!)!
Im so frustrated I could almost cry sometimes.

What I want do learn to do is create a canvas (is that the proper word?) from scratch and place upon it 2 scrollbars. For some reason I get errors all over my code when I try and do that! My code is

Code:
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;


public class ColourChooser {
    public ColourChooser() {
        
        /*I want to be able to create the scrollbar characteristics here and
          then instiate them down below...but I'll try and get it working first! */
    }

    public static void main(String[] args) {
        //Main Method
        ColourChooser colourchooser = new ColourChooser();
        JFrame f = new JFrame();
        f.setSize(400, 400);
        Slider1=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
        add(Slider1);
        Slider2=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
        add(Slider2);

    }
}

Please help!

 
I guess you'll need to post the errors you get in order to help you.

Anyway, at first sight looks like you need to replace add with f.add() and you miss a f.show() at the end of the main() method.

Cheers,

Dian
 
Super! I was missing the f.show command :) Had some other errors too, but a nice warm cup of coffee and a few minutes away from the computer for a think solved that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top