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

📄 jmenu1.java

📁 《精通Java Swing程序设计S》这本书所附带的JAVA程序写得很漂亮,都是SWING的实例子,很适合初学者。
💻 JAVA
字号:
import javax.swing.*;
import java.awt.event.*;

public class JMenu1 extends JFrame{

	JTextArea theArea = null;

	public JMenu1(){
	  
	  super("JMenu1");
	  theArea = new JTextArea();
	  theArea.setEditable(false);
	  getContentPane().add(new JScrollPane(theArea));
	  JMenuBar MBar = new JMenuBar();
	  
	  JMenu mfile = buildFileMenu();

	  MBar.add(mfile);  
	  setJMenuBar(MBar);
	}//end of JMenu1()

	public JMenu buildFileMenu() {
  	
	  JMenu thefile = new JMenu("File");
	  thefile.setIcon(new ImageIcon("icons/file.gif"));

	  return thefile;
	}//end of buildFileMenu()

	
	public static void main(String[] args){

	  JFrame F = new JMenu1();
	  F.setSize(400,200);
	  F.addWindowListener(new WindowAdapter() {
	    public void windowClosing(WindowEvent e) {
	      System.exit(0); 
	    }
	  });//end of addWindowListener
	  F.setVisible(true); 
	} // end of main
}//end of class JMenu1

⌨️ 快捷键说明

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