本文整理汇总了Java中javax.swing.SwingConstants.RIGHT属性的典型用法代码示例。如果您正苦于以下问题:Java SwingConstants.RIGHT属性的具体用法?Java SwingConstants.RIGHT怎么用?Java SwingConstants.RIGHT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.SwingConstants
的用法示例。
在下文中一共展示了SwingConstants.RIGHT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alignRectsRunFor
protected void alignRectsRunFor(final Rectangle[] rects, final Dimension tabPaneSize, final int tabPlacement, final boolean isRightToLeft) {
final boolean isVertical = tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT;
if (isVertical) {
if (needsScrollers) {
stretchScrollingVerticalRun(rects, tabPaneSize);
} else {
centerVerticalRun(rects, tabPaneSize);
}
} else {
if (needsScrollers) {
stretchScrollingHorizontalRun(rects, tabPaneSize, isRightToLeft);
} else {
centerHorizontalRun(rects, tabPaneSize, isRightToLeft);
}
}
}
示例2: CompositeButtonPainter
/**
* Creates a new {@code CompositeButtonPainter} for the given button. The position indicates the
* painting style.
*
* @param button
* the button to paint
* @param position
* the button's position
*/
public CompositeButtonPainter(AbstractButton button, int position) {
// button must not be null
if (button == null) {
throw new IllegalArgumentException("Button must not be null!");
}
this.button = button;
// the painter only support positions left, center, and right
switch (position) {
case SwingConstants.LEFT:
case SwingConstants.CENTER:
case SwingConstants.RIGHT:
this.position = position;
break;
default:
throw new IllegalArgumentException("Position (swing constant) not supported.");
}
}
示例3: getTableCellRendererComponent
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
if (value == null)
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, 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);
}
if (isSelected) {
if (!hasFocus) {
isSelected = false;
}
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
return c;
}
JLabel res = new JLabel((String)value, SwingConstants.CENTER);
if (errorRows[row]) {
res.setForeground(Color.RED);
} else if (warningRows[row]) {
res.setForeground(Color.BLUE);
}
return res;
}
示例4: paintTabBorderSelected
private void paintTabBorderSelected(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h) {
if (tabPlacement == SwingConstants.TOP) {
paintSelectedTop(g, x, y, w, h);
} else if (tabPlacement == SwingConstants.LEFT) {
paintSelectedLeft(g, x, y, w, h);
} else if (tabPlacement == SwingConstants.RIGHT) {
paintSelectedRight(g, x, y, w, h);
} else {
paintSelectedBottom(g, x, y, w, h);
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: isRightAligned
private boolean isRightAligned(AbstractButton button, int position) {
if (position == SwingConstants.EAST) {
boolean ltr = button.getComponentOrientation().isLeftToRight();
int hAlign = button.getHorizontalAlignment();
return ((ltr && (hAlign == SwingConstants.RIGHT ||
hAlign == SwingConstants.TRAILING)) ||
(!ltr && (hAlign == SwingConstants.LEADING)));
}
return false;
}
示例8: getTableCellRendererComponent
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
//Federico Dall'Orso 22/6/2005
//OLD
/* called side effects
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
/* adjust alignment */
/*
if (value instanceof Number) {
setHorizontalAlignment(SwingConstants.RIGHT);
} else {
setHorizontalAlignment(SwingConstants.CENTER);
}
return this;
*/
//NEW
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);
}
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
return c;
//END Federico Dall'Orso
}
示例9: getTableCellRendererComponent
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
// Paints infinity symbol as a number
if (value instanceof String && "\u221E".equals(value)) {
super.setHorizontalAlignment(SwingConstants.RIGHT);
}
if (!table.isCellEditable(row, col)) {
renderer.setEnabled(false);
} else {
renderer.setEnabled(true);
}
return renderer;
}
示例10: addToBar
private void addToBar(JComponent comp, int pos, boolean priority, boolean separator)
{
JPanel panel = getPanel(pos);
JSeparator sep = new JSeparator(SwingConstants.VERTICAL);
sep.setPreferredSize(new Dimension(3, image.getIconHeight()));
comp.setBorder(new EmptyBorder(0, 5, 0, 5));
boolean sepFirst = false;
int loc = -1;
// This could all be done nicer, but who cares if it works?
if( pos == SwingConstants.RIGHT )
{
if( priority )
{
sepFirst = true;
}
else
{
loc = 0;
}
}
else
{
if( priority )
{
loc = 0;
sepFirst = true;
}
}
if( sepFirst && separator )
{
panel.add(sep, loc);
}
panel.add(comp, loc);
if( !sepFirst && separator )
{
panel.add(sep, loc);
}
}
示例11: ColorChooserPanel
ColorChooserPanel(ColorModel model) {
this.model = model;
this.panel = new ColorPanel(this.model);
this.slider = new DiagramComponent(this.panel, false);
this.diagram = new DiagramComponent(this.panel, true);
this.text = new JFormattedTextField();
this.label = new JLabel(null, null, SwingConstants.RIGHT);
ValueFormatter.init(6, true, this.text);
}
示例12: convertAlignment
/**
* Converts {@code Label} alignment constant to the {@code JLabel} constant.
* If wrong Label alignment provided returns default alignment.
*
* @param alignment {@code Label} constant.
*
* @return {@code JLabel} constant.
*/
private static int convertAlignment(final int alignment) {
switch (alignment) {
case Label.CENTER:
return SwingConstants.CENTER;
case Label.RIGHT:
return SwingConstants.RIGHT;
default:
return SwingConstants.LEFT;
}
}
示例13: createCompositeMenuToggleButton
@Override
protected CompositeMenuToggleButton createCompositeMenuToggleButton(Action... actions) {
return new PerspectiveMenuToggleButton(perspectiveController, SwingConstants.RIGHT, actions);
}
示例14: getRightAlignedLabel
public JLabel getRightAlignedLabel(String text) {
return new JLabel(text, SwingConstants.RIGHT);
}
示例15: createCompositeMenuToggleButton
/**
* Creates a {@link CompositeMenuToggleButton} with the given actions and the position
* {@link SwingConstants#RIGHT}.
*
* @param actions
* the actions which should be included
* @return the created button
*/
protected CompositeMenuToggleButton createCompositeMenuToggleButton(Action... actions) {
return new CompositeMenuToggleButton(SwingConstants.RIGHT, actions);
}