-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.1.3
-
None
-
sparc
-
solaris_2.5.1
Name: joT67522 Date: 10/02/97
the rules used to determine the shading of components
does not work correctly on solaris. there are several areas
of concern:
1. by default an editable text field
has a white background. when you
change the color of the textfield,
its background changes to the background
color not a lighter version. The background
of an editable textfield should be lighter.
2. if i change the background color of
a scrollbar dynamically, the trough
changes to black, rather than a darker
shade of the background color.
sometimes when you bring up a new
window, the trough is the same as the
background. this is incorrect.
3. push & check buttons. in some cases
there is no shading. these colors
are able to be shaded, but instead
a black borser completely surrounds
the component. this happens on
other components as well.
I have included some code demonstrates the problesms.
it allows you to cycle through 6 colors to see. the
different effects.
------ code follows ------------
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class ColorTest extends Applet {
public void init(){}
public static void main( String args[] ) {
MyFrame frame = new MyFrame();
frame.show();
}
}
class MyFrame extends Frame implements ActionListener {
Button color, launch, launch2;
Scrollbar sb;
TextField t;
Checkbox c;
static int first = 1;
Values values = Values.getValues();
public MyFrame() {
super();
MenuBar mb = new MenuBar();
setMenuBar( mb );
Menu m = new Menu( "TEST" );
MenuItem mi = new MenuItem( "TEST item" );
m.add( mi );
mb.add( m );
Panel p = new Panel();
p.setLayout( new GridLayout( 6, 1, 3, 3 ));
sb = new Scrollbar( Scrollbar.HORIZONTAL, 0, 20, 0, 100 );
p.add( sb );
t = new TextField( "editable", 20 );
p.add( t );
t = new TextField( "not-editable", 20 );
t.setEditable( false );
p.add( t );
c = new Checkbox( "checkbox" );
p.add( c );
color = new Button( "Change Color" );
color.addActionListener( this );
p.add( color );
launch = new Button( "New Window - default color" );
launch.addActionListener( this );
p.add( launch );
launch2 = new Button( "New Window - changed color" );
launch2.addActionListener( this );
p.add( launch2 );
add( p );
setSize( getPreferredSize() );
pack();
}
public MyFrame( boolean b) {
super();
MenuBar mb = new MenuBar();
setMenuBar( mb );
Menu m = new Menu( "TEST" );
MenuItem mi = new MenuItem( "TEST item" );
m.add( mi );
mb.add( m );
Panel p = new Panel();
p.setLayout( new GridLayout( 7, 1, 3, 3 ));
setBackground( values.background );
setForeground( values.foreground );
sb = new Scrollbar( Scrollbar.HORIZONTAL, 0, 20, 0, 100 );
p.add( sb );
t = new TextField( "editable", 20 );
p.add( t );
t = new TextField( "not-editable", 20 );
t.setEditable( false );
p.add( t );
c = new Checkbox( "checkbox" );
p.add( c );
color = new Button( "Change Color" );
color.addActionListener( this );
p.add( color );
launch = new Button( "New Window - default color" );
launch.addActionListener( this );
p.add( launch );
launch2 = new Button( "New Window - changed color" );
launch2.addActionListener( this );
p.add( launch2 );
add( p );
setSize( getPreferredSize() );
pack();
}
public void actionPerformed( ActionEvent event ) {
if (event.getSource() == color) {
changeColors();
}
else if ( event.getSource() == launch ) {
new MyFrame().show();
}
else if ( event.getSource() == launch2 ) {
new MyFrame( true ).show();
}
}
private void changeColors() {
if ( first == 1 ) {
values.background = Color.yellow;
values.foreground = Color.blue;
first = 2;
}
else if ( first == 2 ) {
values.background = Color.green;
values.foreground = Color.black;
first = 3;
}
else if ( first == 3 ) {
values.background = Color.blue;
values.foreground = Color.white;
first = 4;
}
else if ( first == 4 ) {
values.background = Color.red;
values.foreground = Color.black;
first = 5;
}
else if ( first == 5 ) {
values.background = new Color( 255, 192, 192 );
values.foreground = Color.black;
first = 6;
}
else if ( first == 6 ) {
values.background = Color.cyan;
values.foreground = Color.black;
first = 1;
}
setBackground( values.background );
setForeground( values.foreground );
}
}
class Values extends Object {
public Color background = Color.yellow;
public Color foreground = Color.blue;
private static Values current = null;
static public Values getValues() {
if ( current == null ) {
current = new Values();
}
return current;
}
private Values() {
super();
}
}
======================================================================
- relates to
-
JDK-4182554 setEditable true/false gives different background color in Text Fields / Areas
-
- Closed
-