List of usage examples for javax.swing JButton setVisible
@BeanProperty(hidden = true, visualUpdate = true) public void setVisible(boolean aFlag)
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); ComponentListener comp = new ComponentListener() { public void componentHidden(ComponentEvent e) { dump("Hidden", e); }//from ww w.j a v a 2 s.c o m public void componentMoved(ComponentEvent e) { dump("Moved", e); } public void componentResized(ComponentEvent e) { dump("Resized", e); } public void componentShown(ComponentEvent e) { dump("Shown", e); } private void dump(String type, ComponentEvent e) { System.out.println(e.getComponent().getName() + " : " + type); } }; JButton left = new JButton("Left"); left.setName("Left"); left.addComponentListener(comp); final JButton right = new JButton("Right"); right.setName("Right"); right.addComponentListener(comp); ActionListener action = new ActionListener() { public void actionPerformed(ActionEvent e) { right.setVisible(!right.isVisible()); } }; left.addActionListener(action); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:Main.java
@Override public void updateUI() { super.updateUI(); UIManager.put("ComboBox.squareButton", Boolean.FALSE); setUI(new BasicComboBoxUI() { @Override/*from w w w .ja v a 2 s. c o m*/ protected JButton createArrowButton() { JButton b = new JButton(); b.setBorder(BorderFactory.createEmptyBorder()); b.setVisible(false); return b; } }); setBorder(BorderFactory.createLineBorder(Color.GRAY)); }
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 {// w w w . j a va2s . c o m 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:Main.java
public Main() { super(BoxLayout.Y_AXIS); Box info = Box.createVerticalBox(); info.add(new Label("Please wait 3 seconds")); final JButton continueButton = new JButton("Continue"); info.add(continueButton);// w w w . j a va 2s .c o m JDialog d = new JDialog(); d.setModalityType(ModalityType.APPLICATION_MODAL); d.setContentPane(info); d.pack(); continueButton.addActionListener(e -> d.dispose()); continueButton.setVisible(false); SwingWorker sw = new SwingWorker<Integer, Integer>() { protected Integer doInBackground() throws Exception { int i = 0; while (i++ < 30) { System.out.println(i); Thread.sleep(100); } return null; } @Override protected void done() { continueButton.setVisible(true); } }; JButton button = new JButton("Click Me"); button.addActionListener(e -> { sw.execute(); d.setVisible(true); }); add(button); }
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 {// w w w . j a v a 2 s . co 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:edu.ku.brc.specify.prefs.AttachmentPrefs.java
/** * //from w ww . j a v a 2s . c o m */ public AttachmentPrefs() { super(); createForm("Preferences", "Attachments"); PanelViewable pathPanel = form.getCompById("path_panel"); PanelViewable urlPanel = form.getCompById("url_panel"); isPublicDefChk = form.getCompById(ATTCH_PUB_DEF); pathBrwse = form.getCompById(ATTCH_PATH_ID); pathLbl = form.getLabelFor(ATTCH_PATH_ID); urlTxt = form.getCompById(ATTCH_URL_ID); urlLbl = form.getLabelFor(ATTCH_URL_ID); keyTxt = form.getCompById(ATTCH_KEY_ID); keyLbl = form.getLabelFor(ATTCH_KEY_ID); isInitialized = pathPanel != null && urlPanel != null && pathBrwse != null && pathLbl != null && urlTxt != null && urlLbl != null; if (!isInitialized) { UIRegistry.showError("The form is not setup correctly."); return; } isUsingGlobalAttchPrefs = globalPrefs.getBoolean(USE_GLOBAL_PREFS, false); canEditGlobalAttchPrefs = localPrefs.getBoolean(EDT_GLOBAL_PREFS, false); UIRegistry.loadAndPushResourceBundle("preferences"); pathRB = UIHelper.createRadioButton(UIRegistry.getResourceString("USE_ATTACH_PATH")); urlRB = UIHelper.createRadioButton(UIRegistry.getResourceString("USE_ATTACH_URL")); UIRegistry.popResourceBundle(); pathRB.setOpaque(false); urlRB.setOpaque(false); ButtonGroup group = new ButtonGroup(); group.add(pathRB); group.add(urlRB); CellConstraints cc = new CellConstraints(); if (pathPanel != null) pathPanel.add(pathRB, cc.xy(1, 1)); if (urlPanel != null) urlPanel.add(urlRB, cc.xy(1, 1)); JButton saveGGblPrefs = form.getCompById("SaveGGblPrefs"); JButton clearGGblPrefs = form.getCompById("ClearGGblPrefs"); if (saveGGblPrefs != null) { saveGGblPrefs.setVisible(isUsingGlobalAttchPrefs && canEditGlobalAttchPrefs); saveGGblPrefs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { oldAttachmentURL = (String) urlTxt.getText().trim(); oldAttachmentKey = (String) keyTxt.getText().trim(); globalPrefs.put(ATTACHMENT_PATH, oldAttachmentPath); globalPrefs.put(ATTACHMENT_URL, oldAttachmentURL); globalPrefs.put(ATTACHMENT_KEY, oldAttachmentKey); globalPrefs.putBoolean(ATTACHMENT_USE_PATH, pathRB.isSelected()); // Make sure local prefs is set for the type we are using. localPrefs.putBoolean(ATTACHMENT_USE_PATH, pathRB.isSelected()); //remotePrefs.putBoolean(ATTCH_PUB_DEF, isPublicDefChk.isSelected()); } }); } if (clearGGblPrefs != null) { clearGGblPrefs.setVisible(isUsingGlobalAttchPrefs && canEditGlobalAttchPrefs); clearGGblPrefs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { globalPrefs.remove(ATTACHMENT_PATH); globalPrefs.remove(ATTACHMENT_URL); globalPrefs.remove(ATTACHMENT_KEY); globalPrefs.remove(ATTACHMENT_USE_PATH); try { globalPrefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } }); } if (!isUsingGlobalAttchPrefs || canEditGlobalAttchPrefs) { ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAttachmentsEnabledState(pathRB.isSelected()); } }; pathRB.addActionListener(al); urlRB.addActionListener(al); } else { pathBrwse.setEnabled(false); urlTxt.setEnabled(false); keyTxt.setEnabled(false); pathRB.setEnabled(false); urlRB.setEnabled(false); } setDataIntoUI(); }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
protected void createNotValid() { GridBagConstraints c = new GridBagConstraints(); URI licenseURI = LICENSE.getLicenseURI(); JComponent comp;//from w w w .j a v a2s . c o m comp = new JLabel(getWarningIcon()); c.anchor = GridBagConstraints.NORTH; c.insets = new Insets(0, 0, 0, 5); DETAILS.add(comp, c); String invalidText = getInvalidString(); if (licenseURI != null && allowRetryLink()) invalidText += " " + getRetryString(); comp = newTextArea(invalidText); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.insets = new Insets(7, 0, 0, 0); DETAILS.add(comp, c); c.gridwidth = 1; c.gridheight = 2; c.weightx = 0; c.weighty = 0; DETAILS.add(javax.swing.Box.createGlue(), c); JButton button = new JButton(getVerifyString()); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { LICENSE.verify(LicenseWindow.this); buildDetails(); } }); button.setVisible(licenseURI != null && allowVerifyLookup()); c.gridwidth = GridBagConstraints.RELATIVE; c.gridheight = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 0, 100); DETAILS.add(button, c); if (LICENSE.getLicenseDeed(URN) == null || !allowClaimedDeedLink()) { comp = new JLabel(); comp.setVisible(false); } else { comp = new URLLabel(LICENSE.getLicenseDeed(URN), getClaimedDeedString()); } c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 0; c.insets = new Insets(0, 0, 3, 0); DETAILS.add(comp, c); if (licenseURI == null || !allowVerificationLink()) { comp = new JLabel(); comp.setVisible(false); } else { comp = new URLLabel(licenseURI, getVerificationString()); } c.insets = new Insets(0, 0, 3, 0); DETAILS.add(comp, c); }
From source file:com.haulmont.cuba.desktop.sys.JXErrorPaneExt.java
public JXErrorPaneExt() { Configuration configuration = AppBeans.get(Configuration.NAME); ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); Messages messages = AppBeans.get(Messages.NAME); Locale locale = App.getInstance().getLocale(); UIManager.put("JXErrorPane.details_expand_text", messages.getMainMessage("JXErrorPane.details_expand_text", locale)); UIManager.put("JXErrorPane.details_contract_text", messages.getMainMessage("JXErrorPane.details_contract_text", locale)); UIManager.put("JXErrorPane.ok_button_text", messages.getMainMessage("JXErrorPane.ok_button_text", locale)); UIManager.put("JXErrorPane.fatal_button_text", messages.getMainMessage("JXErrorPane.fatal_button_text", locale)); UIManager.put("JXErrorPane.report_button_text", messages.getMainMessage("JXErrorPane.report_button_text", locale)); UIManager.put("JXErrorPane.copy_to_clipboard_button_text", messages.getMainMessage("JXErrorPane.copy_to_clipboard_button_text", locale)); ErrorPaneUIExt ui = new ErrorPaneUIExt(); setUI(ui);// ww w . ja v a 2 s . c om JButton copyButton = ui.getCopyToClipboardButton(); copyToClipboardListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TopLevelFrame mainFrame = App.getInstance().getMainFrame(); mainFrame.showNotification(messages.getMainMessage("errorPane.copingSuccessful", locale), Frame.NotificationType.TRAY); } }; copyButton.addActionListener(copyToClipboardListener); UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME); Security security = AppBeans.get(Security.NAME); if (userSessionSource == null || !security.isSpecificPermitted("cuba.gui.showExceptionDetails")) { copyButton.setVisible(false); } String supportEmail = null; if (App.getInstance().getConnection().isConnected()) { supportEmail = clientConfig.getSupportEmail(); } if (StringUtils.isNotBlank(supportEmail)) { setErrorReporter(new ErrorReporter() { @Override public void reportError(ErrorInfo info) throws NullPointerException { sendSupportEmail(info); ((ErrorPaneUIExt) getUI()).setEnabled(false); } }); } }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void addRestoreButton() { JButton restoreButton = getRestoreButton(); restoreAction.setDialog(this); restoreAction.setTexts(texts);/*from www .j av a 2 s . com*/ restoreButton.setVisible(true); restoreButton.setAction(restoreAction); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void addApproveButton() { JButton approveButton = getApproveButton(); approveAction.setDialog(this); approveAction.setTexts(texts);/*from ww w . j a v a 2 s . c o m*/ approveButton.setVisible(true); approveButton.setAction(approveAction); }