傻大方


首页 > 学习 >

贪吃|贪吃蛇源代码JavaApplet小程序( 三 )



按关键词阅读:


menuItemi.setFont( new Font( Courier, Font.PLAIN, 12 ) );
menuItemi.addActionListener( new ActionHandler() );
menu0.add( m 。

30、enuItem0 );
menu0.add( menuItem1 );
menu0.addSeparator();
menu0.add( menuItem2 );
menu1.add( menuItem3 );
menu2.add( menuItem4 );
String inner_menu_name = Game Speed, Window Model, Game Standard ;
JMenu inner_menu = new JMenuinner_menu_name.length;
for( inti = 0;
iinner_menu_name.length;
i+ ) inner_ 。

31、menui = new JMenu( inner_menu_namei );
inner_menui.setFont( new Font( Courier, Font.PLAIN, 12 ) );
menu1.add( inner_menui );
ButtonGroup temp1 = new ButtonGroup();
String speedItem_name = Speed-1, Speed-2, Speed-3, Speed-4, Speed-5;
speedItem = new JRadioButtonMenuItemspeedItem_name.length;
for( int 。

32、i = 0;
ispeedItem_name.length;
i+ ) speedItemi = new JRadioButtonMenuItem( speedItem_namei );
inner_menu0.add( speedItemi );
speedItemi.setFont( new Font( Courier, Font.PLAIN, 12 ) );
speedItemi.addItemListener( new ItemHandler() );
temp1.add( speedItemi );
ButtonGroup temp2 = new ButtonGroup();
Str 。

33、ing modelItem_name = Linux, Mac, Windows ;
modelItem = new JRadioButtonMenuItemmodelItem_name.length;
for( inti = 0;
imodelItem_name.length;
i+ ) modelItemi = new JRadioButtonMenuItem( modelItem_namei );
inner_menu1.add( modelItemi );
modelItemi.setFont( new Font( Courier, Font.PLAIN, 12 ) );
modelI 。

34、temi.addItemListener( new ItemHandler() );
temp2.add( modelItemi );
ButtonGroup temp3 = new ButtonGroup();
String standardItem_name = 60 * 40, 45 * 30, 30 * 20 ;
standardItem = new JRadioButtonMenuItemstandardItem_name.length;
for( inti = 0;
istandardItem_name.length;
i+ ) standardItemi = new JRadio 。

35、ButtonMenuItem( standardItem_namei );
inner_menu2.add( standardItemi );
standardItemi.setFont( new Font( Courier, Font.PLAIN, 12 ) );
standardItemi.addItemListener( new ItemHandler() );
temp3.add( standardItemi );
looks = UIManager.getInstalledLookAndFeels();
private class ActionHandler implements A 。

36、ctionListener public void actionPerformed( ActionEvent e ) if( e.getSource() = menuItem0 ) owner.resetGame();
ConfigMenu.this.setVisible( false );
else if( e.getSource() = menuItem1 ) owner.stopGame();
ConfigMenu.this.setVisible( true );
ConfigMenu.this.setMenuEnable( true );
else if( e.getSource()。

37、= menuItem2 ) System.exit( 0 );
else if( e.getSource() = menuItem3 ) ConfigDialog temp = new ConfigDialog( owner );
temp.setVisible( true );
else if( e.getSource() = menuItem4 ) JOptionPane.showMessageDialog( null, Sanke Game 2.0 Version!nn + Author: FinalCorenn );
private class ItemHandler implemen 。

38、ts ItemListener public void itemStateChanged( ItemEvent e ) for( inti = 0;
ispeedItem.length;
i+ ) if( e.getSource() = speedItemi ) owner.snakeTimer.setDelay( 150 - 30 * i );
if( e.getSource() = standardItem0 ) owner.setGrid( 60, 40, 5 );
else if( e.getSource() = standardItem1 ) owner.setGrid( 45, 3 。

39、0, 10 );
else if( e.getSource() = standardItem2 ) owner.setGrid( 30, 20, 15 );
for( inti = 0;
imodelItem.length;
i+ ) if( e.getSource() = modelItemi ) try UIManager.setLookAndFeel( looksi.getClassName() );
catch(Exception ex) public void setMenuEnable( boolean temp ) menu1.setEnabled( temp );
Config 。

40、Dialog.java package SnakeGame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ConfigDialog extends JDialog private Container c;
private JFrame owner;
private OwnPanel panel = new OwnPanel4;
Box box1, box2;
private JButtoncommitButton, cancelButton;
Color color = new C 。

41、olor4;
public ConfigDialog( Frame owner ) this.owner = (JFrame) owner;
this.setSize( 400, 200 );
this.setResizable( false );
this.setTitle( Config Your Game );
this.c = this.getContentPane();
this.c.setBackground( Color.WHITE );
this.c.setLayout( new FlowLayout() );
this.box1 = Box.createVerticalBox 。

42、();
for( inti = 0;
ipanel.length;
i+ ) paneli = new OwnPanel();
paneli.addActionListener( new ActionHandler() );
this.box1.add( paneli );
this.box1.add( Box.createVerticalStrut( 4 ) );
this.panel0.setText( Background );
this.panel1.setText( Snake );
this.panel2.setText( Bean );
this.panel3.setText(。

43、EatedBean );
this.panel0.setBack( ColorGroup.COLOR_BACK );
this.panel1.setBack( ColorGroup.COLOR_SNAKE );
this.panel2.setBack( ColorGroup.COLOR_BEAN );
this.panel3.setBack( ColorGroup.COLOR_EATEDBEAN );
this.box2 = Box.createHorizontalBox();


稿源:(未知)

【傻大方】网址:/a/2021/0711/0022845681.html

标题:贪吃|贪吃蛇源代码JavaApplet小程序( 三 )


上一篇:高压线|高压线防护满堂脚手架施工方案

下一篇:冬季箱梁蒸汽养生施工工艺标准|冬季箱梁蒸汽养生施工工艺标准