Java Code Examples for javax.swing.SwingConstants#BOTTOM

The following examples show how to use javax.swing.SwingConstants#BOTTOM . 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: ImagePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void paintComponent(Graphics graphics) {
    graphics.setColor(getBackground());
    graphics.fillRect(0, 0, getWidth(), getHeight());

    switch (imageAlign) {
        case (SwingConstants.TOP):
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, 0, this);

            break;
        case (SwingConstants.BOTTOM):
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, getHeight() - image.getHeight(null), this);

            break;
        default:
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, 0, this);
    }
}
 
Example 2
Source File: StyleEditor.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
private void setupUI(Style style) {
  size.getEditor().setItem(style.font.getSize() + "");
  bold.setSelected((style.font.getStyle() & Font.BOLD) != 0);
  italic.setSelected((style.font.getStyle() & Font.ITALIC) != 0);
  selectFont(style.font.getFamily());
  switch(style.vAlign) {
  case SwingConstants.TOP:    anorth.setSelected(true);   break;
  case SwingConstants.CENTER: acenterv.setSelected(true); break;
  case SwingConstants.BOTTOM: asouth.setSelected(true);   break;
  }
  switch(style.hAlign) {
  case SwingConstants.LEFT:   awest.setSelected(true);    break;
  case SwingConstants.CENTER: acenterh.setSelected(true); break;
  case SwingConstants.RIGHT:  aeast.setSelected(true);    break;
  }
}
 
Example 3
Source File: ImagePanel.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected void paintComponent(Graphics graphics) {
    graphics.setColor(getBackground());
    graphics.fillRect(0, 0, getWidth(), getHeight());

    switch (imageAlign) {
        case (SwingConstants.TOP):
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, 0, this);

            break;
        case (SwingConstants.BOTTOM):
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, getHeight() - image.getHeight(null), this);

            break;
        default:
            graphics.drawImage(image, (getWidth() - image.getWidth(null)) / 2, 0, this);
    }
}
 
Example 4
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
protected GradientPaint createContentGradient(JComponent c,
		boolean isSelected) {
	JTabbedPane tabs = getTabbedPaneParent(c);
	int placement = tabs == null ? SwingConstants.TOP : tabs
			.getTabPlacement();
	Color outer = isSelected ? contentOuterSelected
			: contentOuterNormal;
	Color inner = isSelected ? contentInnerSelected
			: contentInnerNormal;
	if (placement == SwingConstants.LEFT) {
		return (new GradientPaint(0, 0, outer, c.getWidth(), 0, inner));
	} else if (placement == SwingConstants.RIGHT) {
		return (new GradientPaint(0, 0, inner, c.getWidth(), 0, outer));
	} else if (placement == SwingConstants.BOTTOM) {
		return (new GradientPaint(0, 0, inner, 0, c.getHeight(), outer));
	} else {
		return (new GradientPaint(0, 0, outer, 0, c.getHeight(), inner));
	}
}
 
Example 5
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public void formatControlRow(JTabbedPane tabs, JPanel tabsContainer) {

	Border border;
	Paint paint = createBorderGradient(tabs.getTabPlacement());
	if (tabs.getTabPlacement() == SwingConstants.BOTTOM) {
		border = new PartialLineBorder(paint, true, true,
				tabs.getTabCount() == 0, true);
	} else if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		border = new PartialLineBorder(paint, true,
				tabs.getTabCount() == 0, true, true);
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		border = new PartialLineBorder(paint, true, true, true,
				tabs.getTabCount() == 0);
	} else {
		border = new PartialLineBorder(paint, tabs.getTabCount() == 0,
				true, true, true);
	}

	tabsContainer.setUI(new GradientPanelUI(createContentGradient(tabs,
			false)));
	tabsContainer.setBorder(border);
}
 
Example 6
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 7
Source File: AbstractRadial.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBounds(final int X, final int Y, final int WIDTH, final int HEIGHT) {
    if (WIDTH <= HEIGHT) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = Y;
                break;
            case SwingConstants.BOTTOM:
                yNew = Y + (HEIGHT - WIDTH);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = Y + ((HEIGHT - WIDTH) / 2);
                break;
        }
        super.setBounds(X, yNew, WIDTH, WIDTH);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = X;
                break;
            case SwingConstants.RIGHT:
                xNew = X + (WIDTH - HEIGHT);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = X + ((WIDTH - HEIGHT) / 2);
                break;
        }
        super.setBounds(xNew, Y, HEIGHT, HEIGHT);
    }
    calcInnerBounds();
    init(getGaugeBounds().width, getGaugeBounds().height);
    setInitialized(true);
}
 
