• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help!! I cannot figure out how to have my menu items show up on top of my textarea.  RSS feed

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The items to choose from with my menu bar show up behind the textarea. I cannot figure out how to get them on top. The commented out area is what I thought might work but it did not any suggestions?? I am fairly new at this so any suggestions are greatly appreciated.
Thank you for all your help,
David Mohr

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
public class Menu implements ActionListener {
JLabel label = new JLabel();
JPanel menupanel = new JPanel();
JPanel mainpanel = new JPanel();
String path = null;
Filereaderclass obj;
TextArea jScrollPane1;
BorderLayout borderLayout1 = new BorderLayout();
JFileChooser jfc;
int result = 0;
String filename;
File file;
JFrame frame;
JMenuItem item;
JMenuItem item1;
Container content;

//JInternalFrame Iframe;
public Menu() {
frame = new JFrame("menu test");

content = frame.getContentPane();
jScrollPane1 = new TextArea();
//Iframe = new JInternalFrame("");
//Iframe.add(jScrollPane1, BorderLayout.CENTER);
content.add(jScrollPane1, BorderLayout.CENTER);
content.add(menupanel, BorderLayout.NORTH);
JMenuBar mb = new JMenuBar();

JMenu file1 = new JMenu("file");
item1 = new JMenuItem("open");
item = new JMenuItem("quit");



public void actionPerformed(ActionEvent event) {

jfc = new JFileChooser(".");
result = jfc.showOpenDialog(frame);
filename = jfc.getSelectedFile().getName();
file = new File(filename);
path = file.getAbsolutePath();
obj = new Filereaderclass();
String a = obj.getinfo(path);

if(result == jfc.APPROVE_OPTION)


label.setText("selection cancelled");

} //ends if

}// ends ap
public static void main(String args[]) {
new Menu();
}//ends main
} //ends class
[ April 02, 2002: Message edited by: david mohr ]
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears you are mixing Swing and AWT which should be avoided. AWT components are heavyweight and are always drawn on top of lightweight components (Swing). Try using a JTextArea instead of a TextArea, and in general, stick to components that start with a J (Swing).
david mohr
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Randy,
I have spent the last 5 hours trying to figure that one out, thank you very much.
David mohr
The moustache of a titan! The ad of a flea:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!