this.borderInsets.top = this.component.getPreferredSize().height + this.gap; this.component.setAlignmentX(this.alignment); this.component.setAlignmentY(0.0f); } else if (this.edge == Edge.BOTTOM) { this.borderInsets.bottom = this.component.getPreferredSize().height + this.gap; this.component.setAlignmentX(this.alignment); this.component.setAlignmentY(1.0f); } else if (this.edge == Edge.LEFT) { this.borderInsets.left = this.component.getPreferredSize().width + this.gap; this.component.setAlignmentX(0.0f); this.component.setAlignmentY(this.alignment); } else if (this.edge == Edge.RIGHT) { this.borderInsets.right = this.component.getPreferredSize().width + this.gap; this.component.setAlignmentX(1.0f); this.component.setAlignmentY(this.alignment);
tb.add(newButton); newButton.setAlignmentY(0.5f); newButton.setAlignmentX(0.5f);
public void add(JComponent comp) { comp.setAlignmentY(0); super.add( comp); } }
public Component add(Component comp) { ((JComponent) comp).setAlignmentY(0f); return super.add(comp); } };
public static void addAligned(final Container container, final JComponent component) { component.setAlignmentX(Component.LEFT_ALIGNMENT); component.setAlignmentY(Component.TOP_ALIGNMENT); container.add(component); }
/** * {@inheritDoc} */ @Override public Component add(Component c) { // This won't work right if we remove components. But we don't, so I'm // not going to worry about it right now. if (hgap > 0 && subPanel.getComponentCount() > 0) { subPanel.add(Box.createHorizontalStrut(hgap)); } if (c instanceof JComponent) { ((JComponent) c).setAlignmentY(verticalAlign); } return subPanel.add(c); } }
/** * Add any applet sub-panel(s) now. */ public boolean addSubPanels(Container parent) { JComponent topPane = new ItinScreen(this, null); topPane.setAlignmentX(Component.LEFT_ALIGNMENT); topPane.setAlignmentY(Component.BOTTOM_ALIGNMENT); parent.add(topPane); return true; } /**
JComponent fields = new JPanel(new GridBagLayout()); fields.setOpaque(false); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.BASELINE_LEADING; fields.add(tf, gbc); gbc.insets.top = 6; fields.add(label, gbc); fields.add(button1, gbc); fields.setAlignmentX(JComponent.CENTER_ALIGNMENT); fields.setAlignmentY(JComponent.CENTER_ALIGNMENT); bg.setAlignmentX(JComponent.CENTER_ALIGNMENT); bg.setAlignmentY(JComponent.CENTER_ALIGNMENT); JPanel overlay = new JPanel(); overlay.setLayout(new OverlayLayout(overlay)); overlay.add(fields); overlay.add(bg); frame.getContentPane().add(overlay);
/** * Add any applet sub-panel(s) now. */ public boolean addSubPanels(Container parent, FieldList record) { JComponent topPane = new JContactScreen(this, record); topPane.setAlignmentX(Component.LEFT_ALIGNMENT); topPane.setAlignmentY(Component.BOTTOM_ALIGNMENT); parent.add(topPane); return true; } /**
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) public static ComponentUI createUI(JComponent c) { c.setOpaque(false); c.setAlignmentY(0.5f); return new OnOffButtonUI((OnOffButton)c); }
borderInsets.top = component.getPreferredSize().height + gap; component.setAlignmentX(alignment); component.setAlignmentY(0.0f); } else if (edge == Edge.BOTTOM) { borderInsets.bottom = component.getPreferredSize().height + gap; component.setAlignmentX(alignment); component.setAlignmentY(1.0f); } else if (edge == Edge.LEFT) { borderInsets.left = component.getPreferredSize().width + gap; component.setAlignmentX(0.0f); component.setAlignmentY(alignment); } else if (edge == Edge.RIGHT) { borderInsets.right = component.getPreferredSize().width + gap; component.setAlignmentX(1.0f); component.setAlignmentY(alignment);
borderInsets.top = component.getPreferredSize().height + gap; component.setAlignmentX(alignment); component.setAlignmentY(0.0f); } else if (edge == Edge.BOTTOM) { borderInsets.bottom = component.getPreferredSize().height + gap; component.setAlignmentX(alignment); component.setAlignmentY(1.0f); } else if (edge == Edge.LEFT) { borderInsets.left = component.getPreferredSize().width + gap; component.setAlignmentX(0.0f); component.setAlignmentY(alignment); } else if (edge == Edge.RIGHT) { borderInsets.right = component.getPreferredSize().width + gap; component.setAlignmentX(1.0f); component.setAlignmentY(alignment);
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); label.setText(name); label.setAlignmentY(JLabel.TOP_ALIGNMENT); text.setAlignmentY(JTextField.TOP_ALIGNMENT); this.add(label); this.add(text);
optCode.setAlignmentY(0.0f); optComments.setAlignmentY(0.0f);
optCode.setAlignmentY(0.0f); optComments.setAlignmentY(0.0f);
tabbedPane.add("2", new JTextField("two")); tabbedPane.setAlignmentX(1.0f); tabbedPane.setAlignmentY(0.0f); checkBox.setAlignmentY(0.0f);
field.setAlignmentY(0.0f); panel.add(field);
public void actionPerformed(ActionEvent e) { JLabel text = new JLabel("Original Text"); text.setAlignmentY(0.8f); text.setOpaque(true); text.setBackground(Color.yellow);
/** * Add the description labels to the first column of the grid. */ public JComponent addScreenLabel(Container parent, Converter fieldInfo) { GridBagConstraints c = this.getGBConstraints(); c.gridy = GridBagConstraints.RELATIVE; // Bump Row each time if (fieldInfo.getFieldName().equals(Product.PRODUCT_TYPE)) { BaseApplet applet = this.getBaseApplet(); c.gridy = 0; c.gridx = 4; // Column 3 ((FieldInfo)fieldInfo).setFieldDesc(applet.getString(SearchConstants.DATE)); // Don't display the desc. JComponent component = super.addScreenLabel(parent, fieldInfo); component.setAlignmentX(LEFT_ALIGNMENT); component.setAlignmentY(TOP_ALIGNMENT); return component; } return super.addScreenLabel(parent, fieldInfo); } /**
((JComponent) comp).setAlignmentY(0.5f); ((JComponent) comp).setOpaque(false); ((JComponent) comp).setFont(_list.getFont());