Example 8
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 9
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 10
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 int X, final int Y, final int WIDTH, final int HEIGHT) {
    if (WIDTH <= HEIGHT) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = Y;
                break;
            case SwingConstants.BOTTOM:
                yNew = Y + (HEIGHT - WIDTH);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = Y + ((HEIGHT - WIDTH) / 2);
                break;
        }
        super.setBounds(X, yNew, WIDTH, WIDTH);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = X;
                break;
            case SwingConstants.RIGHT:
                xNew = X + (WIDTH - HEIGHT);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = X + ((WIDTH - HEIGHT) / 2);
                break;
        }
        super.setBounds(xNew, Y, HEIGHT, HEIGHT);
    }
    calcInnerBounds();
    init(INNER_BOUNDS.width);
    initialized = true;
}
 
Example 11
Source File: Clock.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBounds(final int X, final int Y, final int WIDTH, final int HEIGHT) {
    if (WIDTH <= HEIGHT) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = Y;
                break;
            case SwingConstants.BOTTOM:
                yNew = Y + (HEIGHT - WIDTH);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = Y + ((HEIGHT - WIDTH) / 2);
                break;
        }
        super.setBounds(X, yNew, WIDTH, WIDTH);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = X;
                break;
            case SwingConstants.RIGHT:
                xNew = X + (WIDTH - HEIGHT);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = X + ((WIDTH - HEIGHT) / 2);
                break;
        }
        super.setBounds(xNew, Y, HEIGHT, HEIGHT);
    }
    calcInnerBounds();
    init(getGaugeBounds().width, getGaugeBounds().height);
    setInitialized(true);
}
 
Example 12
Source File: Clock.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 13
Source File: LightBulb.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBounds(final int X, final int Y, final int WIDTH, final int HEIGHT) {
    if (WIDTH <= HEIGHT) {
        // vertical
        int yNew;
        switch(verticalAlignment) {
            case SwingConstants.TOP:
                yNew = Y;
                break;
            case SwingConstants.BOTTOM:
                yNew = Y + (HEIGHT - WIDTH);
                break;
            case SwingConstants.CENTER:
            default:
                yNew = Y + ((HEIGHT - WIDTH) / 2);
                break;
        }
        super.setBounds(X, yNew, WIDTH, WIDTH);
    } else {
        // horizontal
        int xNew;
        switch(horizontalAlignment) {
            case SwingConstants.LEFT:
                xNew = X;
                break;
            case SwingConstants.RIGHT:
                xNew = X + (WIDTH - HEIGHT);
                break;
            case SwingConstants.CENTER:
            default:
                xNew = X + ((WIDTH - HEIGHT) / 2);
                break;
        }
        super.setBounds(xNew, Y, HEIGHT, HEIGHT);
    }
    calcInnerBounds();
    init(INNER_BOUNDS.width, INNER_BOUNDS.height);
}
 
Example 14
Source File: LightBulb.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, INNER_BOUNDS.height);
}
 
Example 15
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
private GradientPaint createBorderGradient(int tabPlacement) {
	if (tabPlacement == SwingConstants.BOTTOM) {
		return new GradientPaint(0, 0, borderNormalDark, 0, 25,
				borderNormalLight);
	} else if (tabPlacement == SwingConstants.LEFT) {
		return new GradientPaint(0, 0, borderNormalLight, 25, 0,
				borderNormalDark);
	} else if (tabPlacement == SwingConstants.RIGHT) {
		return new GradientPaint(0, 0, borderNormalDark, 25, 0,
				borderNormalLight);
	} else {
		return new GradientPaint(0, 0, borderNormalLight, 0, 25,
				borderNormalDark);
	}
}
 
Example 16
Source File: AbstractRadial.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: SwingClientGUI.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the left side panel of the client.
 *
 * @return A component containing the components left of the game screen
 */
private JComponent createLeftPanel(StendhalClient client) {
	minimap = new MapPanelController(client);
	final StatsPanelController stats = StatsPanelController.get();
	final BuddyPanelController buddies = BuddyPanelController.get();
	ScrolledViewport buddyScroll = new ScrolledViewport((JComponent) buddies.getComponent());
	buddyScroll.setScrollingSpeed(SCROLLING_SPEED);
	final JComponent buddyPane = buddyScroll.getComponent();
	buddyPane.setBorder(null);

	final JComponent leftColumn = SBoxLayout.createContainer(SBoxLayout.VERTICAL);
	leftColumn.add(minimap.getComponent(), SLayout.EXPAND_X);
	leftColumn.add(stats.getComponent(), SLayout.EXPAND_X);

	// Add a background for the tabs. The column itself has none.
	JPanel tabBackground = new JPanel();
	tabBackground.setBorder(null);
	tabBackground.setLayout(new SBoxLayout(SBoxLayout.VERTICAL));
	JTabbedPane tabs = new JTabbedPane(SwingConstants.BOTTOM);
	// Adjust the Tab Width, if we can. The default is pretty if there's
	// space, but in the column there are no pixels to waste.
	TabbedPaneUI ui = tabs.getUI();
	if (ui instanceof StyledTabbedPaneUI) {
		((StyledTabbedPaneUI) ui).setTabLabelMargins(1);
	}
	tabs.setFocusable(false);
	tabs.add("Friends", buddyPane);

	tabs.add("Group", GroupPanelController.get().getComponent());

	tabBackground.add(tabs, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y));
	leftColumn.add(tabBackground, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y));

	return leftColumn;
}
 
