⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cconfigframe.java

📁 网上收集的
💻 JAVA
字号:
package chiidanceapp;


import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JRadioButton;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import java.util.Hashtable;
import javax.swing.JTable;
import javax.swing.JLabel;
import java.util.ResourceBundle;

public class CConfigFrame extends JFrame{

   static ResourceBundle res = ResourceBundle.getBundle("chiidanceapp.Res1");
  int FrameWidth = 210;//150
   int FrameHeight = 270;//250
   int ScreenWidth;
   int ScreenHeight;

   Dimension dimension;
   Toolkit tk = Toolkit.getDefaultToolkit();
   CClipPlayerThread ClipPlayerThread = new CClipPlayerThread( 2 );

   public CConfigFrame()
   {
     dimension = tk.getScreenSize();
     ScreenWidth = dimension.width;
     ScreenHeight = dimension.height;

     CConfigPanel ConfigPanel = new CConfigPanel();

     this.getContentPane().add(ConfigPanel);
     this.setIconImage(  tk.getImage( "Resource/images/kurochii[1].gif" ));
     this.setTitle( "游戏设置" );
     this.setResizable( false );
     this.setSize( FrameWidth,FrameHeight );
     this.setLocation( ScreenWidth/2 - FrameWidth/2,ScreenHeight/2 - FrameHeight/2 );

     this.show();
   }

   private class CConfigPanel extends JPanel implements ItemListener
   {

      ButtonGroup BG = new ButtonGroup();
      JRadioButton optWindow = new JRadioButton( "窗口游戏方式" );
      JRadioButton optFullScreen = new JRadioButton( "全屏游戏方式" );

      JButton btnOK = new JButton( "确定" );
      JButton btnNO = new JButton( "取消" );

      Slider slider = new Slider();

      public CConfigPanel(){
       CLoad Load = new CLoad();
       configdata aData;
       aData = ( configdata )Load.loadGame();

       if( aData.getIsFullScreen() == 1 )
       {
         optFullScreen.setSelected( true );
       }
       else
       {
         optWindow.setSelected( true );
       }
       BG.add( optWindow );
       BG.add( optFullScreen );
       /*
       Choice choice = new Choice();
       Choice choiceBPP = new Choice();
       this.add(new JLabel("画面分辨率"));
       choice.add( "800X600" );
       choice.add( "1024X768" );

       this.add(new JLabel("发色数"));
       choiceBPP.add( "    16 bit  " );
       choiceBPP.add( "    32 bit  " );

       choice.addItemListener( this );
       choiceBPP.addItemListener( this );
       */

       btnOK.addActionListener( new OkAction() );
       btnNO.addActionListener( new CancelAcion() );

       this.add( new JLabel( "游戏显示方式                " ) );
       this.add( optWindow );
       this.add( optFullScreen );

       this.add( new JLabel( "刷屏速度                   " ) );
       this.add( slider );

       //this.add( choice );
       //this.add( choiceBPP );
       this.add( new JLabel( "                          " ) );
       this.add( new JLabel( "                          " ) );

       this.add( btnOK );
       this.add( btnNO );
      }

    private class Slider extends JSlider
    {
      public Slider()
      {
        this.setMinimum( 1 );
        this.setMaximum( 4 );
        this.setPaintTicks( true );
        this.setPaintLabels( true );
        this.setMajorTickSpacing( 1 );
        this.setMinorTickSpacing( 1 );
        this.setSnapToTicks( true );

        CLoad Load = new CLoad();
        this.setValue( Load.loadRefleshSpeed() );

        Hashtable LableTable = new Hashtable();
        LableTable.put( new Integer( 1 ),new JLabel( "慢" ) );
        LableTable.put( new Integer( 2 ),new JLabel( "一般" ) );
        LableTable.put( new Integer( 3 ),new JLabel( "较快" ) );
        LableTable.put( new Integer( 4 ),new JLabel( "最快" ) );

        this.setLabelTable( LableTable );

        this.setToolTipText( "设置游戏的刷屏速度,速度越高占用CPU资源越高,动画效果最好" );

        this.addChangeListener( new SliderListener());
      }
    }

    private class SliderListener implements ChangeListener
    {
      int Value;

      public int getValue()
      {
        return this.Value;
      }
      public void stateChanged( ChangeEvent event ) {
        JSlider source = ( JSlider )event.getSource();
        this.Value = source.getValue();
        System.out.println( source.getValue() );
      }
    }

    private class OkAction implements ActionListener {

      public void actionPerformed( ActionEvent actionEvent ) {
        configdata data ;
        CSave save = new CSave();
        save.saveReflesh( slider.getValue() );

        if( optWindow.isSelected() )
        {
          data = new configdata( 800,600,32,0 );
          save.saveConfig( data );
          ClipPlayerThread.openClipThread();
          JOptionPane.showMessageDialog( null,
                                         "Chii:\n保存完毕,设置将在游戏重启后生效。",
                                         "保存确定",
                                         JOptionPane.INFORMATION_MESSAGE,
                                         new ImageIcon( tk.getImage( "Resource/images/chii[1].gif") )
                                        );
          System.exit( 0 );
        }
        else if( optFullScreen.isSelected() )
        {
          data = new configdata( 800,600,32,1 );
          save.saveConfig( data );
          ClipPlayerThread.openClipThread();
          JOptionPane.showMessageDialog( null,
                                         "Chii:\n保存完毕,设置将在游戏重启后生效。",
                                         "保存确定",
                                         JOptionPane.INFORMATION_MESSAGE,
                                         new ImageIcon( tk.getImage( "Resource/images/chii[1].gif") )
                                        );

          System.exit( 0 );
        }
      }
    }

    private class CancelAcion implements ActionListener
    {

      public void actionPerformed( ActionEvent actionEvent ) {
        System.exit( 0 );
      }
    }

    public void itemStateChanged(ItemEvent itemEvent) {
    }


  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -