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();
}
}
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();
}
}