Displaying The Result in Frame

Trying to create GUI in two frames, left and right. Left frame is used to display forms for user to fill data and the right frame is used to display the result. 

What was done is as follows: 

When user click "Simulation" on the menu, program will display forms to be filled by users (there are six forms) in the left frame. At the last form when the user click "Calculate", the program should display the result on the right frame and the form on the left frame must be still visible. But what happen so far is that the result is still displayed in the left frame. 

I am using jsp and servlet. Each jsp page call servlet and this servlet call another jsp page. And the last servlet call view.jsp to view the data. I do not know how to direct view.jsp to be displayed in the right frame. 

Are there any other ways to solve that problem (eg. without using frame)? Can I view the result on the right frame each time the user move to other form (jsp page)? 

Answer:

You can use an anchor tag with target as the name of the right iframe. 

Example as follows. 

<iframe name="left_frame" id="left_frame"> 

<iframe name="right_frame" id="right_frame"> 

Instead of submit button in form, you can use anchor tag as follows:

<a href="view.jsp" target="right_frame" onclick="appendFormParameters();"> 

To send form parameters to view,jsp use a javascript function to append the parameters to href attribute of the anchor. 

Or:

To create multiple frames using Java Swing:

Java Swing provides the utility to show frame within another frame by providing the class JInternalFrame. With the use of this class, you can display a JFrame-like window within another window. It provides many of the features of a native frame, including dragging, closing, becoming an icon, resizing, title display, and support for a menu bar. Here we are going to display four internal frame on the JFrame. 

Here is the code:

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

public class MultipleFrames {

        JDesktopPane desk;

        JInternalFrame frame1, frame2, frame3, frame4;

        JFrame frame;

        public static void main(String[] args) {

                MultipleFrames d = new MultipleFrames();

        }

        public MultipleFrames() {

                frame = new JFrame("Multiple Frames");

                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                desk = new JDesktopPane();

                frame1 = new JInternalFrame("Frame1", true, true, true, true);

                frame1.setBounds(20, 200, 150, 100);

                frame1.setVisible(true);

                frame2 = new JInternalFrame("Frame2", true, true, true, true);

                frame2.setBounds(20, 140, 150, 100);

                frame2.setVisible(true);

                frame3 = new JInternalFrame("Frame3", true, true, true, true);

                frame3.setBounds(20, 80, 150, 100);

                frame3.setVisible(true);

                frame4 = new JInternalFrame("Frame4", true, true, true, true);

                frame4.setBounds(20, 20, 150, 100);

                frame4.setVisible(true);

                desk.add(frame1);

                desk.add(frame2);

                desk.add(frame3);

                desk.add(frame4);

                frame.add(desk);

                frame.setSize(400, 400);

                frame.setVisible(true);

        }

}

Java Tips

See also
Detect That JFrame Is Being Resized

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.