Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.*;
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic