List of usage examples for javax.swing JButton setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
private void onStopDiscoveryPost(JButton stopStartButton) { depthComboBox.setEditable(true);/*w ww. jav a2s .c o m*/ addressTextField.setEditable(true); stopStartButton.setText("Start"); pauseResumeButton.setEnabled(false); stopStartButton.setEnabled(true); }
From source file:components.ToolBarDemo.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {//from w w w . j av a 2 s . c o m //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; }
From source file:TextSamplerDemo.java
protected void addStylesToDocument(StyledDocument doc) { //Initialize some styles. Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "SansSerif"); Style s = doc.addStyle("italic", regular); StyleConstants.setItalic(s, true); s = doc.addStyle("bold", regular); StyleConstants.setBold(s, true); s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 10); s = doc.addStyle("large", regular); StyleConstants.setFontSize(s, 16); s = doc.addStyle("icon", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig"); if (pigIcon != null) { StyleConstants.setIcon(s, pigIcon); }/*from www. j a v a 2s . c om*/ s = doc.addStyle("button", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon"); JButton button = new JButton(); if (soundIcon != null) { button.setIcon(soundIcon); } else { button.setText("BEEP"); } button.setCursor(Cursor.getDefaultCursor()); button.setMargin(new Insets(0, 0, 0, 0)); button.setActionCommand(buttonString); button.addActionListener(this); StyleConstants.setComponent(s, button); }
From source file:SwingToolBarDemo.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {// www.j av a2 s. c o m //Look for the image. String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif"; URL imageURL = SwingToolBarDemo.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; }
From source file:components.ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {//w ww . j a v a 2 s . c o m //Look for the image. String imgLocation = "images/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.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; }
From source file:misc.ActionDemo.java
public void createToolBar() { JButton button = null; //Create the toolbar. JToolBar toolBar = new JToolBar(); add(toolBar, BorderLayout.PAGE_START); //first button button = new JButton(leftAction); if (button.getIcon() != null) { button.setText(""); //an icon-only button }//from w ww . ja v a 2 s . c o m toolBar.add(button); //second button button = new JButton(middleAction); if (button.getIcon() != null) { button.setText(""); //an icon-only button } toolBar.add(button); //third button button = new JButton(rightAction); if (button.getIcon() != null) { button.setText(""); //an icon-only button } toolBar.add(button); }
From source file:ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {/*from w ww .ja v a 2 s.c o m*/ //Look for the image. String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.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; }
From source file:cz.alej.michalik.totp.client.OtpPanel.java
/** * Pid jeden panel se zznamem//from ww w . j av a 2 s .c om * * @param raw_data * Data z Properties * @param p * Properties * @param index * Index zznamu - pro vymazn */ public OtpPanel(String raw_data, final Properties p, final int index) { // Data jsou oddlena stednkem final String[] data = raw_data.split(";"); // this.setBackground(App.COLOR); this.setLayout(new GridBagLayout()); // Mkov rozloen prvk GridBagConstraints c = new GridBagConstraints(); this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100)); // Tla?tko pro zkoprovn hesla final JButton passPanel = new JButton(""); passPanel.setFont(passPanel.getFont().deriveFont(App.FONT_SIZE)); passPanel.setBackground(App.COLOR); // Zabere celou ku c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 100; this.add(passPanel, c); passPanel.setText(data[0]); // Tla?tko pro smazn JButton delete = new JButton("X"); try { String path = "/material-design-icons/action/drawable-xhdpi/ic_delete_black_24dp.png"; Image img = ImageIO.read(App.class.getResource(path)); delete.setIcon(new ImageIcon(img)); delete.setText(""); } catch (Exception e) { System.out.println("Icon not found"); } delete.setFont(delete.getFont().deriveFont(App.FONT_SIZE)); delete.setBackground(App.COLOR); // Zabere kousek vpravo c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.anchor = GridBagConstraints.EAST; this.add(delete, c); // Akce pro vytvoen a zkoprovn hesla do schrnky passPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Generuji kod pro " + data[1]); System.out.println(new Base32().decode(data[1].getBytes()).length); clip.set(new TOTP(new Base32().decode(data[1].getBytes())).toString()); System.out.printf("Kd pro %s je ve schrnce\n", data[0]); passPanel.setText("Zkoprovno"); // Zobraz zprvu na 1 vteinu int time = 1000; // Animace zobrazen zprvy po zkoprovn final Timer t = new Timer(time, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { passPanel.setText(data[0]); } }); t.start(); t.setRepeats(false); } }); // Akce pro smazn panelu a uloen zmn delete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.printf("Odstrann %s s indexem %d\n", data[0], index); p.remove(String.valueOf(index)); App.saveProperties(); App.loadProperties(); } }); }
From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java
public SimpleChart(final String title, final StreamConnection connection) { super(title); dataset = new DynamicTimeSeriesCollection(SERIES, COUNT, new Second()); dataset.setTimeBase(new Second(0, 0, 0, 1, 1, Calendar.getInstance().get(Calendar.YEAR))); // Init.// w ww . jav a2 s . c om // for (int i = 0; i < SERIES; i++){ // dataset.addSeries(new float[]{0}, i, "Serie " + (i+1)); // } dataset.addSeries(new float[] { 0, 0, 0 }, 0, "Raw"); dataset.addSeries(new float[] { 0, 0, 0 }, 1, "Software"); dataset.addSeries(new float[] { 0, 0, 0 }, 2, "Hardware"); this.connection = connection; // connection.setStreamReader(new FixedStreamReader(1)); JFreeChart chart = createChart(dataset); final JButton run = new JButton(START); run.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); JButton source = (JButton) e.getSource(); try { if (cmd.equals(START)) { connection.addListener(SimpleChart.this); if (!connection.isConnected()) connection.connect(); source.setText(STOP); source.setActionCommand(STOP); } else { connection.removeListener(SimpleChart.this); source.setText(START); source.setActionCommand(START); } } catch (ConnectionException e1) { e1.printStackTrace(); } } }); final JComboBox combo = new JComboBox(); if (connection instanceof UsbConnection) { Collection<String> portNames = UsbConnection.listAvailablePortNames(); for (String name : portNames) { combo.addItem(name); } } combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object selectedItem = combo.getSelectedItem(); } }); this.add(new ChartPanel(chart), BorderLayout.CENTER); JPanel btnPanel = new JPanel(new FlowLayout()); btnPanel.add(run); btnPanel.add(combo); this.add(btnPanel, BorderLayout.SOUTH); }
From source file:it.imtech.configuration.ChooseServer.java
/** * Aggiorna tutte i labels//from w w w . j a v a 2s . c o m */ private void updateLanguage() { bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); label_server_1.setText("<html>" + Utility.getBundleString("server_1", bundle) + "</html>"); label_server_2.setText("<html>" + Utility.getBundleString("server_2", bundle) + "</html>"); if (Globals.ONLINE) { label_server_3.setText("<html>" + Utility.getBundleString("server_3", bundle) + "</html>"); } else { label_server_3 .setText("<html>" + Utility.getBundleString("server_offline", bundle) + "<br/><br/></html>"); } label_server_4.setText("<html>" + Utility.getBundleString("server_4", bundle) + "</html>"); JButton nextButton = (JButton) StartWizard.footerPanel.getComponentByName("next_button"); JButton prevButton = (JButton) StartWizard.footerPanel.getComponentByName("prev_button"); nextButton.setText(Utility.getBundleString("next", bundle)); prevButton.setText(Utility.getBundleString("back", bundle)); }