Search Results

Search found 4 results on 1 pages for 'progressmonitor'.

Page 1/1 | 1 

  • Delay in displaying contents in JDialog

    - by Yohan
    Please have a look at the following code import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.List; import java.util.ArrayList; public class SendEmailForm extends JDialog { private JLabel to, cc, bcc, subject, account; private JTextField toTxt, ccTxt, bccTxt, subjectTxt; private JTextArea messageTxt; private JButton send; private JComboBox accountBox; private JScrollPane scroll; private GridBagLayout gbl; private GridBagConstraints gbc; public SendEmailForm() { //Declaring instance variables to = new JLabel("To: "); cc = new JLabel("CC: "); bcc = new JLabel("BCC: "); subject = new JLabel("Subject: "); account = new JLabel("Select an Account: "); toTxt = new JTextField(20); ccTxt = new JTextField(20); bccTxt = new JTextField(20); subjectTxt = new JTextField(20); messageTxt = new JTextArea(20, 50); messageTxt.setLineWrap(true); scroll = new JScrollPane(messageTxt); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); accountBox = new JComboBox(); accountBox.addItem("Yahoo"); accountBox.addItem("GMail"); accountBox.addItem("MSN"); //accountBox.addItem("Yahoo"); //accountBox.addItem("Yahoo"); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); send = new JButton("Send"); send.addActionListener(new SendButtonAction()); buttonPanel.add(send); //Creating thr GUI //GUI CREATION IS REMOVED IN THIS POST this.setTitle("Send Emails"); this.setVisible(true); this.pack(); this.setLocationRelativeTo(null); this.validate(); } private class SendButtonAction implements ActionListener { public void actionPerformed(ActionEvent ae) { ProgressMonitor pm = new ProgressMonitor(); //Retreiving the user name and password List userData = new ArrayList(); EmailDBConnector emailCon = new EmailDBHandler(); userData = emailCon.getUserNameAndPassword( accountBox.getSelectedItem().toString().trim()); String userName = userData.get(0).toString(); String password = userData.get(1).toString(); System.out.println(userName); System.out.println(password); pm.setVisible(true); SendEmail sendEmail = new SendEmail(toTxt.getText(), userName.trim(), bccTxt.getText(), ccTxt.getText(), accountBox.getSelectedItem().toString().trim(), messageTxt.getText().trim(), password.trim(), subjectTxt.getText()); String result = sendEmail.send(); //pm.dispose(); JOptionPane.showMessageDialog(null, result); } } private class ProgressMonitor extends JDialog { public ProgressMonitor() { this.setLayout(new BorderLayout()); JLabel text = new JLabel("Sending..Please wait..."); this.add(text, "Center"); this.pack(); this.validate(); this.setLocationRelativeTo(null); } } } First, this is an email program. In here, when the JDialog is called, it just opens as a 100% blank window. I have added a JLabel, but it is not there when it is displaying. Anyway, it takes sometime to send the email, after the email is sent, I can see the JLabel in the JDialog. If I take my issue into one sentence, I am calling the JDialog before the email is sent, but it appears blank, after the email is sent, it's content are there! Why is this? Please help!

    Read the article

  • eclise java internal webbrowser progress listener?

    - by deepthinker121
    Hi All, I need to open an internal web browser from a custom eclipse wizard I have created - and so I am using IWebBrowser webBrowser = browser.createBrowser (IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.STATUS, null,"TestBrowser", "TestBrowser"); URL url = new URL("http://localhost:8080/app"); webBrowser.openURL(url); Now the problem is - the openURL needs time to complete as it tries to load a page for a webapp and as I am not able to get the progress of the 'load page' operation of the URL - my wizard progressmonitor completes before the URL can be completely loaded . Is there any way to get the status of the page load operation - (to check if its complete or it failed) or add a listener to indicate completion of page load? It is okay for me to use some other implementations of internal web browsers - so please suggest some other approach we cannot add a listener to IWebBrowser.. Thanks for ur help !!

    Read the article

  • Progress Bar design patterns?

    - by shoosh
    The application I'm writing performs a length algorithm which usually takes a few minutes to finish. During this time I'd like to show the user a progress bar which indicates how much of the algorithm is done as precisely as possible. The algorithm is divided into several steps, each with its own typical timing. For instance- initialization (500 milli-sec) reading inputs (5 sec) step 1 (30 sec) step 2 (3 minutes) writing outputs (7 sec) shutting down (10 milli-sec) Each step can report its progress quite easily by setting the range its working on, say [0 to 150] and then reporting the value it completed in its main loop. What I currently have set up is a scheme of nested progress monitors which form a sort of implicit tree of progress reporting. All progress monitors inherit from an interface IProgressMonitor: class IProgressMonitor { public: void setRange(int from, int to) = 0; void setValue(int v) = 0; }; The root of the tree is the ProgressMonitor which is connected to the actual GUI interface: class GUIBarProgressMonitor : public IProgressMonitor { GUIBarProgressMonitor(ProgressBarWidget *); }; Any other node in the tree are monitors which take control of a piece of the parent progress: class SubProgressMonitor : public IProgressMonitor { SubProgressMonitor(IProgressMonitor *parent, int parentFrom, int parentLength) ... }; A SubProgressMonitor takes control of the range [parentFrom, parentFrom+parentLength] of its parent. With this scheme I am able to statically divide the top level progress according to the expected relative portion of each step in the global timing. Each step can then be further subdivided into pieces etc' The main disadvantage of this is that the division is static and it gets painful to make changes according to variables which are discovered at run time. So the question: are there any known design patterns for progress monitoring which solve this issue?

    Read the article

1