this.c = this.getcontentpane();
this.c.setbackground( color.white );
this.c.setlayout( new flowlayout() );
this.box1 = box.createverticalbox();
for( int i = 0; i < panel.length; i++ )
{
panel[i] = new ownpanel();
panel[i].addactionlistener( new actionhandler() );
this.box1.add( panel[i] );
this.box1.add( box.createverticalstrut( 4 ) );
}
this.panel[0].settext( " background" );
this.panel[1].settext( " snake" );
this.panel[2].settext( " bean" );
this.panel[3].settext( " eatedbean" );
this.panel[0].setback( colorgroup.color_back );
this.panel[1].setback( colorgroup.color_snake );
this.panel[2].setback( colorgroup.color_bean );
this.panel[3].setback( colorgroup.color_eatedbean );
this.box2 = box.createhorizontalbox();
this.commitbutton = new jbutton( "确定" );
this.commitbutton.setfont( font.getfont( "fixedsys" ) );
this.commitbutton.addactionlistener( new actionhandler() );
this.cancelbutton = new jbutton( "取消" );
this.cancelbutton.setfont( font.getfont( "fixedsys" ) );
this.cancelbutton.addactionlistener( new actionhandler() );
this.box2.add( this.commitbutton );
this.box2.add( box.createhorizontalstrut( 20 ) );
this.box2.add( this.cancelbutton );
this.box1.add( this.box2 );
this.c.add( this.box1, borderlayout.north );
this.setlocation( ( this.gettoolkit().getscreensize().width - this.getwidth() )/2,
( this.gettoolkit().getscreensize().height - this.getheight() )/2 );
this.setvisible( true );
}
public void setownercolor( color temp )
{
this.owner.getcontentpane().setbackground( temp );
}
private class actionhandler implements actionlistener
{
public void actionperformed( actionevent e )
{
for( int i = 0; i < color.length; i++ )
{
if( e.getsource() == panel[i].rebutton() )
{
color[i] = jcolorchooser.showdialog( configdialog.this,
"choose background color",
color.white );
if( color[i] != null )
{
panel[i].setback( color[i] );
}
}
}
if( e.getsource() == commitbutton )
{
color[0] = (color[0]==null?colorgroup.color_back:color[0]);
color[1] = (color[1]==null?colorgroup.color_snake:color[1]);
color[2] = (color[2]==null?colorgroup.color_bean:color[2]);
color[3] = (color[3]==null?colorgroup.color_eatedbean:color[3]);
configdialog.this.setvisible( false );
colorgroup.setcolor_back( color[0] );
owner.getcontentpane().setbackground( color[0] );
colorgroup.setcolor_snake( color[1] );
colorgroup.setcolor_bean( color[2] );
colorgroup.setcolor_eatedbean( color[3] );
configdialog.this.dispose();
}
else if( e.getsource() == cancelbutton )
{
configdialog.this.setvisible( false );
configdialog.this.dispose();
}
}
}
}
class ownpanel extends jpanel
{
private jlabel temp1;
private jtextfield temp2;
private jbutton temp3;
ownpanel()
{
temp1 = new jlabel();
temp1.setfont( font.getfont( "fixedsys" ) );
temp2 = new jtextfield();
temp3 = new jbutton( "change" );
temp3.setfont( font.getfont( "fixedsys" ) );
temp2.seteditable( false );
temp2.setcolumns( 10 );
this.add( temp1 );
this.add( temp2 );
this.add( temp3 );
this.setlayout( new gridlayout( 1, 3 ) );
}
public void setbuttonname( string temp )
{
temp3.setname( temp );
}
public void setback( color temp )
{
temp2.setbackground( temp );
}
public void settext( string temp )
{
temp1.settext( temp );
}
public object rebutton()
{
return temp3;
}
public void addactionlistener( actionlistener ac )
{
temp3.addacti