java小游戏-贪吃蛇__教程 |
|
日期:2007-5-20 1:28:10 人气:294 [大 中 小] |
|
|
|
} }
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.addActionListener( ac ); } }
Tools.java
package SnakeGame;
import java.awt.*; 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_SNAKE( 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 JMenu getMenu( String temp ) { JMenu reMenu = new JMenu( temp ); reMenu.setFont( Font.getFont( "Fixedsys" ) ); return reMenu; } }
final class MenuItemGet { public static JMenuItem getMenuItem( String temp ) { JMenuItem reMenuItem = new JMenuItem( temp ); reMenuItem.setFont( Font.getFont( "Fixedsys" ) ); return reMenuItem; } } |
|
出处:本站原创 作者:佚名 |
|
|