Java Code Examples for javax.swing.SwingConstants#LEFT

The following examples show how to use javax.swing.SwingConstants#LEFT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AquaTabbedPaneTabState.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 2
Source File: AquaTabbedPaneTabState.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 3
Source File: AquaTabbedPaneTabState.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 4
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
protected GridBagConstraints createCloseButtonConstraints() {
	GridBagConstraints closeButtonConstraints = new GridBagConstraints();
	closeButtonConstraints.gridx = 0;
	closeButtonConstraints.gridy = 0;
	closeButtonConstraints.weightx = 1;
	closeButtonConstraints.weighty = 1;
	closeButtonConstraints.fill = GridBagConstraints.NONE;
	if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		closeButtonConstraints.anchor = GridBagConstraints.SOUTH;
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		closeButtonConstraints.anchor = GridBagConstraints.NORTH;
	} else {
		closeButtonConstraints.anchor = GridBagConstraints.WEST;
	}
	if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		closeButtonConstraints.insets = new Insets(0, 0, 3, 0);
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		closeButtonConstraints.insets = new Insets(3, 0, 0, 0);
	} else {
		closeButtonConstraints.insets = new Insets(0, 3, 0, 0);
	}
	return closeButtonConstraints;
}
 
Example 5
Source File: AquaTabbedPaneTabState.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 6
Source File: AquaTabbedPaneTabState.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 7
Source File: VerticalLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
private int layout(ArrayList<Component> list, int y, int width, Insets insets) {
  for (Component component : list) {
    if (component.isVisible()) {
      Dimension size = component.getPreferredSize();
      int x = 0;
      if (myAlignment == -1) {
        size.width = width;
      }
      else if (myAlignment != SwingConstants.LEFT) {
        x = width - size.width;
        if (myAlignment == SwingConstants.CENTER) {
          x /= 2;
        }
      }
      component.setBounds(x + insets.left, y + insets.top, size.width, size.height);
      y += size.height + myGap;
    }
  }
  return y;
}
 
Example 8
Source File: AdvantageModifierEnabler.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private static Container createTop(Advantage advantage, int remaining) {
    JPanel top   = new JPanel(new ColumnLayout());
    JLabel label = new JLabel(Text.truncateIfNecessary(advantage.toString(), 80, SwingConstants.RIGHT), SwingConstants.LEFT);

    top.setBorder(new EmptyBorder(0, 0, 15, 0));
    if (remaining > 0) {
        String msg;
        msg = remaining == 1 ? I18n.Text("1 advantage remaining to be processed.") : MessageFormat.format(I18n.Text("{0} advantages remaining to be processed."), Integer.valueOf(remaining));
        top.add(new JLabel(msg, SwingConstants.CENTER));
    }
    label.setBorder(new CompoundBorder(new LineBorder(), new EmptyBorder(0, 2, 0, 2)));
    label.setOpaque(true);
    top.add(new JPanel());
    top.add(label);
    return top;
}
 
Example 9
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public void formatTabContent(JTabbedPane tabs, JComponent c) {
	if (contentBorder) {
		Border border;
		if (tabs.getTabPlacement() == SwingConstants.LEFT) {
			border = new PartialLineBorder(borderNormalDark, true,
					false, true, true);
		} else if (tabs.getTabPlacement() == SwingConstants.BOTTOM) {
			border = new PartialLineBorder(borderNormalDark, true,
					true, false, true);
		} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
			border = new PartialLineBorder(borderNormalDark, true,
					true, true, false);
		} else {
			border = new PartialLineBorder(borderNormalDark, false,
					true, true, true);
		}
		c.setBorder(border);
	}
}
 
Example 10
Source File: EditorPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * @param compare The current string compare object.
 * @return The field that allows a string comparison to be changed.
 */
protected EditorField addStringCompareField(StringCriteria compare) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, compare.getQualifier(), null);
    field.putClientProperty(StringCriteria.class, compare);
    add(field);
    return field;
}
 
