1 18 19 23 package org.apache.jmeter.gui.util; 24 25 import java.awt.BorderLayout ; 26 import java.awt.Component ; 27 28 import javax.swing.Box ; 29 import javax.swing.JComponent ; 30 import javax.swing.JPanel ; 31 32 36 public class HorizontalPanel extends JPanel 37 { 38 private Box subPanel = Box.createHorizontalBox(); 39 private float verticalAlign; 40 private int hgap; 41 42 public HorizontalPanel() 43 { 44 this(5, CENTER_ALIGNMENT); 45 } 46 47 public HorizontalPanel(int hgap, float verticalAlign) 48 { 49 super(new BorderLayout ()); 50 add(subPanel, BorderLayout.WEST); 51 this.hgap = hgap; 52 this.verticalAlign = verticalAlign; 53 } 54 55 58 public Component add(Component c) 59 { 60 if (hgap > 0 && subPanel.getComponentCount() > 0) 63 { 64 subPanel.add(Box.createHorizontalStrut(hgap)); 65 } 66 67 if (c instanceof JComponent ) 68 { 69 ((JComponent ) c).setAlignmentY(verticalAlign); 70 } 71 return subPanel.add(c); 72 } 73 } 74 | Popular Tags |