Hey all
I am making a simple text editor, it is my first project and I have got the text area all set up but i have now tried to add a menu bar which will hold the File>Save,Open,exit etc...
I have created the menubar and added one menu item called File, there is nothing in the list now, i am going to do that later but I cant get the menu bar to even appear.
Can someone take a look at my code below and tell me why please. Feel free to point out any other mistakes I have made.
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class JotPad extends JFrame
{
private JTextArea textArea;
public JotPad()
{
super("Jot Pad");
//Arrange the Editing Pane
textArea = new JTextArea(20, 50);
textArea.setEditable(true);
setBounds(300, 500, 700, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane scrollingText = new JScrollPane(textArea);
//Set all the panel to size and add the components
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(scrollingText, BorderLayout.CENTER);
setLocationRelativeTo(null);
setContentPane(mainPanel);
mainPanel.setOpaque(true);
// We must set it as visible or else it will run in the background which is bloody useless
setVisible(true);
//Set all the menu bits
JMenuBar menu = new JMenuBar();
JMenu file = new JMenu("File");
menu.add(file);
}
public static void main(String[] args)
{
new JotPad();
}
}
Many thanks
HLA91