按关键词阅读:
mitButton = new JButton( 确定 );
mitButton.setFont( Font.get 。
44、Font( Fixedsys ) );
mitButton.addActionListener( new ActionHandler() );
this.cancelButton = new JButton( 取消 );
this.cancelButton.setFont( Font.getFont( Fixedsys ) );
this.cancelButton.addActionListener( new ActionHandler() );
this.box2.add( mitButton );
this.box2.add( Box.createHorizontalStrut( 20 ) 。
45、 );
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 voi 。
46、d setOwnerColor( Color temp ) this.owner.getContentPane().setBackground( temp );
private class ActionHandler implements ActionListener public void actionPerformed( ActionEvent e ) for( inti = 0;
icolor.length;
i+ ) if( e.getSource() = paneli.reButton() ) colori = JColorChooser.showDialog( ConfigDial 。
47、og.this, Choose BackGround Color, Color.WHITE );
if( colori != null ) paneli.setBack( colori );
if( e.getSource() = commitButton ) color0 = (color0=null?ColorGroup.COLOR_BACK:color0);
color1 = (color1=null?ColorGroup.COLOR_SNAKE:color1);
color2 = (color2=null?ColorGroup.COLOR_BEAN:color2);
color3 =。
48、(color3=null?ColorGroup.COLOR_EATEDBEAN:color3);
ConfigDialog.this.setVisible( false );
ColorGroup.setCOLOR_BACK( color0 );
owner.getContentPane().setBackground( color0 );
ColorGroup.setCOLOR_SNAKE( color1 );
ColorGroup.setCOLOR_BEAN( color2 );
ColorGroup.setCOLOR_EATEDBEAN( color3 );
ConfigDialog.t 。
49、his.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 ) );
。
50、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.se 。
51、tName( 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.addActionListener( ac );
Tools.java package SnakeGame;
import java.a 。
52、wt.*;
import javax.swing.*;
class ColorGroup static Color COLOR_BACK = Color.WHITE;
static Color COLOR_SNAKE = new Color( 43, 110, 187 );
static Color COLOR_BEAN = Color.BLUE;
static Color COLOR_EATEDBEAN = Color.CYAN;
static void setCOLOR_BACK( Color temp ) COLOR_BACK = temp;
static void setCOLOR_S 。
53、NAKE( Color temp ) COLOR_SNAKE = temp;
static void setCOLOR_BEAN( Color temp ) COLOR_BEAN = temp;
static void setCOLOR_EATEDBEAN( Color temp ) COLOR_EATEDBEAN = temp;
final class MenuGet public static JMenugetMenu( String temp ) JMenureMenu = new JMenu( temp );
reMenu.setFont( Font.getFont( Fixedsys 。
54、 ) );
return reMenu;
final class MenuItemGet public static JMenuItemgetMenuItem( String temp ) JMenuItemreMenuItem = new JMenuItem( temp );
reMenuItem.setFont( Font.getFont( Fixedsys ) );
return reMenuItem;
SnakeGame.Javapackage SnakeGame;
import javax.swing.*;
public class SnakeGame public static v 。
55、oid main( String args ) JDialog.setDefaultLookAndFeelDecorated( true );
GameFrame temp = new GameFrame();
Snake.java package SnakeGame;
import java.awt.*;
import java.util.*;
class Snake extends LinkedList public intsnakeDirection = 2;
public intsnakeReDirection = 4;
public Snake() this.add( new Poi 。
56、nt( 3, 3 ) );
this.add( new Point( 4, 3 ) );
this.add( new Point( 5, 3 ) );
this.add( new Point( 6, 3 ) );
this.add( new Point( 7, 3 ) );
this.add( new Point( 8, 3 ) );
this.add( new Point( 9, 3 ) );
this.add( new Point( 10, 3 ) );
public void changeDirection( Point temp, int direction ) this.snakeD 。
57、irection = direction;
switch( direction ) case 1:/up this.snakeReDirection = 3;
this.add( new Point( temp.x, temp.y - 1 ) );
break;
case 2:/right this.snakeReDirection = 4;
this.add( new Point( temp.x + 1, temp.y ) );
break;
case 3:/down this.snakeReDirection = 1;
this.add( new Point( temp.x, temp.y + 1 ) );
稿源:(未知)
【傻大方】网址:/a/2021/0711/0022845681.html
标题:贪吃|贪吃蛇源代码JavaApplet小程序( 四 )