JPanel/ScrollBar Bug

J

Jenny

Hi,

When I move the thumn on the 4th bar, the JPanel displays a scrollbar.
Could you help me to report it to Sun?

Here is the code.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ColorDemo extends JFrame
implements AdjustmentListener{
private JScrollBar scrollerR;
private JScrollBar scrollerG;
private JScrollBar scrollerB;
private JScrollBar scrollerA;
private JLabel labelA = new JLabel("Alpha:");
private JLabel labelR = new JLabel("Red:");
private JLabel labelG = new JLabel("Green:");
private JLabel labelB = new JLabel("Blue:");
private JPanel labelColor= new JPanel();

public static void main(String[] args){
ColorDemo f = new ColorDemo ("Demo");
}
ColorDemo(String s){
super(s);
scrollerR = new JScrollBar( scrollerR.HORIZONTAL,100, 0, 0, 255 );
scrollerR.setPreferredSize( new Dimension( 200, 15 ));
scrollerR.addAdjustmentListener( this );
scrollerG = new JScrollBar( scrollerR.HORIZONTAL,100, 0, 0, 255 );
scrollerG.setPreferredSize( new Dimension( 200, 15 ));
scrollerG.addAdjustmentListener( this );
scrollerB = new JScrollBar( scrollerR.HORIZONTAL,100, 0, 0, 255 );
scrollerB.setPreferredSize( new Dimension( 200, 15 ));
scrollerB.addAdjustmentListener( this );
scrollerA = new JScrollBar( scrollerR.HORIZONTAL,100, 0, 0, 255 );
scrollerA.setPreferredSize( new Dimension( 200, 15 ));
scrollerA.addAdjustmentListener( this );
FlowLayout flo = new FlowLayout(FlowLayout.LEFT,10,20);
Container pane = getContentPane();
pane.setLayout(flo);
pane.add(labelR);
pane.add(scrollerR);
pane.add(labelG );
pane.add(scrollerG);
pane.add(labelB );
pane.add(scrollerB);
pane.add(labelA );
pane.add(scrollerA);
Dimension d = new Dimension(200,100);
labelColor.setPreferredSize(d);
labelColor.setBackground(Color.white);
pane.add(labelColor);
setSize(280,300);
setLocation(200,150);
setVisible(true);
}

public void adjustmentValueChanged( AdjustmentEvent event ){
int r = scrollerR.getValue();
int g = scrollerG.getValue();
int b = scrollerB.getValue();
int a = scrollerA.getValue();
labelColor.setOpaque(true);
labelColor.setBackground(new Color(r,g,b,a));
labelColor.repaint();
}
}
 
A

Andrew Thompson

On 26 Aug 2004 08:44:01 -0700, Jenny wrote:

Hi Jenny!

Some of my posts have apparently not made it through to the
Google archive, so I have just reposted a response to the
'Color Bug' thread that might help explain problems you
might be experiencing with painting using 'alpha values'
When I move the thumn on the 4th bar, the JPanel displays a scrollbar.
Could you help me to report it to Sun?
private JLabel labelA = new JLabel("Alpha:"); ...
public void adjustmentValueChanged( AdjustmentEvent event ){
int r = scrollerR.getValue();
int g = scrollerG.getValue();
int b = scrollerB.getValue();
int a = scrollerA.getValue();
labelColor.setOpaque(true);
labelColor.setBackground(new Color(r,g,b,a));
labelColor.repaint();
}
}

Have a look over that thread (asssuming it
shows up this time!) and see how you go.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top