JB8工具栏上的那种平的按钮是怎么做出来的? 是toolbarbutton,需要你自己继承JComponent 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class PlainButton extends JButton{ public PlainButton(String caption){ super(caption); setBorderPainted(false); setFocusPainted(false); setRequestFocusEnabled(false); setMargin(new Insets(1, 1, 1, 1)); // Dynamic display tool-button border addMouseListener(new MouseAdapter(){ public void mouseEntered(MouseEvent e){ setBorderPainted(true); } public void mouseExited(MouseEvent e){ setBorderPainted(false); } }); } public static void main(String[] args){ JFrame frame=new JFrame("Button Test"); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(new PlainButton("A")); frame.getContentPane().add(new PlainButton("B")); frame.getContentPane().add(new PlainButton("C")); frame.setSize(200, 100); frame.show(); }}实现方法很多!以上仅供参考. 祝你早日进步!! 最主要是JToolBar.setRollover(true);JToolBar jt=new JToolBar();YourFrame.add(jt,"North");jt.setRollover(false);jt.add(...);......jt.addSeparator();...... 请大家帮忙看看为什么这句出错说需要标示符 如果是父类的方法,且不是static 方法. 是不是一定要用 this.方法名()访问...??? 如何判断按下的是按钮而不是其他? java构造函数的问题,需前辈指点 面板显示的问题 用microsoft的JDBC驱动访问SQL数据库,为什么数据集的一些功能用不了了? 求教大侠一个问题,谢谢 类型转换 问inetaddress java.io.IOException: Server returned HTTP response code: 403 关于事件,请问AwteEentmultiCaster是用来做什么的? 如何屏蔽键盘输入
import java.awt.event.*;
import javax.swing.*;public class PlainButton extends JButton
{
public PlainButton(String caption){
super(caption);
setBorderPainted(false);
setFocusPainted(false);
setRequestFocusEnabled(false);
setMargin(new Insets(1, 1, 1, 1));
// Dynamic display tool-button border
addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent e){ setBorderPainted(true); }
public void mouseExited(MouseEvent e){ setBorderPainted(false); }
});
} public static void main(String[] args){
JFrame frame=new JFrame("Button Test");
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(new PlainButton("A"));
frame.getContentPane().add(new PlainButton("B"));
frame.getContentPane().add(new PlainButton("C"));
frame.setSize(200, 100);
frame.show();
}
}实现方法很多!以上仅供参考. 祝你早日进步!!
YourFrame.add(jt,"North");
jt.setRollover(false);
jt.add(...);......jt.addSeparator();......