本文整理汇总了Java中javax.swing.SwingConstants.CENTER属性的典型用法代码示例。如果您正苦于以下问题:Java SwingConstants.CENTER属性的具体用法?Java SwingConstants.CENTER怎么用?Java SwingConstants.CENTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.SwingConstants
的用法示例。
在下文中一共展示了SwingConstants.CENTER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
/**
* Draws the component background.
*
* @param g
* the graphics context
*/
void paintComponent(Graphics g) {
RectangularShape rectangle;
int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
switch (position) {
case SwingConstants.LEFT:
rectangle = new RoundRectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight(), radius,
radius);
break;
case SwingConstants.CENTER:
rectangle = new Rectangle2D.Double(0, 0, button.getWidth(), button.getHeight());
break;
default:
rectangle = new RoundRectangle2D.Double(-radius, 0, button.getWidth() + radius, button.getHeight(), radius,
radius);
break;
}
RapidLookTools.drawButton(button, g, rectangle);
}
示例2: ExtendedJLabel
public ExtendedJLabel( ControlJFrame objPcontrolJFrame,
MouseListener objPmouseListener,
String strPlabel,
Icon objLicon,
Color objPbackgroundColor,
int intPtooltip) {
super(strPlabel, objLicon, SwingConstants.CENTER);
this.objGcontrolJFrame = objPcontrolJFrame;
this.intGtooltip = intPtooltip;
this.setFont(this.objGcontrolJFrame.getFont());
if (objPbackgroundColor != null) {
this.setBackground(objPbackgroundColor);
}
this.setOpaque(true);
if (objPmouseListener != null) {
this.objGmouseListener = objPmouseListener;
this.addMouseListener(this.objGmouseListener);
} else {
if (this.objGmouseListener != null) {
this.removeMouseListener(this.objGmouseListener);
}
}
}
示例3: paintBorder
/**
* Draws the component border.
*
* @param graphics
* the graphics context
*/
void paintBorder(Graphics graphics) {
Graphics2D g = (Graphics2D) graphics.create();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Colors.BUTTON_BORDER);
int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
switch (position) {
case SwingConstants.LEFT:
g.drawRoundRect(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius);
break;
case SwingConstants.CENTER:
g.drawRect(0, 0, button.getWidth() + radius, button.getHeight() - 1);
break;
default:
g.drawRoundRect(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius);
g.drawLine(0, 0, 0, button.getHeight());
break;
}
}
示例4: validate
@Override
protected void validate(XMLDecoder decoder) {
JPanel panel = (JPanel) decoder.readObject();
if (2 != panel.getComponents().length) {
throw new Error("unexpected component count");
}
JButton button = (JButton) panel.getComponents()[0];
if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
throw new Error("unexpected button text");
}
if (SwingConstants.CENTER != button.getVerticalAlignment()) {
throw new Error("unexpected vertical alignment");
}
JLabel label = (JLabel) panel.getComponents()[1];
if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
throw new Error("unexpected label text");
}
if (button != label.getLabelFor()) {
throw new Error("unexpected component");
}
}
示例5: getLayoutComponent
public Component getLayoutComponent(int constraint) {
if (constraint == SwingConstants.NORTH) return north;
if (constraint == SwingConstants.WEST) return west;
if (constraint == SwingConstants.SOUTH) return south;
if (constraint == SwingConstants.EAST) return east;
if (constraint == SwingConstants.CENTER) return center;
throw new IllegalArgumentException("Illegal constraint: " + // NOI18N
constraintName(constraint));
}
示例6: getListCellRendererComponent
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(JList<? extends BuildableType> list,
BuildableType value,
int index,
boolean isSelected,
boolean cellHasFocus) {
JPanel panel = (isSelected) ? selectedPanel : itemPanel;
panel.removeAll();
((ImageIcon)imageLabel.getIcon()).setImage(ImageLibrary.getBuildableImage(value, buildingDimension));
nameLabel.setText(Messages.getName(value));
panel.setToolTipText(lockReasons.get(value));
panel.add(imageLabel, "span 1 2");
if (lockReasons.get(value) == null) {
panel.add(nameLabel, "wrap");
} else {
panel.add(nameLabel, "split 2");
panel.add(lockLabel, "wrap");
}
ImageLibrary lib = getImageLibrary();
List<AbstractGoods> required = value.getRequiredGoodsList();
int size = required.size();
for (int i = 0; i < size; i++) {
AbstractGoods goods = required.get(i);
ImageIcon icon = new ImageIcon(lib.getSmallIconImage(goods.getType()));
JLabel goodsLabel = new JLabel(Integer.toString(goods.getAmount()), icon, SwingConstants.CENTER);
if (i == 0 && size > 1) {
panel.add(goodsLabel, "split " + size);
} else {
panel.add(goodsLabel);
}
}
return panel;
}
示例7: isBasis
private static boolean isBasis(int constraint) {
if (constraint == SwingConstants.NORTH) return true;
if (constraint == SwingConstants.WEST) return true;
if (constraint == SwingConstants.SOUTH) return true;
if (constraint == SwingConstants.EAST) return true;
if (constraint == SwingConstants.CENTER) return true;
return false;
}
示例8: init
private void init() {
setOpaque(false);
dano = new JLabel("0", SwingConstants.CENTER);
dano.setFont(Fontes.getBelwe(30));
dano.setToolTipText("Dano Mágico");
add(dano, new AbsoluteConstraints(0, 0, 40, 40));
}
示例9: getJLabelDefault
/**
* Criar JLabel padrão para as animações
*
* @return JLabel padrão
*/
private JLabel getJLabelDefault() {
JLabel retorno = new JLabel("", SwingConstants.CENTER) {
@Override
public String toString() {
return heroi.getToString();
}
};
retorno.setSize(SIZE);
retorno.setPreferredSize(SIZE);
retorno.setVisible(false);
return retorno;
}
示例10: ToggleButtonGroup
/**
* Creates a new button group from the given Actions (requires at least two actions).
*
* @param preferredSize
* the preferredSize of the nested {@link CompositeToggleButton}s or {@code null}
* @param actions
* the action
*/
public ToggleButtonGroup(Dimension preferredSize, Action... actions) {
if (actions.length < 2) {
throw new IllegalArgumentException("At least two primary actions must be specified.");
}
this.setOpaque(false);
this.preferredSize = preferredSize;
primaryButtons = new CompositeToggleButton[actions.length];
for (int i = 0; i < actions.length; i++) {
int position;
if (i == 0) {
position = SwingConstants.LEFT;
} else if (i < actions.length - 1) {
position = SwingConstants.CENTER;
} else {
position = SwingConstants.RIGHT;
}
primaryButtons[i] = new CompositeToggleButton(actions[i], position);
}
// align buttons left to right with no padding
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weighty = 1;
for (JToggleButton button : primaryButtons) {
button.addActionListener(buttonChooser);
if (preferredSize != null) {
button.setMinimumSize(preferredSize);
button.setPreferredSize(preferredSize);
}
add(button, gbc);
}
}
示例11: getJLabelDefault
/**
* Criar JLabel padrão para as animações
*
* @return JLabel padrão
*/
private JLabel getJLabelDefault() {
JLabel retorno = new JLabel("", SwingConstants.CENTER) {
@Override
public String toString() {
return card.getToString();
}
};
retorno.setSize(SIZE);
retorno.setPreferredSize(SIZE);
retorno.setVisible(false);
return retorno;
}
示例12: getTableCellRendererComponent
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
if (value instanceof Number) {
super.setHorizontalAlignment(SwingConstants.RIGHT);
} else if (value instanceof Boolean) {
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
} else {
super.setHorizontalAlignment(SwingConstants.CENTER);
}
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
}
示例13: createHeaderPanel
/**
* Create a title panel
*
* @param boutonLicense if true, show the license button
* @return the panel
*/
public static JComponent createHeaderPanel(final boolean boutonLicense, final Window parent) {
if (boutonLicense) {
final JButton license = new JButton(Resources.getLabel("license.label"), Resources.getImageIcon("route.png"));
license.addActionListener(e -> {
final LicenseDialog dialog = new LicenseDialog(parent);
dialog.setVisible(true);
});
return license;
} else {
return new JLabel(Resources.getLabel("appli.title", Resources.getVersion()), Resources.getImageIcon("route.png"), SwingConstants.CENTER);
}
}
示例14: Qtdd
public Qtdd() {
super("", SwingConstants.CENTER);
init();
}
示例15: Animacao
public Animacao(Card card) {
super("", SwingConstants.CENTER);
this.card = card;
init();
}