Example 18
Source File: TabOverviewButton.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Updates the location of <code>this</code> tab overview button.
 *
 * @param tabbedPane
 *            Tabbed pane.
 * @param tabAreaInsets
 *            Tab area insets.
 */
public void updateLocation(JTabbedPane tabbedPane, Insets tabAreaInsets) {
    if (tabbedPane == null)
        return;

    // Lock the button for the bounds change
    this.putClientProperty(TabOverviewButton.OWN_BOUNDS, Boolean.TRUE);
    int buttonSize = SubstanceSizeUtils.getLookupButtonSize();

    switch (tabbedPane.getTabPlacement()) {
    case SwingConstants.TOP:
        if (tabbedPane.getComponentOrientation().isLeftToRight())
            this.setBounds(2, tabAreaInsets.top, buttonSize, buttonSize);
        else
            this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                    tabAreaInsets.top, buttonSize, buttonSize);
        break;
    case SwingConstants.BOTTOM:
        if (tabbedPane.getComponentOrientation().isLeftToRight())
            this.setBounds(2,
                    tabbedPane.getBounds().height - tabAreaInsets.bottom - buttonSize - 4,
                    buttonSize, buttonSize);
        else
            this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                    tabbedPane.getBounds().height - tabAreaInsets.bottom - buttonSize - 4,
                    buttonSize, buttonSize);
        break;
    case SwingConstants.LEFT:
        this.setBounds(2, tabAreaInsets.top - 1, buttonSize, buttonSize);
        break;
    case SwingConstants.RIGHT:
        this.setBounds(tabbedPane.getBounds().width - tabAreaInsets.right - buttonSize - 2,
                tabAreaInsets.top - 1, buttonSize, buttonSize);
        break;
    }
    // Unlock the button for the bounds change
    this.putClientProperty(TabOverviewButton.OWN_BOUNDS, null);
}
 
Example 19
Source File: StyleEditor.java    From pdfxtk with Apache License 2.0 4 votes vote down vote up
static boolean validVerticalKey(int key) {
  return ((key == SwingConstants.TOP) || (key == SwingConstants.CENTER) || (key == SwingConstants.BOTTOM));
}
 
Example 20
Source File: MainFrame.java    From desktopclient-java with GNU General Public License v3.0 4 votes vote down vote up
private static WebPanel createListPanel(final WebTable list,
                                        String overlayText,
                                        WebToggleButton button) {
    // overlay for empty list
    WebOverlay listOverlay = new WebOverlay(list);
    listOverlay.setOverlayMargin(20);
    final WebTextArea overlayArea = new WebTextArea();
    overlayArea.setText(overlayText);
    overlayArea.setLineWrap(true);
    overlayArea.setWrapStyleWord(true);
    overlayArea.setMargin(View.MARGIN_DEFAULT);
    overlayArea.setFontSize(View.FONT_SIZE_BIG);
    overlayArea.setEditable(false);
    BorderPainter<WebTextArea> borderPainter = new BorderPainter<>(Color.LIGHT_GRAY);
    borderPainter.setRound(15);
    overlayArea.setPainter(borderPainter);
    list.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            overlayArea.setVisible(list.getModel().getRowCount() == 0);
        }
    });
    overlayArea.setVisible(list.getModel().getRowCount() == 0);
    listOverlay.addOverlay(overlayArea, SwingConstants.CENTER, SwingConstants.CENTER);

    WebScrollPane scrollPane = new ComponentUtils.ScrollPane(listOverlay);
    scrollPane.setDrawBorder(false);

    // button as overlay
    button.setOpaque(false);
    button.setUndecorated(true);
    WebOverlay chatListOverlay = new WebOverlay(scrollPane,
            button, SwingConstants.TRAILING, SwingConstants.BOTTOM);
    chatListOverlay.setOverlayMargin(0, 0, View.GAP_BIG, View.GAP_BIG + SCROLL_BAR_WIDTH);
    // fixing overlay button paint bug on startup, dont wanna know whats happening here
    SwingUtils.delayInvokeLater(0, new Runnable() {
        @Override
        public void run() {
            TooltipManager.showOneTimeTooltip(list, new Point(1,1), "");
        }
    });

    return chatListOverlay;
}