1 18 19 25 package org.apache.jmeter.gui.util; 26 27 import java.awt.BorderLayout ; 28 import java.awt.Component ; 29 30 import javax.swing.Box ; 31 import javax.swing.JComponent ; 32 import javax.swing.JPanel ; 33 34 38 public class VerticalPanel extends JPanel 39 { 40 private Box subPanel = Box.createVerticalBox(); 41 private float horizontalAlign; 42 private int vgap; 43 44 public VerticalPanel() 45 { 46 this(5, LEFT_ALIGNMENT); 47 } 48 49 public VerticalPanel(int vgap, float horizontalAlign) 50 { 51 super(new BorderLayout ()); 52 add(subPanel,BorderLayout.NORTH); 53 this.vgap = vgap; 54 this.horizontalAlign = horizontalAlign; 55 } 56 57 60 public Component add(Component c) 61 { 62 if (vgap > 0 && subPanel.getComponentCount() > 0) 65 { 66 subPanel.add(Box.createVerticalStrut(vgap)); 67 } 68 69 if (c instanceof JComponent ) 70 { 71 ((JComponent )c).setAlignmentX(horizontalAlign); 72 } 73 74 return subPanel.add(c); 75 } 76 } 77 | Popular Tags |