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:Main.java
public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); b.setText(""); source.setText("Drag and drop me to the following JButton"); }
From source file:com.github.kennycyb.uifactory.core.factory.impl.components.swing.JButtonFactory.java
@Override public void initialize(final ComponentContext context) { super.initialize(context); final JButton component = (JButton) context.getComponent(); if (component.getText() == null || component.getText().length() == 0) { component.setText(StringUtils.capitalize(context.getId())); }/*from w w w . j ava2s . c o m*/ }
From source file:com.haulmont.cuba.desktop.sys.WindowBreadCrumbs.java
public void update() { removeAll();/*from w w w .j av a2 s.c om*/ btn2win.clear(); for (Iterator<Window> it = windows.iterator(); it.hasNext();) { Window window = it.next(); JButton button = new JXHyperlink(); button.setFocusable(false); button.setText(StringUtils.trimToEmpty(window.getCaption())); button.addActionListener(new ValidationAwareActionListener() { @Override public void actionPerformedAfterValidation(ActionEvent e) { JButton btn = (JButton) e.getSource(); Window win = btn2win.get(btn); if (win != null) { fireListeners(win); } } }); btn2win.put(button, window); if (it.hasNext()) { add(button); JLabel separatorLab = new JLabel(">"); add(separatorLab); } else { add(new JLabel(window.getCaption())); } } }
From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java
private JButton getDefaultButton(String text, ActionListener al) { JButton button = new JButton(); button.setText(text); button.addActionListener(al);//w ww . ja va 2 s . c om return button; }
From source file:lockers.FrameCobro.java
private void getAvailableLockers() { JSONArray array = Utils.getJSONArrayFromURL("http://127.0.0.1:8000/Lockers_Search/?status=0&format=json"); System.out.println(array.size()); if (array.size() == 0) { this.jLblAvailableLockers.setText("No hay disponibilidad"); } else {//from ww w .j a va2 s . c om this.jLblAvailableLockers.setText("La cantidad de lockers disponibles es :" + array.size()); for (Object array1 : array) { JButton nuevo = new JButton(); JSONObject obj2 = (JSONObject) array1; nuevo.setText(obj2.get("locker_name").toString()); nuevo.setVisible(true); this.jPanel2.add(nuevo); } } }
From source file:jcine.CineForm.java
private void buildHall(Asiento[] asientos) { //Encontraremos las dimensiones de sala Integer maxX = 0;/* www. jav a 2 s .c om*/ Integer maxY = 0; for (int i = 0; i < asientos.length; i++) { if (asientos[i].getPosX() > maxX) { maxX = asientos[i].getPosX(); } if (asientos[i].getPosY() > maxY) { maxY = asientos[i].getPosY(); } } //los tamaos de sillas Integer sizeX = pHall.getWidth() / maxX; Integer sizeY = pHall.getHeight() / maxY; Boolean[][] matrix = new Boolean[maxX][maxY]; //sillas for (int i = 0; i < asientos.length; i++) { JButton btn = new JButton("btn_" + Integer.toString(i)); btn.setText(asientos[i].getName()); btn.setLocation(sizeX * (asientos[i].getPosX() - 1), sizeY * (asientos[i].getPosY() - 1)); btn.setSize(sizeX - SPACER, sizeY - SPACER); btn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chairPressed(evt); } }); matrix[asientos[i].getPosX() - 1][asientos[i].getPosY() - 1] = true; pHall.add(btn); } //pasillos for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { if (matrix[x][y] == null) { JPanel panel = new JPanel(); panel.setBackground(Color.cyan); panel.setLocation(x * sizeX - SPACER, y * sizeY - SPACER); panel.setSize(sizeX + 2 * SPACER, sizeY + 2 * SPACER); pHall.add(panel); } } } pHall.repaint(); }
From source file:lockers.FrameCobro.java
private void getRates() { JSONArray array = Utils.getJSONArrayFromURL("http://127.0.0.1:8000/Rates/?format=json"); if (array.size() == 0) { this.jLblAvailableLockers.setText("No hay disponibilidad"); } else {/*from w w w.j av a 2 s . c o m*/ for (Object array1 : array) { JButton nuevo = new JButton(); JSONObject obj2 = (JSONObject) array1; System.out.println(obj2.size()); nuevo.setText(obj2.get("rate_name") + ": " + obj2.get("rate_rate")); nuevo.setVisible(true); nuevo.setSize(200, 50); nuevo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source instanceof JButton) { JButton btn = (JButton) source; System.out.println("You clicked the button " + btn.getText()); } } }); this.jPanel1.add(nuevo); } } }
From source file:net.nosleep.superanalyzer.panels.HomePanel.java
public JPanel createRightButtonBarPanel(final PieRotator rotator) { URL url = this.getClass().getResource("/media/" + "ButtonPlay.png"); final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)); url = this.getClass().getResource("/media/" + "ButtonPause.png"); final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)); final JButton button = new JButton(playIcon); button.setBorder(null);//from w ww . j a v a2 s . co m button.setBorderPainted(false); button.setText(null); button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { if (rotator.isRunning() == false) { rotator.start(); button.setIcon(pauseIcon); } else { rotator.stop(); button.setIcon(playIcon); } } }); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setBackground(Color.white); toolBar.add(button); JPanel barPanel = new JPanel(new BorderLayout()); barPanel.setBackground(Color.white); barPanel.add(toolBar, BorderLayout.SOUTH); return barPanel; }
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
private void onStartDiscoveryPost(JButton stopStartButton) { stopStartButton.setText("Stop"); pauseResumeButton.setEnabled(true);// w w w . j a v a2 s . c o m stopStartButton.setEnabled(true); }
From source file:Cal.java
/** Compute which days to put where, in the Cal panel */ protected void recompute() { // System.out.println("Cal::recompute: " + yy + ":" + mm + ":" + dd); if (mm < 0 || mm > 11) throw new IllegalArgumentException("Month " + mm + " bad, must be 0-11"); clearDayActive();//from w w w . ja v a 2 s. com calendar = new GregorianCalendar(yy, mm, dd); // Compute how much to leave before the first. // getDay() returns 0 for Sunday, which is just right. leadGap = new GregorianCalendar(yy, mm, 1).get(Calendar.DAY_OF_WEEK) - 1; // System.out.println("leadGap = " + leadGap); int daysInMonth = dom[mm]; if (isLeap(calendar.get(Calendar.YEAR)) && mm == 1) // if (isLeap(calendar.get(Calendar.YEAR)) && mm > 1) ++daysInMonth; // Blank out the labels before 1st day of month for (int i = 0; i < leadGap; i++) { labs[0][i].setText(""); } // Fill in numbers for the day of month. for (int i = 1; i <= daysInMonth; i++) { JButton b = labs[(leadGap + i - 1) / 7][(leadGap + i - 1) % 7]; b.setText(Integer.toString(i)); } // 7 days/week * up to 6 rows for (int i = leadGap + 1 + daysInMonth; i < 6 * 7; i++) { labs[(i) / 7][(i) % 7].setText(""); } // Shade current day, only if current month if (thisYear == yy && mm == thisMonth) setDayActive(dd); // shade the box for today // Say we need to be drawn on the screen repaint(); }