jmenubar

Focus on first jmenubar item on “alt” key press

不羁的心 提交于 2019-12-22 12:07:09
问题 Is there any way to auto-select a jmenu within my jmenubar when the user's pressing the "ALT" key ? (Like windows softwares) The problem is that the default behavior of my jframe, when the "ALT" key is pressed, is to show up a menu containing the following actions : restore, move, size, reduce, ... What I want my java application to do, is to select my jmenu first item when "alt" is pressed. (Like it would do with a mnemonic : "alt + f") 回答1: Add the action to the ActionMap and InputMap of

The JPanel contentpane confusion

我怕爱的太早我们不能终老 提交于 2019-12-22 06:39:18
问题 I am learning Java Swing and I appended a menuBar to the frame. By default this should call jframe.getContentPane().add(child) . When I ran the script the menuBar didn't show up. But the button was at the very top "y=0" if that makes sense. Then I realized my mistake I actually had to put in a menu in the menubar. Then the menuBar showed up. So that got me thinking...is the "menubar" "contentpane" actually 2 panels? It is confusing the hell out of me. Because that acted a lot like a panel.

Example Program JMenubar on JInternalFrame when i Maximize the JInternalFrame

十年热恋 提交于 2019-12-19 21:25:17
问题 Hi I need an Example program in which When i maximize the JInternalFrame the JMenuBar of JFrame should set on JInternalFrame and When i minimize the JInternalFrame again the JMenuBar should leave JinternalFrame and set to JFrame as shown below Please provide me an Example Program in Java Swing 回答1: Seems to work fine, please post SSCCE to show specific problem: import java.awt.*; import java.awt.event.*; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing

How to make a JMenu have Button behaviour in a JMenuBar

不打扰是莪最后的温柔 提交于 2019-12-19 07:28:22
问题 I was trying to make a JMenu behave like a JButton but I'm having some problems and hopefully someone here can help! I've added a MenuListener to the JMenu item with this but I cant get the popup menu/focus to leave to enable me to properly click the JMenu repeated times to trigger this function and i was hoping someone could tell me what i'm doing wrong. Thanks. public void menuSelected(MenuEvent e) { ... // do stuff here code JMenu source = (JMenu)e.getSource(); source.setSelected(false);

add JMenuBar to a JPanel?

妖精的绣舞 提交于 2019-12-17 12:42:30
问题 I've got a JMenuBar and a JPanel. I'd like to add the JMenuBar to the JPanel. How would I do so? 回答1: You can use a BorderLayout for your JPanel and put the JMenuBar into the NORTH area of the panel with JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(menubar, BorderLayout.NORTH); JMenuBar is a JComponent and can be added to a Container like any other JComponent. 回答2: JMenuBars are set to the JFrame using the setJMenuBar method. See the following tutorial on how to use them.

How can I add a JTextField to a JFrame's MenuBar?

情到浓时终转凉″ 提交于 2019-12-17 05:12:11
问题 I've been trying to overload JMenu and put in some custom code to support a JTextField but that isn't going well. My main purpose here is to add a search field to the right of my menu items. So I have something like File, Edit, help on the left and then on the right would be the search bar, almost like how there is a google search bar in some browsers. Does anyone have an idea how I could go about adding this functionality? 回答1: I never see that as JMenuItem , I think that alyways placed in

How can I create title bar menu in Java

半城伤御伤魂 提交于 2019-12-13 06:30:01
问题 I wanna create a simple application with Java. I designed the main template in my head but I have a kind of design problem. I am using JMenuBar and JMenu. It works fine but it's location is not exactly what I want. In ubuntu, I use Eclipse and it has menu in titlebar: As you can see , menus are at top.(File,Edit,Source,etc..) However, My application is not the same. Here is my application. JMenu is working fine but in title bar there is no menu. What can I do to create this menus ? Are there

JMenuItem accelerator not working when menu bar is hidden

不问归期 提交于 2019-12-12 18:41:35
问题 This question is a follow-up to this question. I have a JMenuBar whose behavior is like the menu bars in Firefox and iTunes. That is, the menu bar is initially hidden, but when you press Alt , the menu bar appears. The answer to the other question solved the problem of achieving that functionality, but it brought about another issue: The JMenuItem accelerators are not working when the JMenuBar is not visible. In other words, you must press Alt before CTRL+F (the installed accelerator) will

JMenuBar at the top in MacOSX

血红的双手。 提交于 2019-12-12 12:30:00
问题 In the Java Desktop Application template used by Netbeans, a menu bar is created with JMenuBar and JMenuItems. How can I get that bar displayed at the top, where menu bars are displayed in MacOSX instead of in-window, like in Windows? 回答1: Note: This is outdated information - a more recent answer is needed. Java applications look like traditional java applications even under OS X. If you want a native look and feel, there are a few tweaks you have to do. This article series describes them.

How to get the menu item accelerator keys working when using the screen menu bar on OS X

拜拜、爱过 提交于 2019-12-11 13:57:14
问题 On OS X, it makes sense to remove the JMenuBar from your main JFrame and use the screen menu bar instead. I was under the impression that in recent versions of the Apple JDK this is done using the Application.getApplication().setDefaultMenuBar( JMenuBar ); call. When using this, it seems like the accelerator keys are no longer working. The following program illustrates the problem on OS X: import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.apple.eawt.Application;