收藏 Java初学者,下周六程序设计答辩,窗体设计,在网上找的程序,想自己加个菜单,帮助菜单项如何实现??望前辈们指导一下,很急!!谢啦! [问题点数:40
我是想在这个游戏中加一个帮助菜单,然后下拉菜单项是游戏说明,可是点了说明以后怎么出来那个文本框啊?各位大神帮帮忙吧,之前没好好听课,现在后悔了,我是真的很想明白!最好能给解释一下行吗?
谢谢啦!!
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.ItemListener;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
public class Pintu extends JFrame implements MouseListener,ItemListener,KeyListener{
static final long serialVersionUID = 1L;
JList listResult;
JPanel panMain;
JPanel panGame;
JPanel panRight;
DefaultComboBoxModel dcbm;
JMenuBar mbar;//创建菜单栏
JMenu help;//创建菜单
JMenuItem shuoming;//创建菜单项
JTextField txtCount;
JTextField txtLevel;
JLabel [][] labels;
final int MAX_LEVEL = 10;
int[][] nums;
int level;
long clickCount = 0L;
/**
* Create the frame
*/
public Pintu() {
super();
addComponentListener(new ComponentAdapter() {
public void componentResized(final ComponentEvent e) {
JFrame jf = (JFrame)e.getSource();
if(jf.getHeight()<400) jf.setSize(jf.getWidth(),400);
if(jf.getWidth()<600) jf.setSize(600,jf.getHeight());
panRight.setBounds(jf.getWidth()-panRight.getWidth()-10,10,panRight.getWidth(),jf.getContentPane().getHeight()-20);
panGame.setBounds(10,10,jf.getWidth()-panRight.getWidth()-30,jf.getContentPane().getHeight()-20);
listResult.setSize(listResult.getWidth(), panRight.getHeight()-listResult.getY()-10);
}
});
setName("frmMain");
setTitle("拼图");
setBounds(100, 100, 579, 438);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mbar = new JMenuBar();
this.setJMenuBar(mbar); //把菜单栏显示在窗口中
help = new JMenu("帮助");
mbar.add(help);//把菜单加入菜单栏中
shuoming= new JMenuItem("说明");
help.add("说明");//把菜单项加入菜单中
panMain = new JPanel();
panMain.setLayout(null);
getContentPane().add(panMain, BorderLayout.CENTER);
panGame = new JPanel();
panGame.setLayout(null);
panGame.setBounds(10, 10, 358, 385);
panMain.add(panGame);
panRight = new JPanel();
panRight.setBackground(Color.CYAN);