Example 11
Source File: Led.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBounds(final Rectangle BOUNDS) {
    if (BOUNDS.width <= BOUNDS.height) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = BOUNDS.y;
                break;
            case SwingConstants.BOTTOM:
                yNew = BOUNDS.y + (BOUNDS.height - BOUNDS.width);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = BOUNDS.y + ((BOUNDS.height - BOUNDS.width) / 2);
                break;
        }
        super.setBounds(BOUNDS.x, yNew, BOUNDS.width, BOUNDS.width);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = BOUNDS.x;
                break;
            case SwingConstants.RIGHT:
                xNew = BOUNDS.x + (BOUNDS.width - BOUNDS.height);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = BOUNDS.x + ((BOUNDS.width - BOUNDS.height) / 2);
                break;
        }
        super.setBounds(xNew, BOUNDS.y, BOUNDS.height, BOUNDS.height);
    }
    calcInnerBounds();
    init(INNER_BOUNDS.width);
    initialized = true;
}
 
Example 12
Source File: FlatTableHeaderUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void installDefaults() {
	super.installDefaults();

	separatorColor = UIManager.getColor( "TableHeader.separatorColor" );
	bottomSeparatorColor = UIManager.getColor( "TableHeader.bottomSeparatorColor" );
	height = UIManager.getInt( "TableHeader.height" );
	switch( Objects.toString( UIManager.getString( "TableHeader.sortIconPosition" ), "right" ) ) {
		default:
		case "right":	sortIconPosition = SwingConstants.RIGHT; break;
		case "left":	sortIconPosition = SwingConstants.LEFT; break;
		case "top":		sortIconPosition = SwingConstants.TOP; break;
		case "bottom":	sortIconPosition = SwingConstants.BOTTOM; break;
	}
}
 
Example 13
Source File: LWLabelPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 14
Source File: WhoIsPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WhoIsPanel(final ServiceFactory factory) {
	super(factory);
	final JPanel top = new JPanel();
	top.setLayout(new WrapLayout(FlowLayout.LEFT, 2, 0));
	_label = new JLabel("", SwingConstants.LEFT);
	top.add(_label);
	add(top, BorderLayout.NORTH);
	_textArea = new JTextArea("", 30, 70);
	_textArea.setEditable(false);
	final JScrollPane scroll = new JScrollPane(_textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(scroll, BorderLayout.CENTER);
	_whois.addListener(this);
}
 
Example 15
Source File: ProfilerTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static boolean isLeadingAlign(Component component) {
    int alignment;
    
    if (component instanceof ProfilerRenderer) {
        alignment = ((ProfilerRenderer)component).getHorizontalAlignment();
    } else if (component instanceof JLabel) {
        alignment = ((JLabel)component).getHorizontalAlignment();
    } else {
        alignment = SwingConstants.LEADING;
    }
    
    return alignment == SwingConstants.LEADING ||
           alignment == SwingConstants.LEFT ||
           alignment == SwingConstants.CENTER;
}
 
Example 16
Source File: StopWatch.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBounds(final Rectangle BOUNDS) {
    if (BOUNDS.width <= BOUNDS.height) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = BOUNDS.y;
                break;
            case SwingConstants.BOTTOM:
                yNew = BOUNDS.y + (BOUNDS.height - BOUNDS.width);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = BOUNDS.y + ((BOUNDS.height - BOUNDS.width) / 2);
                break;
        }
        super.setBounds(BOUNDS.x, yNew, BOUNDS.width, BOUNDS.width);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = BOUNDS.x;
                break;
            case SwingConstants.RIGHT:
                xNew = BOUNDS.x + (BOUNDS.width - BOUNDS.height);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = BOUNDS.x + ((BOUNDS.width - BOUNDS.height) / 2);
                break;
        }
        super.setBounds(xNew, BOUNDS.y, BOUNDS.height, BOUNDS.height);
    }
    calcInnerBounds();
    init(getGaugeBounds().width, getGaugeBounds().height);
    setInitialized(true);
}
 
Example 17
Source File: LayoutStyle.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
private boolean isLeftAligned(AbstractButton button, int position) {
	if (position == SwingConstants.WEST) {
		boolean ltr = button.getComponentOrientation().isLeftToRight();
		int hAlign = button.getHorizontalAlignment();
		return ((ltr && (hAlign == SwingConstants.LEFT || hAlign == SwingConstants.LEADING))
				|| (!ltr && (hAlign == SwingConstants.TRAILING)));
	}
	return false;
}
 
