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

📄 帮助信息.java

📁 本程序用java编写的汉偌塔游戏汉偌塔最终版
💻 JAVA
字号:
import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class 帮助信息 extends JDialog               //帮助信息Dialog窗口
{
	
    private ImagePanel imagePanel;   //绘制图像的面板
	//声明并创建面板对象
    JPanel panel1 = new JPanel();
   
  
    //设置布局管理器
    GridLayout gridLayout1 = new GridLayout(5,1);
   //获取内容面板
	Container container = getContentPane();
	    
    //构造函数重载
    public 帮助信息()                                             
    {
    	//调用父类构造方法
         super(new Frame(), "游戏信息", false);
         
        imagePanel = new ImagePanel();
	    container.add(imagePanel, BorderLayout.CENTER);
	     
    //创建文字标签对象
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    this.setBounds(150,150,400,400); //设置窗口大小
         
        //设置帮助信息窗口中的显示信息

        panel1.setLayout(gridLayout1);
      
        jLabel1.setForeground(Color.cyan); 
       // Font f=new Font( "Dialog",Font.BOLD,11);
        //jLabel1.setFont( f);
        jLabel1.setText("汉诺塔小游戏程序1.0版本,谢谢支持");
        jLabel2.setForeground(Color.red);
        jLabel2.setText("作者:王宏伟");
        jLabel3.setForeground(Color.BLUE);
        jLabel3.setText("游戏目标:将第一个柱子中的金盘按原有顺序移到第三个柱子");
        jLabel4.setForeground(Color.DARK_GRAY);
        jLabel4.setText("游戏说明:光标键:选择所要移动的盘子所在的杆");
        jLabel5.setForeground(Color.cyan);
        jLabel5.setText("回车键:移动杆子上的盘子");
        //gridLayout1.setColumns(1);
        //gridLayout1.setRows(2);

        panel1.add(jLabel1, null);
        panel1.add(jLabel2);
        panel1.add(jLabel3);
        panel1.add(jLabel4);
        panel1.add(jLabel5);
        container.add(panel1,BorderLayout.SOUTH);

    }
      class ImagePanel extends JPanel 
    {
    	private ImageIcon images;
    
    	
        public ImagePanel() 
        {
        	super();
        	setBackground(Color.WHITE);
      
                //载入图像
        //	images= new ImageIcon("boy01.png");
        images= new ImageIcon("帮助信息.jpg");
                             
        
        }
        
        public void paintComponent(Graphics g) 
        {
            Graphics2D g2d=(Graphics2D)g;
            g2d.setColor(getBackground());
            g2d.fillRect(0, 0, getWidth(), getHeight());
            //绘制图像,坐标为屏幕中心 
            int x = (this.getWidth() - images.getIconWidth())/2;
            int y = (this.getHeight() - images.getIconHeight())/2;
            images.paintIcon(this, g, x, y);
        }
       
    }
}

⌨️ 快捷键说明

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