?? 幫助信息.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 + -