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

📄 rootexample2.java

📁 java swing 开发代码
💻 JAVA
字号:
// RootExample2.java// Another example of interacting with the root pane.  We set the menubar// for the frame directly through the root pane in this example.//package	jswing.ch08;import javax.swing.*;public class RootExample2 {  public static void main(String[] args) {    JFrame f = new JFrame();    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    JRootPane root = f.getRootPane();    // Create a menu bar    JMenuBar bar = new JMenuBar();    JMenu menu = new JMenu("File");    bar.add(menu);    menu.add("Open");    menu.add("Close");    root.setJMenuBar(bar);    // Add a button to the content pane    root.getContentPane().add(new JButton("Hello World"));    // Display the UI    f.pack();    f.setVisible(true);  }}

⌨️ 快捷键说明

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