当前位置: 首页>>代码示例>>Java>>正文


Java SwingConstants.CENTER属性代码示例

本文整理汇总了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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:CompositeButtonPainter.java

示例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);
		}
	}
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:24,代码来源:ExtendedJLabel.java

示例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;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:CompositeButtonPainter.java

示例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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TestObject.java

示例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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CrossBorderLayout.java

示例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;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:39,代码来源:BuildQueuePanel.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:CrossBorderLayout.java

示例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));
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:7,代码来源:DanoMagico.java

示例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;
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:Animacao.java

示例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);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:47,代码来源:ToggleButtonGroup.java

示例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;
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:Animacao.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:11,代码来源:ExactCellRenderer.java

示例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);
	}
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:18,代码来源:LicenseDialog.java

示例14: Qtdd

public Qtdd() {
    super("", SwingConstants.CENTER);
    init();
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:4,代码来源:Mana.java

示例15: Animacao

public Animacao(Card card) {
    super("", SwingConstants.CENTER);
    this.card = card;
    init();
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:5,代码来源:Animacao.java


注:本文中的javax.swing.SwingConstants.CENTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。