java如何写贪吃蛇游戏界面
1个回答
展开全部
这是一个最基本的界面,下面又不会的地方去查API
import java.awt.*;
import javax.swing.*;
public class View {
JFrame frame;
Container c;
JLabel backgound;
JButton start;
JLabel help;
public void first(){
frame=new JFrame("我的贪吃蛇");
c=frame.getContentPane();
c.setLayout(null);
Font f1=new Font("楷体",Font.BOLD,50);
backgound=new JLabel();
backgound.setBounds(0,0,800,600);
c.add(backgound);
backgound.setLayout(null);
start=new JButton();
start.setBounds(300,70,200,58);
start.setCursor(new Cursor(Cursor.HAND_CURSOR));
start.setBorder(null);
start.setContentAreaFilled(false);
backgound.add(start);
help = new JLabel();
help.setText("游戏帮助");
help.setBounds(180,230,500,50);
help.setForeground(Color.black);
help.setFont(f1);
backgound.add(help);
frame.setSize(800,600);
frame.setResizable(false);
frame.setVisible(true);
}
import java.awt.*;
import javax.swing.*;
public class View {
JFrame frame;
Container c;
JLabel backgound;
JButton start;
JLabel help;
public void first(){
frame=new JFrame("我的贪吃蛇");
c=frame.getContentPane();
c.setLayout(null);
Font f1=new Font("楷体",Font.BOLD,50);
backgound=new JLabel();
backgound.setBounds(0,0,800,600);
c.add(backgound);
backgound.setLayout(null);
start=new JButton();
start.setBounds(300,70,200,58);
start.setCursor(new Cursor(Cursor.HAND_CURSOR));
start.setBorder(null);
start.setContentAreaFilled(false);
backgound.add(start);
help = new JLabel();
help.setText("游戏帮助");
help.setBounds(180,230,500,50);
help.setForeground(Color.black);
help.setFont(f1);
backgound.add(help);
frame.setSize(800,600);
frame.setResizable(false);
frame.setVisible(true);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询