这应该是LookAndFeel的问题,默认的是没有的,window的LNF是有的

解决方案 »

  1.   

    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);
            }
        }
    }
      

  2.   

    Sorry, 我试过了你的方法,效果不是最好,我已经上了javaranch去找了相关的帖子,并得到了答案。公布一下:
    toolbar.add(new JSeparator(SwingConstants.VERTICAL));
    JBuilder八成就是这样实现的还有一个问题,放在ToolBar上的TextField会充满,我想让他不要充满,该怎么做?