From: jason on
hello,
i have question regarding adding an additional GUI to an existing GUI.

i have the following placed inside of the action listener of a
button:

i am trying to implement the following but all i am getting is a
second blank popup window (no progress bar).

this UI is popped up after i click a "go!" button. the
meat of the analysis code executes.

once this starts i would like to watch my progress bar do what it is
made to do. you know. progress!
[code]

public void actionPerformed(ActionEvent arg0) {

JFrame1.setSize(270, 250);
JFrame1.setLocation(200, 200);
JFrame1.setResizable(false);
Insets insets = JFrame1.getInsets();
JFrame1.setLayout(null);
JProgressBar JProgressBar1=new JProgressBar(0,100);
JProgressBar1.setValue(50);
JProgressBar1.setStringPainted(true);
Dimension size=JProgressBar1.getPreferredSize();

JProgressBar1.setBounds(insets.left,insets.top,size.width,size.height);
JFrame1.add(JProgressBar1);
JFrame1.setVisible(true); //i can see this. and all
the applied choices are true. i cannot resize and it appears where it
should at the correct size. but lo and behold, not progressbar.

for (int i=0;i<=Out.size()-1;i++){

JProgressBar1.setValue(i);
//other operations..
}
System.exit(0);
From: markspace on
jason wrote:

> for (int i=0;i<=Out.size()-1;i++){
>
> JProgressBar1.setValue(i);
> //other operations..
> }


I didn't read carefully, but almost certainly this is being done on the
EDT. Which means the EDT can't run to update the progress bar display.
Therefore, you don't see any updates.


Try looking at one of the examples on this page:

<http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html>

From: jason on
On May 13, 10:14 pm, markspace <nos...(a)nowhere.com> wrote:
> jason wrote:
> >          for (int i=0;i<=Out.size()-1;i++){
>
> >                 JProgressBar1.setValue(i);
> > //other operations..
> >            }
>
> I didn't read carefully, but almost certainly this is being done on the
> EDT.  Which means the EDT can't run to update the progress bar display.
>   Therefore, you don't see any updates.
>
> Try looking at one of the examples on this page:
>
> <http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html>

Yes, I seem to be having an issue of associating the two GUI's.

IE: code will look from 1-100 a multiple of times (usually 3-4).
GUI-1: takes input values which cause variations in the complexity of
calculations and the "invoke" or "start" command.
GUI-2: this GUI i want to show the progress of my code underlying GUI
1.

I have looked more closely at the page you referenced and my main
question is the following:
how would i go about creating a GUI that accepts input values? i
envision this second GUI as some sort of function operating in the
following:
[code]
//coming from GUI-1 class:

public void actionPerformed(ActionEvent arg0) {

for (int i=0;i<=someMaxSize;i++){

MyGUI2class.main(i);

}//close for

}//close action performed

//in my GUI2 class
public static void main(int arg0){


if (!MyGUI2==null){ //i am coding this in this window, please take
this as pseudo and not executable.
//create GUI up here etc.
MyGUI2.setVisible(true);
}else{
progressBar.setValue(arg0);
}//close if

}//close main

[/code]

this demonstrates the basic idea of what i am trying to accomplish. i
am sure it is nothing new to a lot of you.

any assistance in overcoming this obstacle would be appreciated!
From: Lew on
jason wrote:
> I have looked more closely at the page you referenced and my main
> question is the following:
> how would i [sic] go about creating a GUI that accepts input values? i [sic]
> envision this second GUI as some sort of function operating in the
> following:
> [code]
> //coming from GUI-1 class:
>
> public void actionPerformed(ActionEvent arg0) {
>
> for (int i=0;i<=someMaxSize;i++){
>
> MyGUI2class.main(i);

You definitely will not want to start a new instance of your second "GUI"
every time you update a progress bar!

You aren't talking about two GUIs. GUI means "graphical user interface". You
have one of those.

The 'actionPerformed()' method should simply update the value used by the
progress bar. This will take negligible time and thus not tie up the EDT.

--
Lew
From: jason on
On May 14, 9:51 am, Lew <no...(a)lewscanon.com> wrote:
> jason wrote:
> > I have looked more closely at the page you referenced and my main
> > question is the following:
> > how would i [sic] go about creating a GUI that accepts input values? i [sic]
> > envision this second GUI as some sort of function operating in the
> > following:
> > [code]
> > //coming from GUI-1 class:
>
> > public void actionPerformed(ActionEvent arg0) {
>
> > for (int i=0;i<=someMaxSize;i++){
>
> >      MyGUI2class.main(i);
>
> You definitely will not want to start a new instance of your second "GUI"
> every time you update a progress bar!
>
> You aren't talking about two GUIs.  GUI means "graphical user interface".  You
> have one of those.
>
> The 'actionPerformed()' method should simply update the value used by the
> progress bar.  This will take negligible time and thus not tie up the EDT.
>
> --
> Lew

i know what a gui is, i have programmed many in different languages
but am having a hard time updating this progressbar.

currently i have a progressbar in my main gui set to 50 (just so that
i can see it is registering, which it is). once i click my action
button the gui animation ceases and the gui becomes a static image of
itself (progress bar looks like an image of itself as of when i
clicked the action button). also, the value on the progressbar seems
unable to be changed.