Java Code Examples for javax.swing.JButton#setText()
The following examples show how to use
javax.swing.JButton#setText() .
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: ReportEditorTest.java From ramus with GNU General Public License v3.0 | 6 votes |
public ReportEditorTest() { setSize(1200, 800); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); JPanel panel = new JPanel(new BorderLayout()); XMLDiagram diagram = new XMLDiagram(); ReportEditor editor = new ReportEditor(diagram); setContentPane(panel); JScrollPane pane = new JScrollPane(editor); panel.add(pane, BorderLayout.CENTER); JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); for (Action action : editor.getActions()) { JButton button = bar.add(action); button.setText((String) action.getValue(Action.ACTION_COMMAND_KEY)); } }
Example 2
Source File: ItemListControl.java From LoboBrowser with MIT License | 6 votes |
public ItemListControl(final ItemEditorFactory<T> ief) { this.itemEditorFactory = ief; this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.comboBox = new JComboBox<>(); this.comboBox.setPreferredSize(new Dimension(100, 24)); this.comboBox.setEditable(false); final JButton editButton = new JButton(); editButton.setAction(new EditAction(false)); editButton.setText("Edit"); final JButton addButton = new JButton(); addButton.setAction(new EditAction(true)); addButton.setText("Add"); final JButton removeButton = new JButton(); removeButton.setAction(new RemoveAction()); removeButton.setText("Remove"); this.add(this.comboBox); this.add(editButton); this.add(addButton); this.add(removeButton); }
Example 3
Source File: SignIn.java From dctb-utfpr-2018-1 with Apache License 2.0 | 6 votes |
public SignIn(JFrame parent){ this.parent = parent; setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); setBackground(new Color(0x000a1f)); createFields(); JButton submit = styleButtons(); submit.setText("SIGN IN"); add(Box.createRigidArea(new Dimension(0, 25))); add(submit); /*submit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("login"); } });*/ submit.addActionListener(this); }
Example 4
Source File: ToolBarDemo.java From marathonv5 with Apache License 2.0 | 6 votes |
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) { // Look for the image. String imgLocation = "images/" + imageName + ".gif"; URL imageURL = ToolBarDemo.class.getResource(imgLocation); // Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { // image found button.setIcon(new ImageIcon(imageURL, altText)); } else { // no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
Example 5
Source File: DefaultsDisplay.java From littleluck with Apache License 2.0 | 6 votes |
public ValueRenderer(Color colors[]) { super(colors); buttonIconRenderer = new JButton(); buttonIconRenderer.setBorderPainted(false); buttonIconRenderer.setContentAreaFilled(false); buttonIconRenderer.setText("(for AbstractButtons only)"); radioIconRenderer = new JRadioButton(); radioIconRenderer.setBorderPainted(false); radioIconRenderer.setText("for JRadioButtons only)"); checkboxIconRenderer = new JCheckBox(); checkboxIconRenderer.setBorderPainted(false); checkboxIconRenderer.setText("for JCheckBoxes only)"); menuItemIconRenderer = new JMenuItem(); menuItemIconRenderer.setBorderPainted(false); menuItemIconRenderer.setText("(for JMenuItems only)"); }
Example 6
Source File: ConfigWindow.java From rscplus with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); button.setText("..."); button.setFocusable(true); button.requestFocusInWindow(); }
Example 7
Source File: DocBookScriptReportEditorView.java From ramus with GNU General Public License v3.0 | 5 votes |
@Override protected void createButtons(ButtonGroup group) { JToggleButton button1 = createOpenViewButton(group, editorView); button1.setSelected(true); buttonsPanel.add(button1); buttonsPanel.add(createOpenViewButton(group, htmlView)); Iterator<DocBookExporter> iterator = AdditionalPluginLoader .loadProviders(DocBookExporter.class); while (iterator.hasNext()) { final DocBookExporter exporter = iterator.next(); JButton tb = new JButton(); tb.setText(exporter.getActionName()); tb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exporter.createReport(getFramework(), new ReportLoadCallback() { @Override public InputStream getDocBookInputStream() { // TODO Auto-generated method stub return null; } }); } }); buttonsPanel.add(tb); } }
Example 8
Source File: ResultPanel.java From tmc-intellij with MIT License | 5 votes |
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { jpanel1 = new JPanel(); jpanel1.setLayout(new GridLayoutManager(5, 7, new Insets(0, 0, 0, 0), -1, -1)); final JLabel label1 = new JLabel(); label1.setText("Code submitted to TMC pastebin"); jpanel1.add(label1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); textField1 = new JTextField(); textField1.setText(""); jpanel1.add(textField1, new GridConstraints(2, 1, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); copyToClipboardButton = new JButton(); copyToClipboardButton.setText("Copy to clipboard"); jpanel1.add(copyToClipboardButton, new GridConstraints(3, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); viewPasteButton = new JButton(); viewPasteButton.setText("View paste"); jpanel1.add(viewPasteButton, new GridConstraints(3, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); okButton = new JButton(); okButton.setText("Ok"); jpanel1.add(okButton, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); jpanel1.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); final Spacer spacer2 = new Spacer(); jpanel1.add(spacer2, new GridConstraints(4, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); final Spacer spacer3 = new Spacer(); jpanel1.add(spacer3, new GridConstraints(1, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(10, -1), new Dimension(10, -1), new Dimension(10, -1), 0, false)); final Spacer spacer4 = new Spacer(); jpanel1.add(spacer4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(10, -1), new Dimension(10, -1), new Dimension(10, -1), 0, false)); }
Example 9
Source File: ProgramPanel.java From mpcmaid with GNU Lesser General Public License v2.1 | 5 votes |
private void refreshPadButton(final Pad pad) { final String htmlLabel = htmlSamples(pad); final JButton button = padButtons[pad.getElementIndex()]; if (button != null) { button.setText(htmlLabel); } }
Example 10
Source File: ContactsPanel.java From xyTalk-pc with GNU Affero General Public License v3.0 | 5 votes |
private void initComponents() { keboardPanel = new JPanel(); keboardPanel.setBackground(Colors.DARK); for (int i=0; i < keys.length; i++) { JButton btn = new JButton(); btn.setBackground(Colors.DARK); btn.setForeground(Colors.FONT_WHITE); btn.setText(String.valueOf(keys[i])); btn.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { refreshData(btn.getText()); super.mouseClicked(e); } }); keboardPanel.add(btn); } ImageIcon sendingIcon = new ImageIcon(getClass().getResource("/image/loading7.gif")); loadingProgress.setIcon(sendingIcon); loadingProgress.setVisible(false); keboardPanel.add(loadingProgress, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 1).setInsets(0, 0, 0, 0)); contactsListView = new RCListView(); }
Example 11
Source File: JPlagCreator.java From jplag with GNU General Public License v3.0 | 5 votes |
public static JButton createOpenFileButton(String toolTip) { JButton button = new JButton(); button.setText(""); button.setToolTipText(toolTip); button.setIcon(new ImageIcon(JPlagCreator.class.getResource("/atujplag/data/open.gif"))); button.setPreferredSize(new java.awt.Dimension(24, 24)); button.setBackground(JPlagCreator.SYSTEMCOLOR); return button; }
Example 12
Source File: Test4652928.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static BeanContext fill(BeanContext context) { context.add(new JLabel("label")); context.add(new JButton("button")); JButton button = new JButton(); button.setText("another button"); context.add(button); return context; }
Example 13
Source File: DownloadListPanel.java From tmc-intellij with MIT License | 5 votes |
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { mainpanel = new JPanel(); mainpanel.setLayout(new GridLayoutManager(7, 6, new Insets(0, 0, 0, 0), -1, -1)); final JScrollPane scrollPane1 = new JScrollPane(); mainpanel.add(scrollPane1, new GridConstraints(3, 1, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(500, 200), new Dimension(500, 200), new Dimension(500, 200), 0, false)); exerciselist = new CustomCheckBoxList(); scrollPane1.setViewportView(exerciselist); final JLabel label1 = new JLabel(); label1.setText("Select exercises"); mainpanel.add(label1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); mainpanel.add(spacer1, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); downloadButton = new JButton(); downloadButton.setText("Download"); mainpanel.add(downloadButton, new GridConstraints(5, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); cancelButton = new JButton(); cancelButton.setText("Cancel"); mainpanel.add(cancelButton, new GridConstraints(5, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); mainpanel.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(10, -1), new Dimension(10, -1), new Dimension(10, -1), 0, false)); final Spacer spacer3 = new Spacer(); mainpanel.add(spacer3, new GridConstraints(3, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, 1, new Dimension(10, -1), new Dimension(10, -1), new Dimension(10, -1), 0, false)); final Spacer spacer4 = new Spacer(); mainpanel.add(spacer4, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); final Spacer spacer5 = new Spacer(); mainpanel.add(spacer5, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); final Spacer spacer6 = new Spacer(); mainpanel.add(spacer6, new GridConstraints(4, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); final Spacer spacer7 = new Spacer(); mainpanel.add(spacer7, new GridConstraints(6, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_FIXED, new Dimension(-1, 10), new Dimension(-1, 10), new Dimension(-1, 10), 0, false)); selectAllButton = new JButton(); selectAllButton.setText("Toggle all"); mainpanel.add(selectAllButton, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); }
Example 14
Source File: DatabaseViewer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
protected void setViewQueryButton( JButton _viewQueryButton, Dimension preferredButtonSize, JTextPane sqlEditorArea ) { _viewQueryButton.setIcon(ImageCache.getInstance().getImage(ImageCache.GLOBE)); _viewQueryButton.setToolTipText(VIEW_QUERY_TOOLTIP); _viewQueryButton.setText(""); _viewQueryButton.setPreferredSize(preferredButtonSize); _viewQueryButton.addActionListener(e -> { String sqlText = sqlEditorArea.getText().trim(); if (sqlText.length() > 0) { if (!sqlText.toLowerCase().startsWith("select")) { JOptionPane.showMessageDialog(this, "Viewing of data is allowed only for SELECT statements.", "WARNING", JOptionPane.WARNING_MESSAGE, null); return; } } final LogConsoleController logConsole = new LogConsoleController(pm); JFrame window = guiBridge.showWindow(logConsole.asJComponent(), "Console Log"); new Thread(() -> { boolean hadErrors = false; try { logConsole.beginProcess("Run query"); hadErrors = viewSpatialQueryResult(null, sqlText, pm, false); } catch (Exception ex) { pm.errorMessage(ex.getLocalizedMessage()); hadErrors = true; } finally { logConsole.finishProcess(); logConsole.stopLogging(); if (!hadErrors) { logConsole.setVisible(false); window.dispose(); } } }, "DatabaseViewer->run query and view geometries").start(); }); }
Example 15
Source File: Test4652928.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static BeanContext fill(BeanContext context) { context.add(new JLabel("label")); context.add(new JButton("button")); JButton button = new JButton(); button.setText("another button"); context.add(button); return context; }
Example 16
Source File: BoardEditor.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Sets up JButtons */ private JButton prepareButton(String iconName, String buttonName, ArrayList<JButton> bList) { JButton button = new JButton(buttonName); button.addActionListener(this); // Get the normal icon File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setIcon(new ImageIcon(imageButton)); // When there is an icon, then the text can be removed button.setText(""); } // Get the hover icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setRolloverIcon(new ImageIcon(imageButton)); } // Get the disabled icon, if any file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_G.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setDisabledIcon(new ImageIcon(imageButton)); } String tt = Messages.getString("BoardEditor."+iconName+"TT"); if (tt.length() != 0) { button.setToolTipText(tt); //$NON-NLS-1$ //$NON-NLS-2$ } button.setMargin(new Insets(0,0,0,0)); if (bList != null) bList.add(button); return button; }
Example 17
Source File: ProductsPanel.java From nordpos with GNU General Public License v3.0 | 5 votes |
@Override public Component getToolbarExtrasDevicePLUs() { JButton btnDevicePLUs = new JButton(); btnDevicePLUs.setText(AppLocal.getIntString("button.uploadplu")); btnDevicePLUs.setVisible(app.getDevicePLUs() != null); btnDevicePLUs.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { btnExtrasDevicePLUsActionPerformed(evt); } }); return btnDevicePLUs; }
Example 18
Source File: ScenarioDialog.java From megamek with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unchecked") public ScenarioDialog(final JFrame frame, Player[] pa) { super(frame, Messages.getString("MegaMek.ScenarioDialog.title"), true); //$NON-NLS-1$ m_frame = frame; m_players = pa; m_labels = new JLabel[pa.length]; m_typeChoices = new JComboBox[pa.length]; m_camoButtons = new JButton[pa.length]; playerTypes = new int[pa.length]; for (int x = 0; x < pa.length; x++) { final IPlayer curPlayer = m_players[x]; curPlayer.setColorIndex(x); m_labels[x] = new JLabel(pa[x].getName(), SwingConstants.LEFT); m_typeChoices[x] = new JComboBox<String>(); m_typeChoices[x].addItem(Messages .getString("MegaMek.ScenarioDialog.me")); //$NON-NLS-1$ m_typeChoices[x].addItem(Messages .getString("MegaMek.ScenarioDialog.otherh")); //$NON-NLS-1$ m_typeChoices[x].addItem(Messages .getString("MegaMek.ScenarioDialog.bot")); //$NON-NLS-1$ m_typeChoices[x].addItem(Messages .getString("MegaMek.ScenarioDialog.otherbot")); //$NON-NLS-1$ m_camoButtons[x] = new JButton(); final JButton curButton = m_camoButtons[x]; curButton.setText(Messages.getString("MegaMek.NoCamoBtn")); //$NON-NLS-1$ curButton.setPreferredSize(new Dimension(84, 72)); final CamoChoiceDialog dialog = new CamoChoiceDialog(frame, curButton); dialog.setPlayer(curPlayer); curButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(true); } }); } getContentPane().setLayout(new BorderLayout()); JPanel choicePanel = new JPanel(); choicePanel.setLayout(new GridLayout(pa.length + 1, 0)); choicePanel.add(new JLabel(Messages .getString("MegaMek.ScenarioDialog.pNameType"))); //$NON-NLS-1$ choicePanel.add(new JLabel(Messages .getString("MegaMek.ScenarioDialog.Camo"))); //$NON-NLS-1$ for (int x = 0; x < pa.length; x++) { JPanel typePanel = new JPanel(); typePanel.setLayout(new GridLayout(0, 1)); typePanel.add(m_labels[x]); typePanel.add(m_typeChoices[x]); choicePanel.add(typePanel); choicePanel.add(m_camoButtons[x]); } getContentPane().add(choicePanel, BorderLayout.CENTER); JPanel butPanel = new JPanel(); butPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton bOkay = new JButton(Messages.getString("Okay")); //$NON-NLS-1$ bOkay.setActionCommand("okay"); //$NON-NLS-1$ bOkay.addActionListener(this); JButton bCancel = new JButton(Messages.getString("Cancel")); //$NON-NLS-1$ bCancel.setActionCommand("cancel"); //$NON-NLS-1$ bCancel.addActionListener(this); butPanel.add(bOkay); butPanel.add(bCancel); getContentPane().add(butPanel, BorderLayout.SOUTH); pack(); setResizable(false); setLocation((frame.getLocation().x + (frame.getSize().width / 2)) - (getSize().width / 2), (frame.getLocation().y + (frame.getSize().height / 2)) - (getSize().height / 2)); }
Example 19
Source File: ImageViewer.java From netbeans with Apache License 2.0 | 4 votes |
/** Creates toolbar. */ private JToolBar createToolBar() { // Definition of toolbar. JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); //NOI18N toolBar.setFloatable (false); toolBar.setName (NbBundle.getBundle(ImageViewer.class).getString("ACSN_Toolbar")); toolBar.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACSD_Toolbar")); JButton outButton = new JButton(SystemAction.get(ZoomOutAction.class)); outButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_ZoomOut")); outButton.setMnemonic(NbBundle.getBundle(ImageViewer.class).getString("ACS_Out_BTN_Mnem").charAt(0)); outButton.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACSD_Out_BTN")); outButton.setText(""); toolBar.add(outButton); toolbarButtons.add(outButton); JButton inButton = new JButton(SystemAction.get(ZoomInAction.class)); inButton.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_ZoomIn")); inButton.setMnemonic(NbBundle.getBundle(ImageViewer.class).getString("ACS_In_BTN_Mnem").charAt(0)); inButton.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACSD_In_BTN")); inButton.setText(""); toolBar.add(inButton); toolbarButtons.add(inButton); toolBar.addSeparator(new Dimension(11, 0)); JButton button; toolBar.add(button = getZoomButton(1,1)); toolbarButtons.add(button); toolBar.addSeparator(new Dimension(11, 0)); toolBar.add(button = getZoomButton(1,3)); toolbarButtons.add(button); toolBar.add(button = getZoomButton(1,5)); toolbarButtons.add(button); toolBar.add(button = getZoomButton(1,7)); toolbarButtons.add(button); toolBar.addSeparator(new Dimension(11, 0)); toolBar.add(button = getZoomButton(3,1)); toolbarButtons.add(button); toolBar.add(button = getZoomButton(5,1)); toolbarButtons.add(button); toolBar.add(button = getZoomButton(7,1)); toolbarButtons.add(button); toolBar.addSeparator(new Dimension(11, 0)); // SystemAction sa = SystemAction.get(CustomZoomAction.class); // sa.putValue (Action.SHORT_DESCRIPTION, NbBundle.getBundle(ImageViewer.class).getString("LBL_CustomZoom")); toolBar.add (button = getZoomButton ()); toolbarButtons.add(button); toolBar.addSeparator(new Dimension(11, 0)); toolBar.add(button = getGridButton()); toolbarButtons.add(button); // Image Dimension toolBar.addSeparator(new Dimension(11, 0)); toolBar.add(new JLabel(NbBundle.getMessage(ImageViewer.class, "LBL_ImageDimensions", imageWidth, imageHeight))); // Image File Size in KB, MB if (imageSize != -1) { toolBar.addSeparator(new Dimension(11, 0)); double kb = 1024.0; double mb = kb * kb; final double size; final String label; if (imageSize >= mb) { size = imageSize / mb; label = "LBL_ImageSizeMb"; // NOI18N } else if (imageSize >= kb) { size = imageSize / kb; label = "LBL_ImageSizeKb"; // NOI18N } else { size = imageSize; label = "LBL_ImageSizeBytes"; //NOI18N } toolBar.add(new JLabel(NbBundle.getMessage(ImageViewer.class, label, formatter.format(size)))); } for (JButton jb : toolbarButtons) { jb.setFocusable(false); } return toolBar; }
Example 20
Source File: ActionWindowDeps.java From Llunatic with GNU General Public License v3.0 | 4 votes |
@Override public Component getToolbarPresenter() { JButton btn = new JButton(this); btn.setText(""); return btn; }