怎样创建类似JBuilder工具栏中的“|”,使用addSeparator() 好像不对 这应该是LookAndFeel的问题,默认的是没有的,window的LNF是有的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import javax.swing.*;public class Separator extends JToolBar.Separator { public Separator() { this.setAlignmentX(0.5f); this.setAlignmentY(0.5f); } public void paintComponent(Graphics g) { Dimension s = getSize(); JToolBar toolbar = (JToolBar)getParent(); if (toolbar.getOrientation() == JToolBar.HORIZONTAL ) { g.setColor( SystemColor.controlShadow ); g.drawLine( s.width/2, 0, s.width/2, s.height ); g.setColor( Color.white ); g.drawLine( s.width/2+1, 0, s.width/2+1, s.height ); } else { // HORIZONTAL g.setColor( SystemColor.controlShadow ); g.drawLine( 0, s.height/2, s.width, s.height/2 ); g.setColor( Color.white ); g.drawLine( 0, s.height/2+1, s.width, s.height/2+1); } }} Sorry, 我试过了你的方法,效果不是最好,我已经上了javaranch去找了相关的帖子,并得到了答案。公布一下:toolbar.add(new JSeparator(SwingConstants.VERTICAL));JBuilder八成就是这样实现的还有一个问题,放在ToolBar上的TextField会充满,我想让他不要充满,该怎么做? 运行run.bat只是晃一下就没了,打不开服务,是怎么回事啊?急 “xx-xx-”格式怎么用“-”分割成数组? java输入到文本框中 遇到数据的查询的速度及慢该怎么办?(高手进) Help!!数据库插入记录的初级问题。 关于checkstyle的一些问题 有一个问题一真的很奇怪!(store procedure) 同时学JAVA和C++可以吗?会冲突吗??? 超多次递归,如何放大空间? 请教一个Java的Swing技术问题. 还是想问线程同步问题,大伙来提提意见 怎么设计问题的JAVA应用程序?大家来探讨探讨!
public Separator() {
this.setAlignmentX(0.5f);
this.setAlignmentY(0.5f);
} public void paintComponent(Graphics g) {
Dimension s = getSize(); JToolBar toolbar = (JToolBar)getParent();
if (toolbar.getOrientation() == JToolBar.HORIZONTAL ) {
g.setColor( SystemColor.controlShadow );
g.drawLine( s.width/2, 0, s.width/2, s.height ); g.setColor( Color.white );
g.drawLine( s.width/2+1, 0, s.width/2+1, s.height );
}
else { // HORIZONTAL
g.setColor( SystemColor.controlShadow );
g.drawLine( 0, s.height/2, s.width, s.height/2 ); g.setColor( Color.white );
g.drawLine( 0, s.height/2+1, s.width, s.height/2+1);
}
}
}
toolbar.add(new JSeparator(SwingConstants.VERTICAL));
JBuilder八成就是这样实现的还有一个问题,放在ToolBar上的TextField会充满,我想让他不要充满,该怎么做?