views:

23

answers:

1

We are building our own Web Browser in Java. It doesn't have to be anything too complicated, we just want several things to do so we could distinguish our project from others.

What we want to know is this: Is it possible to somehow embed a JTextField object into a JMenuItem?

To be more precise, we want our address bar (text field) to show when we click on a certain item within our menu.

+1  A: 

Well, menu items are used for invoking an Action which causes the menu to close.

So you would just have your menu item Action display a popup dialog or something like that.

Or, if you really want to keep the popup open, the you could probably create a sub menu and then just add the JTextField to the sub menu. Remember, you can add any Component to JMenu.

Or, if you just want the text field to display on the main menu, then you just add the text field to the main menu. Of course you would lose functionality like being able to use the keyboard to navigate up and down the menu list.

All the suggestions are a hack at best, so I agree with the original comment to your question.

camickr