Results 1 to 3 of 3
  1. #1
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    130
    Rep Power
    0

    Default JMenuBar acting weird

    i made this JMenuBar but it is not showing completely, i only see 1 tiny edge of the MenuBar.

    can you guys help?

    this is the code:
    Java Code:
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemListener;
    
    import javax.swing.*;
    public class FishingCalculator2 extends JFrame {
    	public static void main(String[] args){
    
    		JFrame frame = new JFrame("Calc");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setSize(500,500);
    		frame.setLocationRelativeTo(null);
    		frame.setLayout(new FlowLayout());
    		
    		JPanel panel = new JPanel();
    		panel.setLayout(new GridLayout(7, 2, 40, 30));
    		JMenuBar bar = new JMenuBar();
    		JMenu menu = new JMenu("Other Calculators..");
    		JMenu menu1 = new JMenu("About");
    		JMenuItem calcs = new JMenuItem("More calculators");
    		JMenuItem Pisvlekk = new JMenuItem("Pisvlekk");
    		JLabel lbl1 = new JLabel("Current XP: ");
    		JLabel lbl2 = new JLabel("XP goal: ");
    		JLabel lbl3 = new JLabel("Name of fish: ");
    		JTextField txt1 = new JTextField(10);
    		JTextField txt2 = new JTextField(10);
    		JTextField txt3 = new JTextField(10);
    		JTextField txt4 = new JTextField(1);
    		JTextField txt5 = new JTextField(1);
    		JButton b1 = new JButton("Calculate");
    		JButton b2 = new JButton("XP table");
    		JButton b3 = new JButton("Help");
    		panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    		panel.add(lbl1); 
    		panel.add(txt1); 
    		panel.add(lbl2);
    		panel.add(txt2);
    		panel.add(lbl3);
    		panel.add(txt3);
    		panel.add(b2);
    		panel.add(b1);
    		
    
    		
    		
    		frame.setJMenuBar(bar);
    		bar.setVisible(true);
    		frame.add(panel);
    		frame.setVisible(true);
    		
    		
    		
    		
    		
    	}

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JMenuBar acting weird

    1. I would avoid changing the JFrame's layout from it's default BorderLayout to FlowLayout, though I doubt that this is the cause of your problems.
    2. You need to add menus to your menubar for it to have "substance" and to gain "thickness".

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,454
    Rep Power
    20

    Default Re: JMenuBar acting weird

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. primitive acting like a Object
    By killutch in forum New To Java
    Replies: 5
    Last Post: 09-15-2012, 08:59 PM
  2. Sphinx 4 Voice Recognition acting WEIRD!
    By treeface99 in forum Advanced Java
    Replies: 3
    Last Post: 04-16-2012, 06:39 PM
  3. Replies: 3
    Last Post: 02-14-2012, 11:27 PM
  4. actionPerformed acting strangely
    By Fortu in forum New To Java
    Replies: 18
    Last Post: 04-10-2011, 05:07 AM
  5. Replies: 6
    Last Post: 01-14-2011, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •