List of usage examples for javax.swing SwingConstants LEFT
int LEFT
To view the source code for javax.swing SwingConstants LEFT.
Click Source Link
From source file:com.aw.core.format.FillerFormat.java
public static String fill(String source, char fillerCharacter, int length, int aligment, boolean fillInclusiveEmptyString) { // if (StringUtils.isEmpty(source) || length<0) { if (length < 0) { return source; }/*from w ww. j av a 2 s .c o m*/ if (source == null) source = ""; if (source.length() > length) return source.substring(0, length); //throw new AWBusinessException("No se puede llenar '"+source+"' pues tamao excede "+length); source = source.trim(); if (source.length() == length) return source; if (!fillInclusiveEmptyString && source.length() == 0) return source; if (source.length() > length) return source.substring(0, length); StringBuffer buf = new StringBuffer(length); if (aligment == SwingConstants.CENTER) { int left = (length - source.length()) / 2; int right = length - (source.length() + left); fill(buf, fillerCharacter, left); buf.append(source); fill(buf, fillerCharacter, right); } else { if (aligment == SwingConstants.LEFT) buf.append(source); fill(buf, fillerCharacter, length - source.length()); if (aligment == SwingConstants.RIGHT) buf.append(source); } return buf.toString(); }
From source file:client.gui.ButtonPanel.java
public ButtonPanel() { GlobalVariables.buttonPanel = this; exchangeCards = new JButton("Exchange cards"); exchangeCards.setHorizontalAlignment(SwingConstants.LEFT); exchangeCards.addActionListener(this); check = new JButton("Check"); check.setHorizontalAlignment(SwingConstants.LEFT); check.addActionListener(this); bet = new JButton("Bet"); bet.setHorizontalAlignment(SwingConstants.LEFT); bet.addActionListener(this); raise = new JButton("Raise"); raise.setHorizontalAlignment(SwingConstants.LEFT); raise.addActionListener(this); call = new JButton("Call"); call.setHorizontalAlignment(SwingConstants.LEFT); call.addActionListener(this); fold = new JButton("Fold"); fold.setHorizontalAlignment(SwingConstants.LEFT); fold.addActionListener(this); allIn = new JButton("All-In"); allIn.setHorizontalAlignment(SwingConstants.LEFT); allIn.addActionListener(this); startGame = new JButton("Start Game"); startGame.setHorizontalAlignment(SwingConstants.LEFT); startGame.addActionListener(this); smallBlind = new JButton("Small Blind"); smallBlind.setHorizontalAlignment(SwingConstants.LEFT); smallBlind.addActionListener(this); bigBlind = new JButton("Big Blind"); bigBlind.setHorizontalAlignment(SwingConstants.LEFT); bigBlind.addActionListener(this); liveBlind = new JButton("Live Blind"); liveBlind.setHorizontalAlignment(SwingConstants.LEFT); liveBlind.addActionListener(this); setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5;// w w w .j a va2 s.c o m c.gridx = 0; c.gridy = 0; add(exchangeCards, c); c.gridy++; add(check, c); c.gridy++; add(bet, c); c.gridy++; add(raise, c); c.gridy++; add(call, c); c.gridy++; add(fold, c); c.gridy++; add(allIn, c); // c.gridy++; // add(startGame, c); c.gridy++; add(smallBlind, c); c.gridy++; add(bigBlind, c); c.gridy++; add(liveBlind, c); exchangeCards.setVisible(false); check.setVisible(false); bet.setVisible(false); raise.setVisible(false); call.setVisible(false); fold.setVisible(false); allIn.setVisible(false); smallBlind.setVisible(false); bigBlind.setVisible(false); liveBlind.setVisible(false); }
From source file:com.moneydance.modules.features.importlist.table.HeaderRenderer.java
@Override public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { Component component = this.defaultHeaderTableCellRenderer.getTableCellRendererComponent(table, value, hasFocus, hasFocus, row, column); if (component instanceof JComponent) { JComponent jComponent = (JComponent) component; jComponent.setBorder(new EmptyBorder(1, 1, 1, 1)); jComponent.setOpaque(false);/* w w w . j a v a2 s . com*/ if (jComponent instanceof JLabel) { JLabel jLabel = (JLabel) jComponent; jLabel.setHorizontalAlignment(SwingConstants.LEFT); } } component.setFont(Preferences.getHeaderFont()); component.setForeground(Preferences.getHeaderForeground()); component.setSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setMinimumSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setPreferredSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setMaximumSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); return component; }
From source file:CustomIconDemo.java
public CustomIconDemo() { Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT); Icon middleButtonIcon = createImageIcon("images/middle.gif", "the middle button"); Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT); b1 = new JButton("Disable middle button", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("Middle button", middleButtonIcon); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("Enable middle button", rightButtonIcon); // Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false);/* w w w . ja v a 2 s. c o m*/ // Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); // Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
From source file:CustomIconDemo.java
public CustomIconDemo() { Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT); Icon middleButtonIcon = new ImageIcon("images/middle.gif"); Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT); b1 = new JButton("Disable middle button", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEFT); b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("Middle button", middleButtonIcon); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("Enable middle button", rightButtonIcon); //Use the default text position of CENTER, RIGHT. b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false);/* ww w. ja v a 2 s . com*/ //Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); //Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
From source file:PaintUtils.java
/** * Returns the bounds that the text of a label will be drawn into. * Takes into account the current font metrics. *///from w ww . ja va 2 s . c om public static Rectangle getTextBounds(Graphics g, JLabel label) { FontMetrics fm = g.getFontMetrics(); Rectangle2D r2d = fm.getStringBounds(label.getText(), g); Rectangle rect = r2d.getBounds(); int xOffset = 0; switch (label.getHorizontalAlignment()) { case SwingConstants.RIGHT: case SwingConstants.TRAILING: xOffset = label.getBounds().width - rect.width; break; case SwingConstants.CENTER: xOffset = (label.getBounds().width - rect.width) / 2; break; default: case SwingConstants.LEFT: case SwingConstants.LEADING: xOffset = 0; break; } int yOffset = 0; switch (label.getVerticalAlignment()) { case SwingConstants.TOP: yOffset = 0; break; case SwingConstants.CENTER: yOffset = (label.getBounds().height - rect.height) / 2; break; case SwingConstants.BOTTOM: yOffset = label.getBounds().height - rect.height; break; } return new Rectangle(xOffset, yOffset, rect.width, rect.height); }
From source file:forge.gui.CardDetailPanel.java
public CardDetailPanel() { super();//from w ww . j a va2s. c o m setLayout(null); setOpaque(false); nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build(); powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); setInfoLabel = new JLabel(); setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER); final Font font = new Font("Dialog", 0, 14); nameCostLabel.setFont(font); typeLabel.setFont(font); idLabel.setFont(font); powerToughnessLabel.setFont(font); cdArea = new FHtmlViewer(); cdArea.setBorder(new EmptyBorder(2, 6, 2, 6)); cdArea.setOpaque(false); scrArea = new FScrollPane(cdArea, false); add(nameCostLabel); add(typeLabel); add(idLabel); add(powerToughnessLabel); add(setInfoLabel); add(scrArea); }
From source file:net.sf.vfsjfilechooser.accessories.bookmarks.BookmarksManagerPanel.java
public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) { this.parentDialog = parentDialog; this.chooser = chooser; model = new Bookmarks(); table = new JTable(model); scrollPane = new JScrollPane(table); table.setPreferredScrollableViewportSize(tableSize); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText")); bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText")); bOpen.setIcon(/*from w ww . ja va2 s .c o m*/ new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/document-open.png"))); bOpen.setHorizontalAlignment(SwingConstants.LEFT); bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText")); bAdd.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-add.png"))); bAdd.setHorizontalAlignment(SwingConstants.LEFT); bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText")); bEdit.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/book_edit.png"))); bEdit.setHorizontalAlignment(SwingConstants.LEFT); bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText")); bDelete.setIcon( new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-remove.png"))); bDelete.setHorizontalAlignment(SwingConstants.LEFT); bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText")); bMoveUp.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-up.png"))); bMoveUp.setHorizontalAlignment(SwingConstants.LEFT); bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText")); bMoveDown.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-down.png"))); bMoveDown.setHorizontalAlignment(SwingConstants.LEFT); final ActionHandler ah = new ActionHandler(); bOpen.addActionListener(ah); bCancel.addActionListener(ah); bEdit.addActionListener(ah); bAdd.addActionListener(ah); bDelete.addActionListener(ah); bMoveUp.addActionListener(ah); bMoveDown.addActionListener(ah); final Box south = Box.createHorizontalBox(); south.add(Box.createHorizontalGlue()); south.add(bCancel); south.add(Box.createHorizontalGlue()); final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5)); buttons.add(bAdd); buttons.add(bEdit); buttons.add(bDelete); buttons.add(bOpen); buttons.add(Box.createVerticalStrut(10)); buttons.add(bMoveUp); buttons.add(bMoveDown); JPanel east = new JPanel(); east.add(buttons, BorderLayout.NORTH); east.add(new JPanel(), BorderLayout.CENTER); // don't ask setLayout(new BorderLayout(10, 10)); add(scrollPane, BorderLayout.CENTER); add(south, BorderLayout.SOUTH); add(east, BorderLayout.EAST); setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background"))); }
From source file:com.googlecode.vfsjfilechooser2.accessories.bookmarks.BookmarksManagerPanel.java
public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) { this.parentDialog = parentDialog; this.chooser = chooser; model = new Bookmarks(); table = new JTable(model); scrollPane = new JScrollPane(table); table.setPreferredScrollableViewportSize(tableSize); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText")); bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText")); bOpen.setIcon(new ImageIcon( getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/document-open.png"))); bOpen.setHorizontalAlignment(SwingConstants.LEFT); bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText")); bAdd.setIcon(//from www . j a va 2 s . com new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-add.png"))); bAdd.setHorizontalAlignment(SwingConstants.LEFT); bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText")); bEdit.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/book_edit.png"))); bEdit.setHorizontalAlignment(SwingConstants.LEFT); bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText")); bDelete.setIcon(new ImageIcon( getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-remove.png"))); bDelete.setHorizontalAlignment(SwingConstants.LEFT); bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText")); bMoveUp.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-up.png"))); bMoveUp.setHorizontalAlignment(SwingConstants.LEFT); bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText")); bMoveDown.setIcon( new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-down.png"))); bMoveDown.setHorizontalAlignment(SwingConstants.LEFT); final ActionHandler ah = new ActionHandler(); bOpen.addActionListener(ah); bCancel.addActionListener(ah); bEdit.addActionListener(ah); bAdd.addActionListener(ah); bDelete.addActionListener(ah); bMoveUp.addActionListener(ah); bMoveDown.addActionListener(ah); final Box south = Box.createHorizontalBox(); south.add(Box.createHorizontalGlue()); south.add(bCancel); south.add(Box.createHorizontalGlue()); final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5)); buttons.add(bAdd); buttons.add(bEdit); buttons.add(bDelete); buttons.add(bOpen); buttons.add(Box.createVerticalStrut(10)); buttons.add(bMoveUp); buttons.add(bMoveDown); JPanel east = new JPanel(); east.add(buttons, BorderLayout.NORTH); east.add(new JPanel(), BorderLayout.CENTER); // don't ask setLayout(new BorderLayout(10, 10)); add(scrollPane, BorderLayout.CENTER); add(south, BorderLayout.SOUTH); add(east, BorderLayout.EAST); setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background"))); }
From source file:gdt.jgui.tool.JTextEncrypter.java
/** * The default constructor./*w w w .ja va 2 s . c o m*/ */ public JTextEncrypter() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Master password", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panel); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); JCheckBox chckbxNewCheckBox = new JCheckBox("Show"); chckbxNewCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); chckbxNewCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() != ItemEvent.SELECTED) { passwordField.setEchoChar('*'); } else { passwordField.setEchoChar((char) 0); } } }); panel.add(chckbxNewCheckBox); panel.setFocusTraversalPolicy( new FocusTraversalOnArray(new Component[] { chckbxNewCheckBox, passwordField })); passwordField = new JPasswordField(); passwordField.setMaximumSize(new Dimension(Integer.MAX_VALUE, passwordField.getPreferredSize().height)); panel.add(passwordField); JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, "Text", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panel_1); panel_1.setLayout(new BorderLayout(0, 0)); textArea = new JTextArea(); textArea.setColumns(1); panel_1.add(textArea); }