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 7 years ago.
Improve this question
I am trying to change the title of my JFrame when something stops happening how could i achieve this?
I have tried the following:
if(camera.isItDone() == false){
setTitle("Sending...");
}else if(camera.hasFocus() == false){
setTitle("Communication");
}
the 'isItDone' method returns a boolean variable and when false this prints 'sending' on the button click on action listener, however after it being done how can i update this to say communication? because it gets stuck on 'Sending'?
EDIT:
I have also got a Swingworker and then i execute this to run a method in camera, and then check is it done which is a boolean.
Firstly; you don't compare a method that returns a boolean to a boolean. Like Ball.isRed() == false, Ball.isRed() already contains that value.
Secondly; check you if-cases in the debugger. If your are stuck on "Sending..." then:
Either camera.isItDone() is always false, or
camera.hasFocus() is never true.
Your if-else-case is built upon two different booleans that both have to match to fall in the right pigeon hole.
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 3 years ago.
Improve this question
I am working on a Grails app that only consumes a third-party API and uses Firebase as a datastore. Because of this, I don't want to associate my controller methods with any views in the grails-app/views directory. I keep getting a ServletException: could not resolve view in servlet whenever any controller methods gets called back. How should I stop this from happening?
In Groovy if the last statement of the method is implicitly the return statement. Similarly, in Grails, a controller action method will expect a view with the same name as your method name if you do not explicitly render a view.
With that in mind, you can solve this in two ways.
Create an empty view that matches the method name with nothing in it.
Render an empty string as the last statement in your method as such.
class SomeController{
def index(){
// do stuff
render ""
}
}
If you do not wish to render anything, you likely need to render a status at the end of the method. You can do so like this: render(status: 200)
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
I am using four ProgressBars in my AndroidApp.
First of all I want them all to be empty, and when I update a Variable, I want one of the ProgressBars to get filled a bit. But only up to a "goal" that I want to set in beforehand. For example as soon as the Variable hits 1000, the ProgressBar should be filled and a message should pop up or something like that, when the variable is 500, it should be halfway filled and so on.
These are my problems, I think they might all be solved by knowing how to bind a ProgressBar to a variable? If so, please tell me how I can achieve that, else, please tell me how I can still get my plan done. THANK YOU!
You can set the progress bar max value to 1000 and then rather than set the variable to 500, set the progress value to 500.
Here an example of binding the progress bar is:
Can i databind a ProgressBar in Android?
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
I'm having some trouble with my code. I have a number of lists, lists 1, 2 and 3 contain elemets so that when I click them they appear in list 4.
My goal is to have a number appear in a JTextField that will change every time an element is added to list 4.
This is the code I have in order for me to do that but it doesn't work and I don't know why.
jtextfield.setText(java.lang.String.valueOf(list4.getModel().getSize()));
The java.lang.String is weird I know but eclipse told me to change it.
Thank you!
You should use a ListDataListener. An event will be generated any time the DefaultListModel is updated by adding or removing an item.
Then you simply invoke the code you posted above.
Read the section from the Swing tutorial on How to Write a ListDataListener for more information and working examples.
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 8 years ago.
Improve this question
I'm writing a Java application that calls a method letsPlay. I want to see if the code works, and sout'ed to test if it's running or not. When I run the app, nothing is printed. Is it because Java doesn't sout anything, or is it a problem with my code?
private void letsPlay(boolean player1turn) {
if(player1playing && player1turn)
System.out.println("It is " + nameField1.getText() + "'s turn.");
}
One of the two:
(probably) player1playing or/and player1turn are false, causing the expression to be evaluated to false, so the statement won't be executed
output stream is directed to somewhere else and not to the console, to solve this you'll need to do something like:
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
The easiest way to find what's your problem is to debug your code. Use the debugger, it'll save for you time, much of it.
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 8 years ago.
Improve this question
Im pretty new to SWING and I tried my best but this is what is happening.
I have a interface that looks like this:
https://dl.dropboxusercontent.com/u/17524455/nodelete/1.jpg
From the main thread I call:
FrmMain.settextParticipants(5 + "");
FrmMain.setLaps(5 + "");
FrmMain.setRaceType("standard");
And that goes OK.
I Even manage to update the stoptime and time in the upper part of the GUI.
But as soon as I call (in the next line)
PnlRacers.PnlTransparents[0].setNameAndKartNr("01", "RACER");
My UI breaks like this:
https://dl.dropboxusercontent.com/u/17524455/nodelete/2.jpg
And the only thing that helps to fix the UI is, when I grab the window and move it around (to my second screen for example). That tells me that the "data" or "functions" are working well I guess... But the REDRAWING (or how to call it) is somehow ok for the first arguments and broken for the last class. After moving around it looks like this: https://dl.dropboxusercontent.com/u/17524455/nodelete/3.jpg
I read something about redraw() and validate() and I tried all on all places and on any element I was working with :(.
Maybe someone knows what the problem could be and if the source should be any help, here it is: https://dl.dropboxusercontent.com/u/17524455/nodelete/TEST.rar
Please help :) Im so lost ...
Have you tried calling repaint() to the content pane after the change you implemented?