Need a Java guru :-)
In my program I would like to have a method - "public boolean confirmAction()" - in the GUI. This method should present the user with some option, and return the reply.
In solving a similar problem I have used JOptionPane (with JDialog) for this behavior, but now I have a full-screen application and cannot use JFrame, JDialog or JInternalFrame.
First, I tried this approach:
public boolean confirmAction() {
// ConfirmPanel: The JPanel containing the question and the options.
confirmPanel.show();
return confirmPanel.getReply();
The method "getReply()" in "ConfirmPanel" waits until the user has choosen an option, and returns the outcome.
This workes fine if the caller of "confirmAction()" is not the "Event-Dispatching Thread" (EDT), but if the caller is the EDT this problem arises: While waiting for input from "getReply()" it may not process the events needed for making this reply and thereby causing a deadlock.
Do you know any good solutions for this problem?
I think one possible solution might be to channel the events from the "EventQueue" to the listener of "ConfirmPanel" while waiting for the reply - but this seems to be a dirty hack (and I have not tried it so I am unaware if it is possible)...
What do you think?
I found the solution I wanted!
To satisfy your curiosity jayDS:
The reason why I could not use dialogs was because I am developing a game. Using a JDesktopPane instead of just a JLayeredPane is slower (I have tested it). But JayDS, you guided me to the solution: I read the source for JInternalFrame and found "startModal()" with the code I needed (rerouting of the events).
Thanks for helping; jockamus, bbritta, Josh_Castagno and JayDS.
I have appended JInternalFrame.startModal():
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
// This is essentially the body of EventDispatchThread
AWTEvent event = theQueue.getNextEvent();
Object src = event.getSource();
// can't call theQueue.dispatchEvent, so I pasted its body here
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (src instanceof Component) {
((Component) src).dispatchEvent(event);
} else if (src instanceof MenuComponent) {
((MenuComponent) src).dispatchEvent(event);
} else {
System.err.println("unable to dispatch event: " + event);
} else
while (isVisible())
wait();
} catch(InterruptedException e){}
Similar Messages
-
I keep getting a pop up window labled Software Update saying, "To open 'MLBNexDefAutobahn,' you need a Java SE 6 runtime. Would you like to install one now?" I click on "Not Now" and it pops open again a second later. It is not going away! Is this a Java virus? I just installed Maverick Wednesday and got a message yesterday on google that "Google would like to take over this computer"??? Please help.
Thanks!This is not a virus, or any other kind of malware. Some third-party software that you have installed is repeatedly trying to open a Java process called MLBNexDefAutobahn. What that software might be, I don't know. What software do you have that this name might fit with?
-
To open you need a Java SE 6 runtime. Why, when I have 1.7 installed?
PREFACE: I've read most of the posts on here that discuss this issue but none have provided a real answer to this.
I'm on Moutain Lion w/ all the latest updates from the App Store.
I've installed Oracle's latest Java JDK (7u11) because of the recent security issue. When I go to Terminal and type in "java -version", it's the latest version of Oracle's 1.7. I don't have Apple's 1.6 version of Java on my system. I've verified that by checking in the appropriate System folder for the 1.6 JRE & JDK.
So all seems to be fine so far and per Apple's recommendation, I'm using Oracle's latest version of Java.
So when I go to run Charles debugging proxy, which is a Java desktop app, I get the following message in a dialog:
"To open "Charles,” you need a Java SE 6 runtime. Would you like to install one now?"
If I have the latest Oracle Java version installed, why am I being prompted to install Apple's 1.6 version?
I've had this prompt in the past and went through the install before. Contrary to what another poster in another thread says, choosing install at the prompt ignores the fact that 1.7 is installed and does in fact install Apple Java 1.6. It's an outdated version of Java which I don't want on my system.
Why do I need to install Apple's 1.6 when Oracle's Java 1.7 latest is already there?
ReyRey Bango wrote:
If I have the latest Oracle Java version installed, why am I being prompted to install Apple's 1.6 version?
Rey
You would need to ask the "Charles" developer that question. There seem to be quite a few issues regarding Java 1.6 and 1.7 with the Oracle version causing the most trouble. This, of course, is not an Apple problem to solve. The Java community and Oracle need to sort out their troubles.
You can, of course, have both versions on your system but you need to do some terminal work to switch between them. Apple has a tech support document that explains how to do that. -
I have Mountain Lion on my MacBook Pro and every time I run "Dreamweave" or "Eclipse" for example, I get this message: "To open "Eclipse" you need a java SE 6 runtime. Would you like to install it now ?".
I've tried installing it many many times, manualy and from this notification but it doesnt work.
I've tried installing Java 7 and tried uninstalling Java 7 then installing "Java For OSX 2013-002" and dosent work too !
everytime I install any Java version I tried this "java -version" I got this result "No Java runtime present, requesting install." !
anybody can help ?
ThanksContact the developers of that software for a updated 10.8.3 verison that runs off Java 7.
They are likely working on it or perhaps something better not relying upon Java at all.
Java is a real security nightmare lately.
Security Issues Warning List -
Do I need the 'java-polling-amf in my services-config.xml if I'm using coldfusion
Do I need the 'java-polling-amf in my services-config.xml if I'm using coldfusion?
Im using IntelliJ IDEA with a flex project and for some reason its stopping comilation with this error:
[SUITE (Flex Application 1)] flex.messaging.config.ConfigurationException: The services configuration includes a channel-definition 'java-polling-amf' that has an endpoint with a context.root token but a context root has not been defined. Please specify a context-root compiler argument.
when I was using flex builder with CF builder I never needed to specify the context.rootI don't use IDEA, so I don't know what kind of configuration settings it has for Flex project development.
You don't need the java-polling-amf channel for CF development. By default, CF development uses CF-specific channels:
my-cfamf
cf-polling-amf
my-cfamf-secure
any custom channels you've created yourself for CF to use
That said, all the channels require a context root setting for your project to compile properly. If you still have Flash Builder handy, take a look at your compiler switches for a project there to see what you're missing in IDEA.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/ -
I NEED A JAVA SCRIPT that chance the crouser on my webpage
my webpage is made whit flash
so i want i want a script that chance the cruser(mouse-pointer)<script language="JavaScript">
alert("WRONG FORUM, Suggest you do a google search....");
</script> -
when trying to use my webmail service it says i need some java to run reply to the emails. i am using an iPad iOS 6.1.3
what do i hve to do to be able to use my webmail ?Java is not supported on iPads. Does your provider have a non-Java version or have their own app, or could you use the Mail or a third-party email app for it ?
-
Hello everyone
I'm a Student and new to java and I have been given a question which I have to go through. I have come across a problem with one of the questions and am stuck, so I was wondering if you guys could help me out.
here is my code so far:
A Class that maintains Information about a book
This might form part of a larger application such
as a library system, for example.
@author (your name)
*@version (a version number or a date)*
public class Book
// instance variables or fields
private String author;
private String title;
Set the author and title when the book object is constructed
public Book(String bookAuthor, String bookTitle)
author = bookAuthor;
title = bookTitle;
Return The name of the author.
public String getAuthor()
return author;
Return The name of the title.
public String getTitle()
return title;
and below are the questions that I need to complete. they just want me to add codes to my current one, but the problem is I don't know where to put them and how I should word them, if that makes sense.
Add a further instance variable/field pages to the Book class to store the number of pages in the book.
This should be of type int and should be set to 0 in the Constructor.
Add a second Constructor with signature
public Book(String bookAuthor, String bookTitle, int noPages) so it has a third parameter passed to it as well as the author and title;
this parameter is used - obviously?? - to initialise the number of pages.
Note: This is easiest done by making a copy of the existing Constructor and adding the parameter.
Add a getPages() accessor method that returns the number of pages in the book.
Add a method printDetails() to your Book class. This should print out the Author title and number of pages to the Terminal Window. It is your choice as to how the data is formatted, perhaps all on one line, perhaps on three, and with or without explanatory text. For instance you could print out in the format:
Title: Robinson Crusoe, Author: Daniel Defoe, Pages:226
Add a further instance variable/field refNumber() to your Book class. This stores the Library's reference number. It should be of type String and be initialised to the empty String "" in the constructor, as its initial value is not passed in as a parameter. Instead a public mutator method with the signature:
public void setRefNumber(String ref) should be created. The body of this method should assign the value of the method parameter ref to the refNumber.
Add a corresponding getRefNumber() accessor method to your class so you can check that the mutator works correctly
Modify your printDetails() method to include printing the reference number of the book.
However the method should print the reference number only if it has been set - that is the refNumber has a non-zero length.
If it has not been set, print "ZZZ" instead.
Hint Use a conditional statement whose test calls the length() method of the refNumber String and gives a result like:
Title: Jane Eyre, Author: Charlotte Bronte, Pages:226, RefNo: CB479 or, if the reference number is not set:
Title: Robinson Crusoe, Author: Daniel Defoe, Pages:347, RefNo: ZZZ
Modify your setRefNumber() method so that it sets the refNumber field only if the parameter is a string of at least three characters. If it is less than three, then print an error message (which must contain the word error) and leave the field unchanged
Add a further integer variable/field borrowed to the Book class, to keep a count of the number of times a book has been borrowed. It should (obviously??) be set to 0 in the constructor.
Add a mutator method borrow() to the class. This should increment (add 1 to) the value of borrowed each time it is called.
Include an accessor method getBorrowed() that returns the value of borrowed
Modify Print Details so that it includes the value of the borrowed field along with some explanatory text
PS. sorry it looks so messey1. In the future, please use a more meaningful subject. "Help needed with java" contains no information. The very fact that you're posting here tells us you need help with Java. The point of the subject is to give the forum an idea of what kind of problem you're having, so that individuals can decide if they're interested and qualified to help.
2. You need to ask a specific question. If you have no idea where to start, then start here: [http://home.earthlink.net/~patricia_shanahan/beginner.html]
3. When you post code, use code tags. Copy the code from the original source in your editor (NOT from an earlier post here, where it will already have lost all formatting), paste it in here, highlight it, and click the CODE button. -
Can i download java for my ipad, the problem is i open glovis.usgs from my ipad, but i can't see the full page, cause the page need a java...help me please
Nope. The iPad (and iPhone and iPod touch) cannot execute Java applets. It's a limitation in iOS from the beginning (just like lack of Flash). You will either need to use a desktop computer or access a desktop computer via RDP or VNC to access that page on iPad.mIn short: there is no native way to use a Java applet on iOS.
-
Need a java code using swing that can do master configuration
I need a java code using swing that can do master configuration.For example, in the 1st screen it will show all configuration checke boxes . According to those selected check box, it will show the needed panels sequentially and finnaly it will update many xml files.
TapasB wrote:
I need a java code .......and I wish you much luck in creating it. Please come back if you have a specific question on a specific part of your code that is not working quite right. -
Hi,
iam working in SAP .
I need sample java code on how to convert Decimal to number
For Ex: I/p-----123.11
O/p----------------12311 ( with out decimal) want to remove the dicimal point what ever the input value and deliver it to the output
Please give me code
Regards
Sumani don't know what do you want to do really. If you are doing it simply then you can take the input in a String and then remove the decimal.
String str = "123.11";
str = str.substring(0, str.indexOf("."));
System.out.println(str); -
Maybe because I'm running on empty, waiting for lunch, but I'm not feeling inspired.
So, I need some Java inspiration. What was the last Java-"thing" (anything, from a coding trick, to a class, package, tool, etc...) that made you say "giddy-up!"> super cool stuff.
Another example from the book, but I'll write the Java-equivalent first.
List list = Arrays.asList(
Arrays.asList(1, 0),
Arrays.asList(0, 1, 2)
Collections.sort(list, new Comparator() { // sort by first element
public int compare(Object o1, Object o2) {
List list1 = (List) o1;
List list2 = (List) o2;
Integer a = (Integer) list1.get(0);
Integer b = (Integer) list2.get(0);
return a.compareTo(b);
List expected = Arrays.asList(
Arrays.asList(0, 1, 2),
Arrays.asList(1, 0)
assert list.equals(expected);Here's the Groovy equivalent:
def list = [ [1, 0], [0, 1, 2] ]
list = list.sort { a, b -> a[0] <=> b[0] } // sort by first element
assert list == [ [0, 1, 2], [1, 0] ]Oh, and I'm with duffymo. Spring is a blast.
~ -
Hello Java Guru,
I am writing a simple applet to load an animated gif file. I am using double buffering to avoid flickering. So I want to load the animated gif file to the offscreen buffer during the initialisation of the applet. For that to happen I am using MediaTracker for wait for the loading of the file during initialisation. I am getting the file completly loaded but when I am drawing the file on screen I am getting only the first frame of the animated gif file. When I am trying to draw the animated gif without the buffer I am getting all the frames on the screen. Please anyone can help to resolve my problem. I don't know whether this is a bug of Java. It will be very helpful for me.
Thanking you,
RahulCould you post up the code you're using to display this animated image?
Sounds like you're not adding the ImageObserver to the Image or you're not regenerating the offscreen image at the right time. -
HT5493 so do I need this Java OS X 2012-006 update or no?
so do I need this Java OS X 2012-006 update or no?
The operative words from that article are:
"This update also removes the Java Preferences application, which is no longer required to configure applet settings," the support note concludes.
(My bold)
In other words, the security risks of using Java have been removed, but without loss of functionality.
If you feel you must jave Java you can get it from here:
http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1637588.h tml
Further information here:
http://www.oracle.com/us/corporate/press/1735645 -
hi,
on two occasions, when trying to start an application, i received a warning saying i need a java runtime (?) but that i was not connected to the internet while in fact I was. I controlled this by selecting the system network preference which confirmed my internetconnection was working properly?
thanks in advance
ps: sorry for my language as i am not a native speaker
patrickBecause the machine is not able to resolve the name of the server where it needs to get the Java runtime from. Seem to be a lot of wonky DNS out there.
Temporarily switch your DNS to 8.8.8.8 and 4.4.4.4, open a terminal, and type 'java -version', to get it to install the runtime.
Then put your DNS back the way it was.
Maybe you are looking for
-
When i run Time Machine to back up my computer on to an external hard drive, i have no way of knowing when the back up process has been completed. This is necessary to know because i don't leave my external hard drive connected to the computer. I r
-
How to disable "slide to callback"
When I talk to someone the phone and I walk into no signal coverage area, the phone will hang with "call fail" showing up in the lock screen. The slide bar will show "Silde to Callback". Does anyone know how to disable that feature which is quite ano
-
SQLJ error in stored procedure
Okay I'm kind of new to this stuff so this is probably an easy question but I can't fix my current problem. Know I have been creating and compiling several java stored procedures in my oracle 8.1.7.0.0 enterprise edition database. So far everything i
-
Alphabetical playlists when I dont want them, any ideas?
Ive got a new ipod Nano, and despite having the tracks in my playlists in the order I want on itunes my Nano keeps making them alphabetical when I add them to it, which I dont want. Any ideas? Many thanks in advance if you can help. Philip
-
My Wireless KB and mouse are stuck in discovery mode, but I can't get past the "user password" screen because It won't allow me to enter characters.