下面列出了javax.swing.JSeparator#setAlignmentY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public SeparatorTitled(String title, boolean bold) {
super(BoxLayout.LINE_AXIS);
JLabel titleLabel = new JLabel(title);
if (bold)
FormUtils.setBold(titleLabel);
titleLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
this.add(titleLabel);
this.add(Box.createHorizontalStrut(5));
JSeparator separator = new JSeparator();
separator.setAlignmentY(Container.TOP_ALIGNMENT);
this.add(separator);
this.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
}
private void build(String title) {
JLabel titleLabel = new JLabel(title);
if (color != null)
titleLabel.setForeground(color);
titleLabel.setFont(font);
titleLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
this.add(titleLabel);
this.add(Box.createHorizontalStrut(5));
JSeparator separator = new JSeparator();
separator.setAlignmentY(Container.TOP_ALIGNMENT);
this.add(separator);
this.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
}
private Box createPromptPanel() {
final Box pane = Box.createHorizontalBox();
pane.setBorder( BorderFactory.createEmptyBorder( 15, 0, 10, 0 ) );
final JLabel promptLabel = new JLabel( Messages.getString( "ParameterDialog.Prompt" ) );
pane.add( promptLabel );
pane.add( Box.createRigidArea( new Dimension( 10, 0 ) ) );
final JSeparator horizontalSeparator = new JSeparator();
horizontalSeparator.setAlignmentY( TOP_ALIGNMENT );
pane.add( horizontalSeparator );
return pane;
}