Hai!!! I have a class, Search Class...this class suppose to search the data from the MySQL db...on top of the JFrame, should have two JMenu bar button which is call About Us and Help...the problem is, if you run this code, the JMenu Bar doesn't appear on top of the JFrame...Can anyone help me??? Pleassseeee...

import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;


class User extends JFrame
        {
                    JButton SEARCH;
                    JLabel label3;
                    JTextField search;

			User(){
                            final JFrame s=new JFrame("Malay Synonym Word Checker - SEARCH WORD");
                                s.setLayout(null);

				label3 = new JLabel();
                                label3.setText("WORD:");
                                search = new JTextField(15);

                                SEARCH=new JButton("SEARCH");
                                label3.setBounds(60,50,150,28);
                                search.setBounds(120,50,170,25);
                                SEARCH.setBounds(310,50,83,28);

                                s.add(label3);
                                s.add(search);
                                s.add(SEARCH);
                                s.setVisible(true);
                                s.setSize(450,250);
                                s.setBackground(Color.red);
                               }

    public void Menu()
{
    JFrame amy = new JFrame("Malay Synonym Word Checker");

    amy.setSize(500,500);
    amy.setVisible(false);
    amy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

     JMenuBar bar = new JMenuBar();

		setJMenuBar(bar);

		JMenu fileMenu = new JMenu("File");
		fileMenu.setMnemonic('F');
		JMenu helpMenu = new JMenu("Help");
		helpMenu.setMnemonic('r');

		bar.add(fileMenu);
		bar.add(helpMenu);

		JMenuItem aboutItem = new JMenuItem("About");
		aboutItem.setMnemonic('A');
		aboutItem.addActionListener(

		new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				JOptionPane.showMessageDialog(getRootPane(), "This is a final year project by \nNur Amillia bt Amran.", "About", JOptionPane.PLAIN_MESSAGE);
			}
		}
		);

		JMenuItem exitItem = new JMenuItem("Exit");
		exitItem.setMnemonic('x');
		exitItem.addActionListener(

		new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				System.exit(0);
			}
		}
		);

		fileMenu.add(aboutItem);
		fileMenu.addSeparator();
		fileMenu.add(exitItem);

                amy.setVisible(true);
                amy.setSize(550,200);
		amy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	}

}


 class LoginDemo
{
  public static void main(String arg[]){

    new User();



}
 }

I've change my code to this....but it still doesn't workkk....

import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;


class User extends JFrame
        
        {
                    JButton SEARCH;
                    JLabel label3;
                    JTextField search;

			User(){
                            final JFrame s=new JFrame("Malay Synonym Word Checker - SEARCH WORD");
                            JMenuBar bar = new JMenuBar();

                        setJMenuBar(bar);

		JMenu fileMenu = new JMenu("File");
		fileMenu.setMnemonic('F');
		JMenu helpMenu = new JMenu("Help");
		helpMenu.setMnemonic('r');

		bar.add(fileMenu);
		bar.add(helpMenu);

		JMenuItem aboutItem = new JMenuItem("About");
		aboutItem.setMnemonic('A');
		aboutItem.addActionListener(

		new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				JOptionPane.showMessageDialog(getRootPane(), "This is a final year project by \nNur Amillia bt Amran.", "About", JOptionPane.PLAIN_MESSAGE);
			}
		}
		);

		JMenuItem exitItem = new JMenuItem("Exit");
		exitItem.setMnemonic('x');
		exitItem.addActionListener(

		new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				System.exit(0);
			}
		}
		);

		fileMenu.add(aboutItem);
		fileMenu.addSeparator();
		fileMenu.add(exitItem);


                                s.setLayout(null);

				label3 = new JLabel();
                                label3.setText("WORD:");
                                search = new JTextField(15);

                                SEARCH=new JButton("SEARCH");
                                label3.setBounds(60,50,150,28);
                                search.setBounds(120,50,170,25);
                                SEARCH.setBounds(310,50,83,28);

                                s.add(label3);
                                s.add(search);
                                s.add(SEARCH);
                                s.setVisible(true);
                                s.setSize(450,250);
                                s.setBackground(Color.red);

                        }

    
}



 class LoginDemo
{
  public static void main(String arg[]){

    new User();



}
 }

It's okay...problem solved..=)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.