Example 18
Source File: FlatTableHeaderUI.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
void reset() {
	if( l != null && sortIconPosition == SwingConstants.LEFT && oldHorizontalTextPosition >= 0 )
		l.setHorizontalTextPosition( oldHorizontalTextPosition );
}
 
Example 19
Source File: LanguageSelectionPanel.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * Construct panel contents.
 */
private void constructContents() {
  GridBagConstraints constraints = new GridBagConstraints(
      0, 0, 1, 1, 1, 0,
      GridBagConstraints.LINE_START, GridBagConstraints.BOTH,
      new Insets(0, 0, 0, 0), 0, 0);

  // Text
  if ((text != null) && (text.trim().length() > 0)) {
    JLabel label = new JLabel(text, SwingConstants.LEFT);
    constraints.gridwidth = 2;
    add(label, constraints);
    constraints.weightx = 1;
    constraints.gridwidth = 1;
    constraints.gridy++;
  }

  // Language
  buttonLanguage = Utilities.createJButton(GT._T("Language"), null);
  buttonLanguage.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionLanguage"));
  constraints.gridx = 0;
  constraints.weightx = 0;
  add(buttonLanguage, constraints);
  txtLanguage = new JTextField("", 40);
  txtLanguage.setEditable(false);
  constraints.gridx++;
  constraints.weightx = 1;
  add(txtLanguage, constraints);
  constraints.gridy++;

  // Script
  buttonScript = Utilities.createJButton(GT._T("Script"), null);
  buttonScript.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionScript"));
  buttonScript.setEnabled(false);
  constraints.gridx = 0;
  constraints.weightx = 0;
  add(buttonScript, constraints);
  txtScript = new JTextField("", 40);
  txtScript.setEditable(false);
  constraints.gridx++;
  constraints.weightx = 1;
  add(txtScript, constraints);
  constraints.gridy++;

  // Region
  buttonRegion = Utilities.createJButton(GT._T("Region"), null);
  buttonRegion.addActionListener(
      EventHandler.create(ActionListener.class, this, "actionRegion"));
  buttonRegion.setEnabled(false);
  constraints.gridx = 0;
  constraints.weightx = 0;
  add(buttonRegion, constraints);
  txtRegion = new JTextField("", 40);
  txtRegion.setEditable(false);
  constraints.gridx++;
  constraints.weightx = 1;
  add(txtRegion, constraints);
  constraints.gridy++;

  // Variants
  buttonVariant = new Vector<JButton>(NB_VARIANTS);
  txtVariant = new Vector<JTextField>(NB_VARIANTS);
  variant = new Vector<LanguageRegistry.Variant>(NB_VARIANTS);
  for (int i = 0; i < NB_VARIANTS; i++) {
    JButton tmpButton = Utilities.createJButton(GT._T("Variant n°{0}", Integer.toString(i + 1)), null);
    tmpButton.setActionCommand(Integer.toString(i));
    tmpButton.addActionListener(EventHandler.create(
        ActionListener.class, this, "actionVariant", "actionCommand"));
    tmpButton.setEnabled(false);
    buttonVariant.add(tmpButton);
    constraints.gridx = 0;
    constraints.weightx = 0;
    add(tmpButton, constraints);
    JTextField tmpText = new JTextField("", 40);
    tmpText.setEditable(false);
    txtVariant.add(tmpText);
    constraints.gridx++;
    constraints.weightx = 1;
    add(tmpText, constraints);
    constraints.gridy++;
    variant.add(null);
  }

  // Default language
  Configuration config = Configuration.getConfiguration();
  String defaultLanguage = config.getString(null, ConfigurationValueString.LAST_LANGUAGE);
  if (defaultLanguage != null) {
    selectLanguage(defaultLanguage);
  }
}
 
Example 20
Source File: PageField.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Creates a new, left-aligned, text input field.
 *
 * @param sheet        The sheet to listen to.
 * @param consumedType The field to listen to.
 * @param tooltip      The tooltip to set.
 */
public PageField(CharacterSheet sheet, String consumedType, String tooltip) {
    this(sheet, consumedType, SwingConstants.LEFT, true, tooltip);
}