/** Set alignment of the text component */ private void setAlignment() { getAlignmentPanel().remove(getLabel()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; gbc.gridwidth = 1; gbc.gridheight = 1; switch (ScilabAlignment.toSwingAlignment(horizontalAlignment)) { case SwingConstants.LEFT: switch (ScilabAlignment.toSwingAlignment(verticalAlignment)) { case SwingConstants.TOP: gbc.anchor = GridBagConstraints.NORTHWEST; break; case SwingConstants.CENTER: gbc.anchor = GridBagConstraints.WEST; break; default: // SwingConstants.BOTTOM gbc.anchor = GridBagConstraints.SOUTHWEST; break; } break; case SwingConstants.CENTER: switch (ScilabAlignment.toSwingAlignment(verticalAlignment)) { case SwingConstants.TOP: gbc.anchor = GridBagConstraints.NORTH; break; case SwingConstants.CENTER: gbc.anchor = GridBagConstraints.CENTER; break; default: // SwingConstants.BOTTOM gbc.anchor = GridBagConstraints.SOUTH; break; } break; default: // SwingConstants.RIGHT switch (ScilabAlignment.toSwingAlignment(verticalAlignment)) { case SwingConstants.TOP: gbc.anchor = GridBagConstraints.NORTHEAST; break; case SwingConstants.CENTER: gbc.anchor = GridBagConstraints.EAST; break; default: // SwingConstants.BOTTOM gbc.anchor = GridBagConstraints.SOUTHEAST; break; } break; } getAlignmentPanel().add(getLabel(), gbc); }
/** * Set the vertical alignment for the Menu text * * @param alignment the value for the alignment (See ScilabAlignment.java) */ public void setVerticalAlignment(String alignment) { setVerticalAlignment(ScilabAlignment.toSwingAlignment(alignment)); }
/** * Set the horizontal alignment for the Menu text * * @param alignment the value for the alignment (See ScilabAlignment.java) */ public void setHorizontalAlignment(String alignment) { setHorizontalAlignment(ScilabAlignment.toSwingAlignment(alignment)); }