jmenubar

Why JMenuBar is not place in the JFrame content pane, but JToolbar place in the content pane

会有一股神秘感。 提交于 2020-01-19 17:58:27
问题 Why JMenuBar is not place in the content pane?is there any reason or effects when make a java gui program especially when using jframe? Thanks 回答1: As stated in Using Top-Level Containers article, the manu bar is managed by the Root Pane: Each top-level container relies on a reclusive intermediate container called the root pane. The root pane manages the content pane and the menu bar, along with a couple of other containers. You generally don't need to know about root panes to use Swing

Why JMenuBar is not place in the JFrame content pane, but JToolbar place in the content pane

情到浓时终转凉″ 提交于 2020-01-19 17:58:27
问题 Why JMenuBar is not place in the content pane?is there any reason or effects when make a java gui program especially when using jframe? Thanks 回答1: As stated in Using Top-Level Containers article, the manu bar is managed by the Root Pane: Each top-level container relies on a reclusive intermediate container called the root pane. The root pane manages the content pane and the menu bar, along with a couple of other containers. You generally don't need to know about root panes to use Swing

Why JMenuBar is not place in the JFrame content pane, but JToolbar place in the content pane

。_饼干妹妹 提交于 2020-01-19 17:58:05
问题 Why JMenuBar is not place in the content pane?is there any reason or effects when make a java gui program especially when using jframe? Thanks 回答1: As stated in Using Top-Level Containers article, the manu bar is managed by the Root Pane: Each top-level container relies on a reclusive intermediate container called the root pane. The root pane manages the content pane and the menu bar, along with a couple of other containers. You generally don't need to know about root panes to use Swing

How to import an image in menu bar

眉间皱痕 提交于 2020-01-16 03:55:10
问题 I've created a simple menu bar and I don't know how to import an image in the free space. My code is below: import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.io.IOException; public class MyMenu extends JFrame { JMenuBar menubar; JMenu file, edit, contact, quit; JMenuItem exit, open, search, delete, registration, informations; public MyMenu() { setLayout(new FlowLayout()); //___________________________ FILE __________________________________ menubar = new JMenuBar()

MenuListener Implementation, how to detect which JMenu was clicked?

丶灬走出姿态 提交于 2020-01-01 16:10:37
问题 If I have defined JMenu and JMenuBar like this: private JMenuBar jMenuBar; private JMenu jMenu1; jMenuBar = new JMenuBar(); jMenu1 = new JMenu(); jMenu1.setText("ABOUT"); //and here add a MenuListener so that i can detect when a menu is clicked: jMenu1.addMenuListener(this); jMenuBar.add(jMenu1); setJMenuBar(jMenuBar); //and here i implement the menulisteners public void menuSelected(MenuEvent e) { //my logic here } public void menuDeselected(MenuEvent e) {} public void menuCanceled(MenuEvent

Java JMenuItem ActionListener

放肆的年华 提交于 2019-12-30 08:56:49
问题 I need some help with my ActionListener on my JMenuBar. There's no error; however every time I click on a JMenuItem, it triggers all the action associated with the JMenuItem. My question is: am I doing it right in my ActionListener code? I'm not too sure about my ActionListener class. I'm trying to separate my ActionListener from my Button logic. If anyone has any ideas on what I may be doing wrong, please point it out. Here is my code: package MenuBar; import java.awt.*; import javax.swing.*

JMenu work on single tab

こ雲淡風輕ζ 提交于 2019-12-25 17:47:06
问题 I have a JMenuBar and I have a JTabbedPane , when I create multiple tabs the JMenuBar does it on all the tabs, e.g. I open a file it opens the same file in each tab. However I only want it to open a file on the current tab. I have added a ChangeListener so It know what tab its in however it does not seem help even though it works. tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Tab=" + tabbedPane.getSelectedIndex()); } });

How do I change the direction of JMenus in a JMenuBar

℡╲_俬逩灬. 提交于 2019-12-24 14:57:36
问题 When I create a menu in java GUI by using JMenuBar it puts all JMenu s from Left-to-right direction like this: I want to change it to Right-to-left like this: I want do this in an English OS, so suggestions of an Arabic or Right-to-Left solution aren't what I'm looking for. 回答1: You can use Component.applyComponentOrientation to change the orientation of the JMenuBar : import javax.swing.*; import java.awt.*; public class R_L_MenuBar_Demo { public static void main(String[] args){

Swing menu item on right of Menu Bar

大兔子大兔子 提交于 2019-12-23 15:37:33
问题 I have a swing application and on the JFrame's menu I want to add a Help MenuItem, but have it Right justified. Any ideas ? A Swing JMenuBar has a BoxLayout and I have tried: menuItem = new JMenuItem("Help"); menuItem.setAlignmentX(Box.RIGHT_ALIGNMENT); menuBar.add(menuItem); The menu just stays on the left. I have also tried: menuBar.add(Box.createHorizontalGlue()); as per the Swing Tutorial... but that just adds a space. I am using Windows 7. JDK 1.6.26 EDIT: It works as per the Java

php menu setting for language settings

喜你入骨 提交于 2019-12-23 04:25:28
问题 I am going to implement the multi-language support for the website using php The default language is chinese I have selected en as british English one. the webpage link is set as www.abc.com/index.php?lang=en When it comes to selecting the other menu items, the query string ?lang=en is gone and resume to chinese language Would you please tell me how to pass the 'en' and ?lang= to other menu so as to maintain the selection of language desired through the browsing ? The below is my code <html>