This content has been marked as final. Show 1 reply
I don't understand your question :o(
Or at least, I don't see enough information in it to assume the behavior you witness is not the correct one. So I've skipped your post a few times. Since I see you've had no reply over the week-end, I'll try to help you provide more context so that someone else can help you...
Let's address it bit by bit:
When I try to invoke frame2 from frame1What does invoke frame2 mean? You invoke a method, not a class. Which method of frame2's class are you invoking, and what do you expect it to perform?
the focus is shifting to frame1 instead of frame2What do you mean by "shifting to frame1"? Is it on frame2 initially? Is it on frame1, but on another widget within frame1?
though I am doing setVisible(true) on frame2.From the Javadoc http://docs.oracle.com/javase/6/docs/api/java/awt/Window.html#setVisible%28boolean%29, if a frame/window is initially invisible, setVisible(true) only displays it, but nothing says it should give it the focus. A second call to setVisible(true) would bring the window/frame to front, i.e. give it the focus.
This behavior is not consistent.Not consistent with what? Do you have other examples where setVisible() gives the focus differently than in this example? Does frame2 call frame1.setVisible(...) and result in a different effect?
Or do you mean that if you compile both frames' code withj the same JDK version, you obtain a different effect?