Java Code Examples for javax.swing.JButton#setVerticalTextPosition()
The following examples show how to use
javax.swing.JButton#setVerticalTextPosition() .
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: Place.java From nordpos with GNU General Public License v3.0 | 6 votes |
public void readValues(DataRead dr) throws BasicException { m_sId = dr.getString(1); m_sName = dr.getString(2); m_ix = dr.getInt(3).intValue(); m_iy = dr.getInt(4).intValue(); m_sfloor = dr.getString(5); m_bPeople = false; m_btn = new JButton(); m_btn.setFocusPainted(false); m_btn.setFocusable(false); m_btn.setRequestFocusEnabled(false); m_btn.setHorizontalTextPosition(SwingConstants.CENTER); m_btn.setVerticalTextPosition(SwingConstants.BOTTOM); m_btn.setIcon(ICO_FRE); m_btn.setText(m_sName); }
Example 2
Source File: JProductsSelector.java From nordpos with GNU General Public License v3.0 | 6 votes |
public void addProduct(Image img, String name, ActionListener al) { JButton btn = new JButton(); btn.applyComponentOrientation(getComponentOrientation()); btn.setText(name); btn.setFont(btn.getFont().deriveFont((float)24)); btn.setIcon(new ImageIcon(img)); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setMargin(new Insets(2, 2, 2, 2)); btn.setMaximumSize(new Dimension(80, 70)); btn.setPreferredSize(new Dimension(80, 70)); btn.setMinimumSize(new Dimension(80, 70)); btn.addActionListener(al); flowpanel.add(btn); }
Example 3
Source File: JTSTestBuilderToolBar.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private JButton createButton(String toolTipText, ImageIcon icon, java.awt.event.ActionListener actionListener) { JButton btn = new JButton(); btn.setMargin(new Insets(0, 0, 0, 0)); btn.setPreferredSize(new Dimension(30, 30)); btn.setIcon(icon); btn.setMinimumSize(new Dimension(30, 30)); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setSelected(false); btn.setToolTipText(toolTipText); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setFont(new java.awt.Font("SansSerif", 0, 10)); btn.setMaximumSize(new Dimension(30, 30)); btn.addActionListener(actionListener); return btn; }
Example 4
Source File: FrmCustom.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
private void init_Figure() { JFrame window = getFrame(); JMenuBar menuBar = new JMenuBar(); menuBar.add(new JMenu("File")); menuBar.add(new JMenu("Figure")); window.setJMenuBar(menuBar); JToolBar toolBar = new JToolBar(); JButton jButton_ZoomIn = new JButton(); jButton_ZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomIn.Image.png"))); // NOI18N jButton_ZoomIn.setToolTipText("Zoom In"); // NOI18N jButton_ZoomIn.setFocusable(false); jButton_ZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButton_ZoomIn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jButton_ZoomIn.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { //jButton_ZoomInActionPerformed(evt); } }); toolBar.add(jButton_ZoomIn); JButton jButton_ZoomOut = new JButton(); JButton jButton_Pan = new JButton(); JButton jButton_FullExtent = new JButton(); //window.getContentPane().setLayout(new GridLayout(2, 1)); //window.add(toolBar); window.getContentPane().add(toolBar, BorderLayout.PAGE_START); }
Example 5
Source File: ButtonDemo.java From marathonv5 with Apache License 2.0 | 5 votes |
public ButtonDemo() { ImageIcon leftButtonIcon = createImageIcon("images/right.gif"); ImageIcon middleButtonIcon = createImageIcon("images/middle.gif"); ImageIcon rightButtonIcon = createImageIcon("images/left.gif"); b1 = new JButton("Disable middle button", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for // left-to-right // locales 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); // 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); }
Example 6
Source File: TransparentToolBar.java From visualvm with GNU General Public License v2.0 | 5 votes |
private JButton createActionComponent(Action a) { JButton b = new JButton(); if (a != null && (a.getValue(Action.SMALL_ICON) != null || a.getValue(Action.LARGE_ICON_KEY) != null)) { b.setHideActionText(true); } b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.BOTTOM); b.setAction(a); return b; }
Example 7
Source File: JPaymentCashPos.java From nordpos with GNU General Public License v3.0 | 5 votes |
public void addButton(String image, double amount) { JButton btn = new JButton(); btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image), Formats.CURRENCY.formatValue(amount)))); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setMargin(new Insets(2, 2, 2, 2)); btn.addActionListener(new AddAmount(amount)); jPanel6.add(btn); }
Example 8
Source File: MainFrame.java From ios-image-util with MIT License | 5 votes |
/** * Set preferences to Menu button. * * @param button * @param foregroundColor * @param backgroundColor * @param font * @return */ private JButton initMenuButton(JButton button, Color foregroundColor, Color backgroundColor, Font font) { button.setBackground(backgroundColor); button.setForeground(foregroundColor); button.setBorderPainted(false); button.setFocusPainted(false); button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setFont(font); button.setMargin(new Insets(2, 16, 2, 16)); button.setOpaque(true); button.setDoubleBuffered(true); button.setRolloverEnabled(true); return button; }
Example 9
Source File: StandardButtonHelper.java From OpERP with MIT License | 5 votes |
public static JButton SetStandardSizeForButton(JButton btn){ btn.setMaximumSize(new Dimension(95, 95)); btn.setMinimumSize(new Dimension(95,95)); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setFont(new Font("Arial", Font.PLAIN, 10)); return btn; }
Example 10
Source File: ButtonHtmlDemo.java From marathonv5 with Apache License 2.0 | 4 votes |
public ButtonHtmlDemo() { ImageIcon leftButtonIcon = createImageIcon("images/right.gif"); ImageIcon middleButtonIcon = createImageIcon("images/middle.gif"); ImageIcon rightButtonIcon = createImageIcon("images/left.gif"); b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>", leftButtonIcon); Font font = b1.getFont().deriveFont(Font.PLAIN); b1.setFont(font); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for // left-to-right // locales b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("middle button", middleButtonIcon); b2.setFont(font); b2.setForeground(new Color(0xffffdd)); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>", rightButtonIcon); b3.setFont(font); // Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false); // 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); }
Example 11
Source File: SwingAppleCommander.java From AppleCommander with GNU General Public License v2.0 | 4 votes |
/** * Launch SwingAppleCommander. */ public void launch() { JMenuBar menuBar = createMenuBar(); JToolBar toolBar = new JToolBar(); JPanel topPanel = new JPanel(new BorderLayout()); tabPane = new JTabbedPane(JTabbedPane.TOP); topPanel.add(menuBar,BorderLayout.NORTH); topPanel.add(toolBar,BorderLayout.SOUTH); JButton aButton = new JButton(textBundle.get("OpenButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/opendisk.gif")))); //$NON-NLS-1$ aButton.setToolTipText(textBundle.get("SwtAppleCommander.OpenDiskImageTooltip")); //$NON-NLS-1$ aButton.setHorizontalTextPosition(JLabel.CENTER); aButton.setVerticalTextPosition(JLabel.BOTTOM); aButton.addActionListener(this); toolBar.add(aButton); JButton aButton2 = new JButton(textBundle.get("CreateButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/newdisk.gif")))); //$NON-NLS-1$ aButton2.setToolTipText(textBundle.get("SwtAppleCommander.CreateDiskImageTooltip")); //$NON-NLS-1$ aButton2.setHorizontalTextPosition(JLabel.CENTER); aButton2.setVerticalTextPosition(JLabel.BOTTOM); aButton2.addActionListener(this); toolBar.add(aButton2); JButton aButton3 = new JButton(textBundle.get("CompareButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/comparedisks.gif")))); //$NON-NLS-1$ aButton3.setToolTipText(textBundle.get("SwtAppleCommander.CompareDiskImageTooltip")); //$NON-NLS-1$ aButton3.setHorizontalTextPosition(JLabel.CENTER); aButton3.setVerticalTextPosition(JLabel.BOTTOM); aButton3.addActionListener(this); toolBar.add(aButton3); JButton aButton4 = new JButton(textBundle.get("AboutButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/about.gif")))); //$NON-NLS-1$ aButton4.setToolTipText(textBundle.get("SwtAppleCommander.AboutTooltip")); //$NON-NLS-1$ aButton4.setHorizontalTextPosition(JLabel.CENTER); aButton4.setVerticalTextPosition(JLabel.BOTTOM); aButton4.addActionListener(this); toolBar.add(aButton4); SwingAppleCommander application = new SwingAppleCommander(); application.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/diskicon.gif"))); //$NON-NLS-1$ application.setTitle(textBundle.get("SwtAppleCommander.AppleCommander")); titleLabel = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/AppleCommanderLogo.jpg")))); addTitleTabPane(); application.getContentPane().add(topPanel, BorderLayout.NORTH); application.getContentPane().add(tabPane, BorderLayout.CENTER); application.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); application.pack(); application.setVisible(true); }
Example 12
Source File: EditorFrame.java From settlers-remake with MIT License | 4 votes |
/** * Create the toolbar from menu.properties */ private void createToolbar() { ActionMap actionMap = ((JPanel) this.getContentPane()).getActionMap(); JToolBar tb = new JToolBar(); tb.setFloatable(false); for (String toolName : menuconfig.getProperty("toolbar", "").split(",")) { toolName = toolName.trim(); if (toolName.isEmpty()) { continue; } if ("---".equals(toolName)) { tb.addSeparator(); } else if ("player-spinner".equals(toolName)) { tb.add(new JLabel(EditorLabels.getLabel("window.current-player"))); JComponent playerSpinner = createPlayerSelectSelection(); tb.add(playerSpinner); } else { final Action action = actionMap.get(toolName); if (action == null) { System.err.println("Action \"" + toolName + "\" not found!"); continue; } final JButton bt = tb.add(action); action.addPropertyChangeListener(evt -> { if (Action.NAME.equals(evt.getPropertyName())) { setButtonText(bt, action); } }); setButtonText(bt, action); bt.setVerticalTextPosition(SwingConstants.CENTER); bt.setHorizontalTextPosition(SwingConstants.RIGHT); } } add(tb, BorderLayout.NORTH); }
Example 13
Source File: LibraryPanel.java From HubPlayer with GNU General Public License v3.0 | 4 votes |
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings({ "unchecked", "serial" }) // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { aScrollPanel = new JScrollPane(); dataTable = new JTable(); libraryTableModel = new LibraryTableModel(); libraryOperation = new LibraryOperation(); aToolBar = new JToolBar(); moreSearch = new JButton(); setLayout(new BorderLayout()); aScrollPanel .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); aScrollPanel .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); aScrollPanel.setMaximumSize(new Dimension(615, 481)); // 设置20行空数据 dataTable.setModel(libraryTableModel); libraryTableModel.setLibraryOperation(libraryOperation); // 定义"操作栏"的渲染器 显示按钮 dataTable.getColumn("操作").setCellRenderer( new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return value instanceof JPanel ? (JPanel) value : super .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }); // 定义"操作栏"的编辑器 响应按钮事件 dataTable.getColumn("操作").setCellEditor(new CellEditor()); dataTable.setColumnSelectionAllowed(true); dataTable.setRowHeight(23); aScrollPanel.setViewportView(dataTable); dataTable.getColumnModel().getSelectionModel() .setSelectionMode(ListSelectionModel.SINGLE_SELECTION); add(aScrollPanel, BorderLayout.CENTER); aToolBar.setFloatable(false); aToolBar.setRollover(true); aToolBar.setOpaque(false); moreSearch.setText("更多数据"); moreSearch.setFocusable(false); moreSearch.setHorizontalTextPosition(SwingConstants.CENTER); moreSearch.setVerticalTextPosition(SwingConstants.BOTTOM); // moreSearch.setEnabled(false); aToolBar.add(moreSearch); Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createLineBorder(Color.BLACK)); box.setOpaque(true); box.add(aToolBar); add(box, BorderLayout.SOUTH); }
Example 14
Source File: OptionMenu.java From Math-Game with Apache License 2.0 | 4 votes |
public OptionMenu(MathGame mathGame) { this.mathGame = mathGame; this.tm = mathGame.getTypeManager(); this.setLayout(new GridBagLayout()); // this.setLayout(new FlowLayout(FlowLayout.CENTER)); gbc = new GridBagConstraints(); // Set size Dimension size = getPreferredSize(); size.width = mathGame.getWidth(); size.height = mathGame.getHeight(); setPreferredSize(size); // Image initialization background = new ImageIcon(OptionMenu.class.getResource(BACKGROUND_FILE)); buttonImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_IMAGE_FILE)); buttonRollOverImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_ROLLOVER_IMAGE_FILE)); buttonPressedImage = new ImageIcon(OptionMenu.class.getResource(BUTTON_PRESSED_IMAGE_FILE)); // Button creation buttonMap = new HashMap<String, JToggleButton>(); initModes(); initTypes(); initDiffs(); // Default selections modes.get(0).setSelected(true); types.get(0).setSelected(true); diffs.get(0).setSelected(true); mathGame.setGameState(GameState.PRACTICE); play = new JButton("Play"); play.setFont(eurostile24); play.setHorizontalTextPosition(JButton.CENTER); play.setVerticalTextPosition(JButton.CENTER); play.setBorderPainted(false); play.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); play.addActionListener(this); try { play.setIcon(buttonImage); play.setRolloverIcon(buttonRollOverImage); play.setPressedIcon(buttonPressedImage); } catch (Exception ex) { ex.printStackTrace(); } gbc.insets = new Insets(5, 5, 5, 5); gbc.gridwidth = 3; gbc.gridheight = 3; gbc.gridx = 0; gbc.gridy = 0; add(modePanel, gbc); gbc.gridx = 4; gbc.gridy = 0; gbc.gridwidth = 3; gbc.gridheight = 3; add(typePanel, gbc); gbc.gridx = 8; gbc.gridy = 0; gbc.weighty = 1; gbc.gridwidth = 3; gbc.gridheight = 3; add(diffPanel, gbc); gbc.gridx = 4; gbc.gridy = 3; add(play, gbc); }