Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Inside a JFrame class, I start one Thread. That thread checks something and return a boolean as true or false. Inside the JFrame class I want to check that boolean, and do actions according to the results of the thread.
Now my question is how can I make my JFrame to wait untill the Thread ends?
How to make a program to sleep until my Thread ends ? I dont wanna to use Thread.join(). Is it possible?
I am interacting with the user in another window.
Make the second window a modal dialog such as either a JOptionPane or a modal JDialog. Either one will freeze the calling window until the dialog window is no longer visible. Please check out this question for more on this, as well as these questions for a lot more on this.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
When i start the Jframe "VentanaPrincipal" this one looks like this:
but when I open the Jframe from another Jframe, it changes the format of the components:
My code is:
VentanaPrincipal vp = new VentanaPrincipal();
vp.setVisible(true);
Can you please help me?
The Look and Feel (LAF) is changing.
Swing components use the LAF at the time the component is created.
It would seem that one frame uses a different LAF so the second frame inherits that LAF when it is created.
Fix your code to use the same LAF.
Read the section from the Swing tutorial on Modifying the Look and Feel for more information.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I started creating an automation framework for my current company. now I’m having a problem with a form that has a JS modal appearing top part of the form attaches to it. that JS form comes every time if I change the default value of the form (Changes Detected: save button, dismissed button). the issue is there is a drop-down box and the default value is set to empty. after I change that to a value (eg: house) that JS modal comes that I have made a change to the form and put the value of the drop-down box to that default empty value. this happens in the run time. if I put a thread.sleep for 3 seconds that solves the issue. but I need a more reliable solution. are there any other options that I can use for this issue?
All I can think of now is to call that first function, Wait for success
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.javaScriptThrowsNoExceptions("putValue()"));
May be a little bit
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to use a JSlider to display my data, and as such I don't want users to be able to move them as then it would no longer display the correct value. At the moment I'm disabling the JSlider so the user can't move the slider, but doing that makes the visibility of the slider really poor.
I would recommend against showing an enabled, but inspirational slider, as it is against typical UI conventions and will likely confuse the users.
Nonetheless, if you really want to do it: The default JSlider is either enabled or not, so you cannot do what you want directly. A workaround would be to have it enabled and add an ActionListener to it. This would be called once the user changes the value. In this ActionListener, you could just reset the value of the slider to its original value, so the slider would snap back. Again, this is very atypical behaviour of UI elements and might confuse users.
In the end, I would suggest coming up with your own component that displays a bar or other slider-like element to visualize your values, but which do not accept any user input.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
Cheers, lads.
I am currently standing in front of a minor problem, but it really drives me insane, that I'm not able to fix it.
My very first mistake was to use my main-JFrame as main-class, as well.
You will see why this is (as far as I am able to judge) a problem later...
Now I am opening a new JFrame from my main-class-main-JFrame and I want to disable it as long as the new JFrame is opened.
I've already read much about using JDialog to do this, but I did not yet managed to find a solution without having to redesign my whole sub-JFrame.
Is there an easy way to just disable the mainJFrame as long as the subJFrame is opened?
Something like:
JFrame subframe = new GUI_subJFrame(<params>);
this.disable();
subframe.onClose(this.enable());
I know this is awful and not existent source code, but I wanted to make my thought clear, accurately.
I just changed the "subJFrame" from JFrame to JDialog and added the following line to the constructor:
this.setModalityType(DEFAULT_MODALITY_TYPE);
It works fine and is not as complicated as it seemed at first glance.
Thanks to everyone for their help.
Use frame.dispose(); to close the frame
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have created a GUI window is being called in the main method of another class. The window has a run button. The control should return to the main method only afterthe run button has been clicked. How do i get this functionality? Should i use threads?
What you're describing is the classic behavior of a modal dialog such as a JOptionPane: program flow from the calling code pauses while the modal dialog is displayed and then returns at the calling spot when the modal dialog is no longer visible.
I suggest that you look into using a JOptionPane since this is usually the simplest way to get this behavior. Please understand that JOptionPanes can display complex GUI's since the second parameter of its showXXX(...) method is of Object type and can be a JPanel that is laden with other JPanels, components, and goodies.
For example, please look at the code from the answer to this question: How can I make a JFrame modal like a JOptionPane?
Edit
You state in comment:
can i make a JOptionPane from a JFrame? i made a JFrame with three file choosers and 3 text fields and a run button.can i make a JOptionPane from this JFrame direclty?
#Alvin: now you're learning why you should not be gearing your code towards creating JFrames -- you end up painting yourself in a corner. I suggest that you re-do that little bit of code and instead create a JPanel. Then you can put it into a JOptionPane, a JDialog, or JFrame or whatever the need dictates.