Need some help guys not cross posting this time.
Ok here is my code:
import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.*; import java.io.*; import javax.swing.filechooser.FileFilter; import java.awt.*; public class Hashnain extends JFrame{ JMenuBar menuBar; JMenu menu; JMenuItem menuItem1; JMenuItem menuItem2; JMenuItem menuItem3; JFileChooser c = new JFileChooser(); public Hashnain(){ super("The title"); setLayout(new FlowLayout()); //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("Guide"); menuItem1 = new JMenuItem("Guide"); menuItem2 = new JMenuItem("About"); menuItem3 = new JMenuItem("Exit"); menu.add(menuItem1); menu.add(menuItem2); menu.add(menuItem3); add(menu); menuBar.add(menu); add(menuBar); thehandler handler = new thehandler(); menuItem1.addActionListener(handler); menuItem2.addActionListener(handler); menuItem3.addActionListener(handler); } private class thehandler implements ActionListener{ public void actionPerformed(ActionEvent event){ String string = ""; if(event.getSource()==menuItem3) System.exit(0); // Demonstrate "Open" dialog: if(event.getSource()==menuItem1) { JFrame frame = new JFrame("click"); JLabel bf= new JLabel("This application allow users to communicate securely.All the coding is written in Java language."); frame.add(bf); frame.setVisible(true); frame.setSize(400,400); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setText("This is a simple Image steganography application which allows user to send and receive messages embedded inside images.The user is able to choose the image he wants and the program tells if this image will suit the text or not"); // Define a keyword attribute // Add some text frame.add(textPane); } } } } Main class import javax.swing.JFrame; public class Fish { public static void main(String[] args){ Hashnain bucky = new Hashnain(); bucky.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bucky.setSize(350, 100); bucky.setVisible(true); } }
The problem is when you click on the "Guide" menu item there appears a new frame but I have also added a JLabel to the frame which does not appear.
Please check my code where am I doing wrong ?
Thanks a ton in advance.