怎么在toolbar上添加按钮

怎么在toolbar上添加按钮,第1张

Java Swing本身提供了现成的按钮控件JButton

创建一个新的按钮:JButton about = new JButton;

这个按钮该放到菜单区:toolBar.add(about)

要为按钮添加事件响应,需要使用about.addActionListener(this)来告诉程序监听按钮按下时的事件,ActionListener是一个程序接口。

public class KyodaiUI extends JFrame implements ActionListener {...}实现ActionListener接口是为了告诉程序我要进行事件处理了。

最后我们得添加响应事件的代码:

public void actionPerformed(ActionEvent e) {

if (e.getSource() == about) {

jplayer (ssssssss) 表达不明确,请问是要添加eclipse系统的toolbar按钮还是要添加eclipse程序的toolbar按钮呢

1。eclipse系统的按钮你可以在Windows-Show View中选择或者在toolbar上右键选择“自定义”

2。eclipse程序的toolbar按钮,挂上VE,可以很直观的看到用法。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/bake/11936972.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存