在jbuilder 中右侧的属性面版的border属性中自己试验看看哪种效果是你喜欢的!

解决方案 »

  1.   

    从SWIN容器组件如JPanel中继承。
    组件绘制方法 public paint(Graphics g) 调用paintComponent,
    paintBorder及paintChildren三个保护方法。要有不同的边框,重载paintBorder.
      

  2.   

    public class Frame1 extends JFrame {
      private JPanel jPanel1 = new JPanel();
      private XYLayout xYLayout1 = new XYLayout();
      private JPanel jPanel2 = new JPanel();  public Frame1() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      private void jbInit() throws Exception {
        jPanel1.setLayout(xYLayout1);
        jPanel2.setBackground(Color.lightGray);
        jPanel2.setBorder(BorderFactory.createRaisedBevelBorder());//---here
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jPanel2,    new XYConstraints(60, 48, 270, 176));
      }
    }
      

  3.   

    extends JComponent,
    setBorder()
      

  4.   

    其他组件必须是Component的子类的对象,调用Container的add(Component comp)方法。
      

  5.   

    在Swing中先放置的组件在后放置的上面
    请问,怎么解决使组件的放置顺序与显示无关