jmenubar

java JMenuBar not visible? Why?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 12:12:26
问题 I cannot figure out why my menu bar isn't visible. I have following code: //Main import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Menu extends JFrame{ public static void main(String[] args){ JFrame frame = new JFrame(); frame.setSize(500,350); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); menuBar mbObj = new menuBar(); mbObj.menuBar(frame); } } //Menu Bar class public class menuBar{ private JMenu file

Why does the compiler not run the program even though there are not any errors?

跟風遠走 提交于 2019-12-11 06:24:25
问题 I have a program that is not showing any errors in Eclipse, but whenever I click the run button, nothing happens. I get the code lines in the compiler console that I have attached below. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Transaction extends JFrame { private static final long serialVersionUID = 1L; JFrame frame = new JFrame("Bank Account - S Standridge"); JMenuBar MenuBar; JMenu File = new JMenu("File"); JMenu Edit = new JMenu("Edit"); JMenu About =

Why does my program compile but it not run?

北战南征 提交于 2019-12-11 05:34:08
问题 This is a follow up question due to changes being made to the OP code. Another user suggested I link the other question to this one. The OP is : Why does the compiler not run the program even though there are not any errors? I have a code that compiles but it does not run. I am trying to get the GUI to run so that I can then add the code to perform the functions I need it to. the code follows as: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Transaction

How to dynamically add JMenus to JMenuBar

拈花ヽ惹草 提交于 2019-12-11 04:41:54
问题 Following is my code. import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class MenuBarProblem { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(new Dimension(300, 400)); JMenu menu1 = new JMenu("First"); JMenuItem item = new JMenuItem("Add menu"); menu1.add(item); final JMenuBar mb = new

JMenuBar does not enable after being disabled

柔情痞子 提交于 2019-12-11 03:32:20
问题 I'm disabling a JMenuBar before displaying a FileDialog (as the menu items are still active when the FileDialog is visible) using getJMenuBar().setEnabled(false) and then calling getJMenuBar().setEnabled(true) after the FileDialog closes, but the menu items do not become active after being enabled - they will if I change to another application and back to mine. I've tried calling getJMenuBar().revalidate() and/or getJMenuBar().repaint() to no avail. Of note, I'm using a screen menu bar as I'm

Changing a JMenuBar's font

情到浓时终转凉″ 提交于 2019-12-11 00:43:15
问题 I have problems with setting the font of a JMenuBar . I personally don't like the bold font Java frames use by default, so I tried to change it by using something like this: public class MyFrame extends javax.swing.JFrame { public MyFrame() { JMenuBar menuBar = new JMenuBar(); menuBar.setFont(new Font("sans-serif", Font.PLAIN, 12)); setJMenuBar(menuBar); setSize(600, 400); // add some menus to the menu bar menuBar.add(new JMenu("Foo")); menuBar.add(new JMenu("Bar")); menuBar.add(new JMenu(

How to remove the border on a JMenu or JMenuItem

我只是一个虾纸丫 提交于 2019-12-10 18:34:09
问题 I'm using Eclipse Luna with Java 1.7 and am trying to create a JPanel that has a JMenuBar . This JMenuBar contains a JMenu which again contains a JMenuItem . To fit the whole JMenuBar into my project's visual design, I changed the background and foreground colors of JMenu , JMenuBar and JMenuItem using UIManager.put() . The result should be a drop-down menu with sections only divided by different shades of a Color (blue in my example). No lines or borders. However, a whiteish, silverish

Nimbus Look And Feel adjust colors of menubar

走远了吗. 提交于 2019-12-09 00:57:27
问题 I am trying to adjust the colors of the Nimbus Look and Feel but it is only working partially. Especially I have problems adjusting the colors of the menubar. Here is a running example: import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing

The JPanel contentpane confusion

旧街凉风 提交于 2019-12-05 08:47:39
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. But getContentPane() returns a Container, not a JPanel object so I'm confused. If so, does that mean that

How to create a JMenuBar with Glossy Colors?

 ̄綄美尐妖づ 提交于 2019-12-02 17:43:26
问题 I created a small Swing based application. For that I created a menu bar using JMenuBar class. But I want to apply glossy color for that menu bar. In particular, I'm look at the effects seen here: a gradient color in the fifth example and an animation in the seventh. My Code: public class MenuBar extends javax.swing.JFrame { /** * Creates new form MenuBar */ public MenuBar() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT