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

📄 最佳排行.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(4,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();
    
    this.setBounds(150,150,400,400); //设置窗口大小
         
        //设置帮助信息窗口中的显示信息

        panel1.setLayout(gridLayout1);
      
        jLabel1.setForeground(Color.cyan); 
        
        jLabel1.setText("你是超级的高手啊!!!!!!!");
        jLabel2.setForeground(Color.red);
        jLabel2.setText("初级过关次数:3");
        jLabel3.setForeground(Color.BLUE);
        jLabel3.setText("中级过关次数:2");
        jLabel4.setForeground(Color.DARK_GRAY);
        jLabel4.setText("高级过关次数:2");

        panel1.add(jLabel1);
        panel1.add(jLabel2);
        panel1.add(jLabel3);
        panel1.add(jLabel4);
     
        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 + -