File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with colorslide

 
Allan Newman
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone tell me what i am doing wrong with this boolean:

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

public class ColorSlide extends JFrame implements ChangeListener {
ColorPanel canvas = new ColorPanel();
JSlider red = new JSlider(0,255,0);
JSlider green = new JSlider(0,255,0);
JSlider blue = new JSlider(0,255,255);

public ColorSlide() {
super("Color Slide");
setSize(270,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

red.setMajorTickSpacing(50);
red.setMinorTickSpacing(10);
red.setPaintTicks(true);
red.SetPaintLabels(true);
red.addChangeListener(this);

green.setMajorTickSpacing(50);
green.setMinorTickSpacing(10);
green.setPaintTicks(true);
green.SetPaintLabels(true);
green.addChangeListener(this);

blue.setMajorTickSpacing(50);
blue.setMinorTickSpacing(10);
blue.setPaintTicks(true);
blue.SetPaintLabels(true);
blue.addChangeListener(this);

JLabel redLabel = new JLabel("Red: ");
JLabel greenLabel = new JLabel("Green: ");
JLabel blueLabel = new JLabel("Blue: ");
GridLayout grid = new GridLayout(4, 1);
FlowLayout right = new FlowLayout(FlowLayout.RIGHT);

JPanel redPanel = new JPanel();
redPanel.setLayout(right);
redPanel.add(redLabel);
redPanel.add(red);
add(redPanel);

i get this message when i try to compile it:

ColorSlide.java://lines 20 26 and 32; cannot find symbol
symbol : method SetPaintLabels(boolean)
location: class javaxlswing.JSlider
//red, green, or blue.SetPaintLabels(true);
^
 
Allan Newman
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about this double post but there was some things wrong in the other one. The ^ on the last line is supposed to be right under the first period.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SetPaintLabels should be setPaintLabels.
 
Allan Newman
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah thank you, but it now has 2 errors, and does compile.

the errors:

ColorSlide.java:87: background is not public in java.awt.Component; cannot be accessed from outside package
comp2D.setColor(background);
^ under b on background

and

ColorSlide.java:92:background is not public in java.awt.Component;cannot be accessed from out side package
background = newBackground;
^ under b on first background



when i compile it i get this error message:

Exception in thread "main" java.lang.NoSuchMethodError: main
 
Allan Newman
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry again for the double post, but at the end i meant once i try to run the class file
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use getBackground and setBackground.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About the runtime error, make sure that the class containing the "main" method is in your CLASSPATH.
About the classpath:
http://faq.javaranch.com/view?HowToSetTheClasspath
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic