0

There are 3 Frames 1st Frame is used to Display the Jlist and Create a New Report and 2nd Frame is used for giving Report Name and Type and 3rd Frame is used to write the report I want to Store the Report Name and Type from 2nd Frame in JList in 1st Frame and when we click on that Report that 3rd Frame should open with the Saved Report

import java.awt.Container;
import javax.swing.JOptionPane;
import java.awt.event.*;
import javax.swing.*;
public class Reports extends JFrame implements ActionListener {
    JMenuBar menubar;
    JMenu menu1,menu2,menu3,menu4;
    JMenuItem menuitem1,menuitem2,menuitem3,menuitem4;
    String r_Name,r_Written;
    JLabel label;
    JTable list;


    public Reports(){
        super("Reports");
        menub();
        setSize(500, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(null);
        setResizable(false);
        setVisible(true);
    }

    public void menub(){
        menubar = new JMenuBar();
        menu1 = new JMenu("File");
        menuitem1 = new JMenuItem("New");
        menuitem1.addActionListener(this);
        menu1.add(menuitem1);

        menuitem2 = new JMenuItem("Open");
        menu1.add(menuitem2);
        menuitem2.addActionListener(this);

        menu1.addSeparator();

        menuitem3 = new JMenuItem("Quit");
        menu1.add(menuitem3);
        menuitem3.addActionListener(this);
        menu2 = new JMenu("Edit");



        menubar.add(menu1);
        menubar.add(menu2);

        setJMenuBar(menubar);
    }



    public void actionPerformed(ActionEvent e){
        if(e.getSource()==menuitem1){
        newmenu obj = new newmenu();//Take Report Name and Report Type and then Open up a Frame just like a Notepad 
            }
        else if(e.getSource()==menuitem2){

        }
        else if(e.getSource()==menuitem3){
            System.exit(0);
        }


    }

    public static void main(String args[]){
        Reports obj = new Reports();
    }

}
Rishabh Rawat
  • 849
  • 6
  • 11
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Jul 12 '15 at 14:16
  • 1
    It is likely the 2nd frame should be in a modal dialog and the content of the third frame in one card of a `CardLayout` in frame 1 that also has a card for the (original) content of frame 1. – Andrew Thompson Jul 12 '15 at 14:18
  • BTW - what is your question? Note that 'How do I achieve the requirement?' is 'too broad' for SO. – Andrew Thompson Jul 12 '15 at 14:19
  • I want to save the text written in 3rd frame in JList created in 1st frame – Rishabh Rawat Jul 12 '15 at 14:24
  • If the question is *"How to save the text written in 3rd frame in JList created in 1st frame?"* then please [edit that into the question](http://stackoverflow.com/posts/31368637/edit). – Andrew Thompson Jul 12 '15 at 14:28
  • BTW - the '3rd frame' part of that explanation conflicts with the current text in the question, which suggests it is the 2nd frame. Since communicating technical problems in writing only and (often) across translations from another language to English, it is important to ensure the details are as accurate as possible. **Triple check** everything that is written. – Andrew Thompson Jul 12 '15 at 14:31
  • I Replaced the 2nd Frame in to a modal dialog as you said But how to save that text in JList in 1st Frame – Rishabh Rawat Jul 12 '15 at 14:40
  • 1
    For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example) or [SSCCE](http://www.sscce.org/) (Short, Self Contained, Correct Example) of your current code with list and table and trim all the other stuff (like menu bars). – Andrew Thompson Jul 12 '15 at 15:15

0 Answers0