List of usage examples for javax.swing JProgressBar setIndeterminate
public void setIndeterminate(boolean newValue)
indeterminate
property of the progress bar, which determines whether the progress bar is in determinate or indeterminate mode. From source file:qic.launcher.Main.java
private void startGUI(TakeDown installer) { TextAreaWithBackground textArea = new TextAreaWithBackground(); JButton launchButton = new JButton(" Launch "); launchButton.setEnabled(false);//from w w w. ja v a 2 s. c om JProgressBar progressBar = new JProgressBar(); launchButton.addActionListener(e -> { runAIC(); System.exit(0); }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); southPanel.add(progressBar); southPanel.add(launchButton); JFrame frame = new JFrame("QIC Search Updater"); frame.setIconImage(new ImageIcon(getClass().getResource("/q.png")).getImage()); frame.setLayout(new BorderLayout(5, 5)); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.getContentPane().add(southPanel, BorderLayout.SOUTH); frame.setSize(495, 445); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); textArea.setText("Loading path notes..."); String imgUrl = "http://poeqic.github.io/launcher/images/background.png"; try { Image image = ImageIO.read(new URL(imgUrl)); if (image != null) textArea.setBackgroundImage(image); } catch (IOException ex) { logger.error("Error while loading background image from: " + imgUrl, ex); } Worker<String> pathNotesWorker = new Worker<String>(() -> URLConnectionReader.getText(CHANGELOG_URL), s -> textArea.setText(s), e -> showErrorAndQuit(e)); pathNotesWorker.execute(); Worker<Boolean> updaterWorker = new Worker<Boolean>(() -> { progressBar.setIndeterminate(true); return installer.installOrUpdate(); }, b -> { progressBar.setIndeterminate(false); launchButton.setEnabled(true); }, e -> showErrorAndQuit(e)); updaterWorker.execute(); }
From source file:ui.frame.UILogin.java
public UILogin() { super("Login"); Label l = new Label(); setLayout(new BorderLayout()); this.setPreferredSize(new Dimension(400, 300)); Panel p = new Panel(); loginPanel = p.createPanel(Layouts.grid, 4, 2); loginPanel.setBorder(new EmptyBorder(25, 25, 0, 25)); lblUser = l.createLabel("Username:"); lblPassword = l.createLabel("Password:"); lblURL = l.createLabel("Server URL"); lblBucket = l.createLabel("Bucket"); tfURL = new JTextField(); tfURL.setText("kaiup.kaisquare.com"); tfBucket = new JTextField(); PromptSupport.setPrompt("BucketName", tfBucket); tfUser = new JTextField(); PromptSupport.setPrompt("Username", tfUser); pfPassword = new JPasswordField(); PromptSupport.setPrompt("Password", pfPassword); buttonPanel = p.createPanel(Layouts.flow); buttonPanel.setBorder(new EmptyBorder(0, 0, 25, 0)); Button b = new Button(); JButton btnLogin = b.createButton("Login"); JButton btnExit = b.createButton("Exit"); btnLogin.setPreferredSize(new Dimension(150, 50)); btnExit.setPreferredSize(new Dimension(150, 50)); Component[] arrayBtn = { btnExit, btnLogin }; p.addComponentsToPanel(buttonPanel, arrayBtn); Component[] arrayComponents = { lblURL, tfURL, lblBucket, tfBucket, lblUser, tfUser, lblPassword, pfPassword };// w ww . j av a 2 s. co m p.addComponentsToPanel(loginPanel, arrayComponents); add(loginPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); btnLogin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { if (tfUser.getText().equals("") || String.valueOf(pfPassword.getPassword()).equals("") || tfBucket.getText().equals("")) { JOptionPane.showMessageDialog(Data.mainFrame, "Please fill up all the fields", "Error", JOptionPane.ERROR_MESSAGE); } else { String username = tfUser.getText(); String password = String.valueOf(pfPassword.getPassword()); Data.URL = Data.protocol + tfURL.getText(); Data.targetURL = Data.protocol + tfURL.getText() + "/api/" + tfBucket.getText() + "/"; String response = api.loginBucket(Data.targetURL, username, password); try { if (DesktopAppMain.checkResult(response)) { JSONObject responseJSON = new JSONObject(response); Data.sessionKey = responseJSON.get("session-key").toString(); response = api.getUserFeatures(Data.targetURL, Data.sessionKey); if (checkFeatures(response)) { Data.mainFrame = new KAIQRFrame(); Data.mainFrame.uiInventorySelect = new UIInventorySelect(); Data.mainFrame.addPanel(Data.mainFrame.uiInventorySelect, "inventory"); Data.mainFrame.showPanel("inventory"); Data.mainFrame.pack(); setVisible(false); Data.mainFrame.setVisible(true); } else { JOptionPane.showMessageDialog(Data.loginFrame, "User does not have necessary features", "Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(Data.loginFrame, "Wrong username/password", "Error", JOptionPane.ERROR_MESSAGE); } } catch (JSONException e1) { e1.printStackTrace(); } } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Login", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Logging in .........."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); }
From source file:ui.panel.UIAccessKeySelect.java
public void runaccessKeySelect() { getAccessKeyData();/*from w ww. ja va 2 s. co m*/ Panel p = new Panel(); Button b = new Button(); Label l = new Label(); setLayout(new BorderLayout()); JPanel pnlInstruction = p.createPanel(Layouts.flow); JLabel lblInstruction = l.createLabel("Access Keys"); pnlInstruction.setBackground(CustomColor.LightBlue.returnColor()); lblInstruction.setForeground(Color.white); lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18)); pnlInstruction.add(lblInstruction); JPanel pnlBucketList = p.createPanel(Layouts.border); listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollBucket = new JScrollPane(listBucket); Component[] BucketListComponents = { scrollBucket }; pnlBucketList.add(scrollBucket, BorderLayout.CENTER); JPanel pnlButtons = p.createPanel(Layouts.flow); JButton btnBack = b.createButton("Back"); JButton btnSelectElements = b.createButton("Next"); JButton btnAdd = b.createButton("Generate Access Key"); JButton btnRefresh = b.createButton("Refresh"); pnlButtons.add(btnBack); pnlButtons.add(btnAdd); pnlButtons.add(btnRefresh); pnlButtons.add(btnSelectElements); add(pnlInstruction, BorderLayout.NORTH); add(pnlBucketList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("license"); } }); btnRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getAccessKeyData(); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.uiGenerateKey = new UIGenerateKey(); Data.mainFrame.addPanel(Data.mainFrame.uiGenerateKey, "generateKey"); Data.mainFrame.pack(); Data.mainFrame.showPanel("generateKey"); } }); btnSelectElements.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int selected = listBucket.getSelectedRow(); if (selected != -1) { Data.accessKey = (String) listBucket.getModel().getValueAt(selected, 0); Data.mainFrame.qrGenerator = new JavaQR(); Data.mainFrame.pack(); Data.mainFrame.addPanel(Data.mainFrame.qrGenerator, "generateQR"); Data.mainFrame.showPanel("generateQR"); } else { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select Access Key", "Error", JOptionPane.ERROR_MESSAGE); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Generating QR Code......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); }
From source file:ui.panel.UIBucketSelect.java
public void runBucketSelect() { Panel p = new Panel(); Button b = new Button(); Label l = new Label(); setLayout(new BorderLayout()); JPanel pnlInstruction = p.createPanel(Layouts.flow); JLabel lblInstruction = l.createLabel("Bucket List"); pnlInstruction.setBackground(CustomColor.LightBlue.returnColor()); lblInstruction.setForeground(Color.white); lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18)); pnlInstruction.add(lblInstruction);// w w w . ja v a 2s. c om JPanel pnlBucketList = p.createPanel(Layouts.border); listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollBucket = new JScrollPane(listBucket); scrollBucket.setPreferredSize(new Dimension(300, 150)); pnlBucketList.add(scrollBucket, BorderLayout.CENTER); JPanel pnlButtons = p.createPanel(Layouts.flow); JButton btnBack = b.createButton("Back"); JButton btnSelectElements = b.createButton("Next"); JButton btnRefresh = b.createButton("Refresh Bucket List"); pnlButtons.add(btnBack); pnlButtons.add(btnRefresh); pnlButtons.add(btnSelectElements); add(pnlInstruction, BorderLayout.NORTH); add(pnlBucketList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); setVisible(true); btnRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getBucketData(); } }); btnSelectElements.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int selected = listBucket.getSelectedRow(); if (selected == -1) { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error", JOptionPane.ERROR_MESSAGE); } else { Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0); Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(), "license"); Data.mainFrame.pack(); Data.mainFrame.showPanel("license"); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Retrieving Licenses......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("inventory"); } }); }
From source file:ui.panel.UILicenseAdd.java
public JPanel createButtonPanel() { JPanel panel = p.createPanel(Layouts.flow); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); btnSubmit = b.createButton("Submit"); btnCancel = b.createButton("Cancel"); btnSubmit.addActionListener(new ActionListener() { @Override/*from www .j a v a2 s. co m*/ public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { TreePath[] path = checkTreeManager.getSelectionModel().getSelectionPaths(); ArrayList<String> featureL = new ArrayList<String>(); String[] features = new String[] {}; for (TreePath tp : path) { if (tp.getLastPathComponent().toString().equals("Features")) { Object rootNode = tree.getModel().getRoot(); int parentCount = tree.getModel().getChildCount(rootNode); for (int i = 0; i < parentCount; i++) { Object parentNode = tree.getModel().getChild(rootNode, i); int childrenCount = tree.getModel().getChildCount(parentNode); for (int x = 0; x < childrenCount; x++) { MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x); featureL.add(node.getValue()); } } } else if (tp.getPathCount() == 2) { Object rootNode = tree.getModel().getRoot(); int parentCount = tree.getModel().getChildCount(rootNode); for (int i = 0; i < parentCount; i++) { Object parentNode = tree.getModel().getChild(rootNode, i); if (parentNode.toString().equals(tp.getLastPathComponent().toString())) { int childrenCount = tree.getModel().getChildCount(parentNode); for (int x = 0; x < childrenCount; x++) { MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x); featureL.add(node.getValue()); } } } } else if (tp.getPathCount() == 3) { MyDataNode node = (MyDataNode) tp.getLastPathComponent(); featureL.add(node.getValue()); } } features = featureL.toArray(features); String duration = spnValidity.getValue().toString(); if (cbPerpetual.isSelected()) { duration = "-1"; } String storage = spnCloud.getValue().toString(); String maxVCA = spnConcurrentVCA.getValue().toString(); String response = apiCall.addNodeLicense(Data.targetURL, Data.sessionKey, Data.bucketID, features, duration, storage, maxVCA); try { JSONObject responseObject = new JSONObject(response); if (responseObject.get("result").equals("ok")) { Data.mainFrame.uiLicenseDetail.getLicenseData(); Data.mainFrame.showPanel("license"); } } catch (JSONException e1) { e1.printStackTrace(); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Retrieving License..."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("license"); } }); panel.add(btnSubmit); panel.add(btnCancel); return panel; }
From source file:ui.panel.UILicenseDetail.java
public JPanel createButtonPanel() { JPanel panel = p.createPanel(Layouts.flow); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); btnSubmit = b.createButton("Next"); btnBack = b.createButton("Back"); btnAdd = b.createButton("Add License"); panel.add(btnBack);//from w w w . j a va2 s .com panel.add(btnAdd); panel.add(btnSubmit); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("bucket"); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd"); Data.mainFrame.showPanel("licenseAdd"); } }); btnSubmit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int row = tblInfo.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a License", "Error", JOptionPane.ERROR_MESSAGE); } else { Data.licenseNumber = (String) tblInfo.getModel().getValueAt(row, 0); Data.mainFrame.uiAccessKeySelect = new UIAccessKeySelect(); Data.mainFrame.addPanel(Data.mainFrame.uiAccessKeySelect, "access"); Data.mainFrame.showPanel("access"); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Retrieving Access Keys"), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("bucket"); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd"); Data.mainFrame.pack(); Data.mainFrame.showPanel("licenseAdd"); } }); return panel; }
From source file:xtrememp.update.SoftwareUpdate.java
public static void showCheckForUpdatesDialog() { checkForUpdatesDialog = new JDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate"), true);/*from w w w. j a v a2 s .com*/ JPanel panel = new JPanel(new BorderLayout(0, 10)); panel.add(new JLabel(tr("Dialog.SoftwareUpdate.CheckingForUpdates")), BorderLayout.CENTER); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setPreferredSize(new Dimension(250, 20)); panel.add(progressBar, BorderLayout.SOUTH); JButton cancelButton = new JButton(tr("Button.Cancel")); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (checkForUpdatesWorker != null && !checkForUpdatesWorker.isDone()) { checkForUpdatesWorker.cancel(true); } checkForUpdatesDialog.dispose(); } }); JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { cancelButton }, cancelButton); checkForUpdatesDialog.setContentPane(optionPane); checkForUpdatesDialog.pack(); checkForUpdatesDialog.setResizable(false); checkForUpdatesDialog.setLocationRelativeTo(checkForUpdatesDialog.getParent()); checkForUpdatesDialog.getRootPane().setDefaultButton(cancelButton); checkForUpdatesDialog.setVisible(true); }