帮我写一个java左侧菜单
时间: 2023-04-06 20:00:38 浏览: 187
jquery左侧菜单
5星 · 资源好评率100%
好的,我可以为您提供一个 Java 左侧菜单的代码示例:
import javax.swing.*;
import java.awt.*;
public class LeftMenu extends JFrame {
private JPanel panel;
private JButton button1, button2, button3;
public LeftMenu() {
setTitle("左侧菜单");
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
panel.setLayout(new GridLayout(3, 1));
button1 = new JButton("菜单项1");
button2 = new JButton("菜单项2");
button3 = new JButton("菜单项3");
panel.add(button1);
panel.add(button2);
panel.add(button3);
add(panel, BorderLayout.WEST);
setVisible(true);
}
public static void main(String[] args) {
new LeftMenu();
}
}
希望这个代码示例能够帮到您!
阅读全文