aspose file tools*
The moose likes Applets and the fly likes JApplet containing JTextfields within a JMenubar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "JApplet containing JTextfields within a JMenubar" Watch "JApplet containing JTextfields within a JMenubar" New topic
Author

JApplet containing JTextfields within a JMenubar

Sven Farrenkopf
Greenhorn

Joined: Sep 03, 2008
Posts: 22
Hi there ...

after finding the actual problem to my symptoms, I'm now completely lost.

I have a JMenuBar in a JApplet.
The menubar contains a menu, which has as submenu and a JTextfield "A".
The submenu has antoher JTextfield "B".

Running the applet in a browser with width and height set to 100%, both Textfields are editable.
Running the applet in a browser with width set to 100% and height set to "45" the textfield in the submenu ("B") is not editable.

The problem occurs with IE6 and JRE 1.6.0_12, with JRE 1.5.0_09 it doesn't.

Any ideas?

Sample-Code



Regards
Sven





Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41579
    
  54
I've never tried putting a JTextField in a menu -didn't know that was possible, and am not sure that it's even supposed to work- but the applet width and height parameters are in *pixels*, not *percentages*.


Ping & DNS - my free Android networking tools app
Sven Farrenkopf
Greenhorn

Joined: Sep 03, 2008
Posts: 22
Well, I can put a JTextfield in a JPopupMenu and it works fine. Putting it in a JMenu in an applet that's large enough seems to be fine too. But this thing drives me crazy. Especially because it works if the Textfield is part of a top-level menu.

Any ideas? Please?

(And why can't I define my applet/object-tag with percentage-values? Is this not specified? It works with IE ...)

Sven
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41579
    
  54
And why can't I define my applet/object-tag with percentage-values? Is this not specified? It works with IE ...

Umm, are you new to web development? :-) Just because something works in IE does NOT mean that it works anywhere else, nor does it mean that it conforms to any standard (which in this case is set by Sun, not Microsoft).
Sven Farrenkopf
Greenhorn

Joined: Sep 03, 2008
Posts: 22
Well, I'm into Swing/Applet-Development for some years now, so not actually "new". And I didn't expect it to work on all platforms - but IE is standard in our company, so "%" saves me some scripting. That's why I asked if it was specified this way. Looking it up, I just found suggestions that you shouldn't use it - but no specification. (Which doesn't mean it doesn't exist - I just googled 10mins!)

Anyway ... pixel-sizes don't help - same effect. I'm aware the guys from sun didn't expect developers to put a JTextfield in a JMenu. I even found a posting on sun's Bug-DB (in a different context) where a supporter was totally surprised that people could have such an idea. But browsing swing-codes I can't see why it shouldn't work. Having a JTextfield in a simple JPopupMenu (without JMenu as parent) always works - no matter how big or small the applet is and whether the popup is inside or outside the applet- or browser-area. But that won't solve my problem since I need the JMenu.

Our company can't upgrade to JRE 1.6 unless I either solve this problem or write them a different user-interface (which they have to accept first).

Sven
Sven Farrenkopf
Greenhorn

Joined: Sep 03, 2008
Posts: 22
For anyone who might have the same problem some day, I reported the bug to sun:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6828208

Sven
Sven Farrenkopf
Greenhorn

Joined: Sep 03, 2008
Posts: 22
Sorry for bringing this up again, but I just tried Java 7 early access ... and the bug is still there. We can't stay on JRE 1.5 forever, so has anybody any idea for a workaround?

Sven
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JApplet containing JTextfields within a JMenubar