BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

example for app using multiple internal frames

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE
View previous topic :: View next topic  
Author Message
Wayne Harper
Guest





PostPosted: Wed Dec 03, 2003 4:34 pm    Post subject: example for app using multiple internal frames Reply with quote



I cant find anywhere info on how to use the jbuilder ide to create an
app that uses internal frames (JInternalFrame).
I created an app with a JFrame, then created an internal frame, but
then what?
could someone point me in the right direction please?
Thanks
-Wayne
Back to top
Daljit Sehmbi
Guest





PostPosted: Wed Dec 03, 2003 6:11 pm    Post subject: Re: example for app using multiple internal frames Reply with quote



Look in the following directory for the SwingSet2 sample code:-

cd JBuilder<version>jdk<version>demojfcSwingSet2

Daljit

"Wayne Harper" <wayne_a_harper (AT) not_coldmail (DOT) com> wrote

Quote:
I cant find anywhere info on how to use the jbuilder ide to create an
app that uses internal frames (JInternalFrame).
I created an app with a JFrame, then created an internal frame, but
then what?
could someone point me in the right direction please?
Thanks
-Wayne



Back to top
Wayne Harper
Guest





PostPosted: Wed Dec 03, 2003 6:25 pm    Post subject: Re: example for app using multiple internal frames Reply with quote



"Daljit Sehmbi" <newsgroupsATsehmbiDOTnet> wrote:

Quote:
Look in the following directory for the SwingSet2 sample code:-

cd JBuilder<version>jdk<version>demojfcSwingSet2

Daljit



Thanks, but I'm wondering how to do this with Jbuilder generated code.
The JInternalFrame in that example cant be modified in the Jbuilder
IDE visual design.

-Wayne

Back to top
Daljit Sehmbi
Guest





PostPosted: Wed Dec 03, 2003 7:57 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

As far as I am aware no support in JBuilder to develop or manipulate
JInternalFrame in the Visual Designer.

Daljit
"Wayne Harper" <wayne_a_harper (AT) not_coldmail (DOT) com> wrote

Quote:
"Daljit Sehmbi" <newsgroupsATsehmbiDOTnet> wrote:

Look in the following directory for the SwingSet2 sample code:-

cd JBuilder<version>jdk<version>demojfcSwingSet2

Daljit



Thanks, but I'm wondering how to do this with Jbuilder generated code.
The JInternalFrame in that example cant be modified in the Jbuilder
IDE visual design.

-Wayne



Back to top
Wayne Harper
Guest





PostPosted: Wed Dec 03, 2003 8:22 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

"Daljit Sehmbi" <newsgroupsATsehmbiDOTnet> wrote:

Quote:
As far as I am aware no support in JBuilder to develop or manipulate
JInternalFrame in the Visual Designer.


you can create a JInternalFrame by File-New-Frame , then select
JInternaFrame as the base class. you can then edit the JInternalFrame
in the visual designer.
But how do you incorporate it into your project? I want to make an MDI
type application.
I have been working on this a long time, if anyone has done this
please let me know how.

-Wayne

Back to top
pNichols
Guest





PostPosted: Thu Dec 04, 2003 2:18 am    Post subject: Re: example for app using multiple internal frames Reply with quote

Wayne Harper wrote:

Quote:
"Daljit Sehmbi" <newsgroupsATsehmbiDOTnet> wrote:

As far as I am aware no support in JBuilder to develop or manipulate
JInternalFrame in the Visual Designer.


you can create a JInternalFrame by File-New-Frame , then select
JInternaFrame as the base class. you can then edit the JInternalFrame
in the visual designer.
But how do you incorporate it into your project? I want to make an MDI
type application.
I have been working on this a long time, if anyone has done this
please let me know how.

-Wayne

Look at the sample below. I have not included the Data Module (since it is
proprietary for the application), but the other code will work (i comment
out the specific calls to the DataModule).
Note this is a long post. If you create a new Project in JBuilder and use
this code, it should work. You will need to add a new DataModule, called DM
and palce it in a package as indicated below before compiling.
ShowResultsTable will not work unless you reset the QueryDataSet used for
the JdbTable.

Note: To visually create a JDesktopPane, ou can add a JPanel to your
MainFrame, and rename it in code as per the notes in the code below.


MainClass

package net.clc.pace.license.app;

import javax.swing.UIManager;
import java.awt.*;

/**
* <p>Title: Pace Social Studies and Sicence License Updater</p>
* <p>Description: See Title</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Computer Logic Company</p>
* @author Dr. Paul W. Nichols
* @version 1.0
*/

public class MainClass {
boolean packFrame = false;

//Construct the application
public MainClass() {
MainFrame frame = new MainFrame();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their
layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}

//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new MainClass();
}
}

MainFrame

package net.clc.pace.license.app;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.clc.pace.license.dm.*;

/**
* <p>Title: Pace Social Studies and Sicence License Updater</p>
* <p>Description: See Title</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Computer Logic Company</p>
* @author Dr. Paul W. Nichols
* @version 1.0
*/

public class MainFrame extends JFrame {
JPanel contentPane;
ImageIcon image1;
ImageIcon image2;
ImageIcon image3;
JLabel statusBar = new JLabel();
private JMenuBar jMenuBar1 = new JMenuBar();
private JMenu jMenu1 = new JMenu();
private JMenuItem jMenuItem1 = new JMenuItem();
private JMenuItem jMenuItem2 = new JMenuItem();
private JMenuItem jMenuItem3 = new JMenuItem();
private JMenu jMenu2 = new JMenu();
private JMenuItem jMenuItem4 = new JMenuItem();
private DM dm;
/* Change the JPanel to JDesktop pane as per the code below. This is how to
create a JDesktopPane in the designer..

private JPanel dtpdMain= new JPanel();

*See how we changed the class type below */

private JDesktopPane jdtpMain = new JDesktopPane();

//---------end changes

private BorderLayout borderLayout1 = new BorderLayout();
private BorderLayout borderLayout2 = new BorderLayout();

//Construct the frame
public MainFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}

//Component initialization
private void jbInit() throws Exception {
image1 = new
ImageIcon(net.clc.pace.license.app.MainFrame.class.getResource("openFile.png"));
image2 = new
ImageIcon(net.clc.pace.license.app.MainFrame.class.getResource("closeFile.png"));
image3 = new
ImageIcon(net.clc.pace.license.app.MainFrame.class.getResource("help.png"));
contentPane = (JPanel) this.getContentPane();
dm = net.clc.pace.license.dm.DM.getDataModule();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(640, 480));
this.setTitle("Update Pace License for Social Studies and Science");
statusBar.setText(" ");
jMenu1.setText("File");
jMenuItem1.setText("Run License Nbrs");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem1_actionPerformed(e);
}
});
jMenuItem2.setText("Show Results");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem2_actionPerformed(e);
}
});
jMenuItem3.setText("Exit");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem3_actionPerformed(e);
}
});
jMenu2.setText("About");
jMenuItem4.setText("About");
jdtpMain.setBounds(new Rectangle(3, 18, 480, 308));
jdtpMain.setLayout(borderLayout2);
contentPane.add(statusBar, BorderLayout.SOUTH);

/* Make sure that the jdtpMain looks like the code below. */
contentPane.add(jdtpMain, BorderLayout.CENTER);

jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenu1.add(jMenuItem1);
jMenu1.add(jMenuItem2);
jMenu1.add(jMenuItem3);
jMenu2.add(jMenuItem4);
contentPane.add(jMenuBar1,BorderLayout.NORTH);
}

//File | Exit action performed
public void jMenuFileExit_actionPerformed(ActionEvent e) {
System.exit(0);
}

//Help | About action performed
public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
}

//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}

void jMenuItem1_actionPerformed(ActionEvent e) {
boolean pass=false;
try {
this.statusBar.setText("Please wait, updating");
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
//pass=dm.someCall();
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

}
catch (Exception ex) {
pass=false;
JOptionPane.showMessageDialog(this,ex.getMessage());
}
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
if (pass) {
JOptionPane.showMessageDialog(this, "Update of new license numbers was
successful");
}
}
/* This is how you call an JInternalFrame and make it the child of the
partent container, which is JDesktopPane. */

void jMenuItem2_actionPerformed(ActionEvent e) {
ShowResultsTable srt= new ShowResultsTable();
this.jdtpMain.add(srt,BorderLayout.CENTER);
srt.setVisible(true);
}

void jMenuItem3_actionPerformed(ActionEvent e) {
if(JOptionPane.showConfirmDialog(this,"Are you sure you want to exit?",
"Exit License Update",JOptionPane.YES_NO_OPTION)==
JOptionPane.YES_OPTION) {
System.exit(0);
}
}
}


The JInternalFrame (called ShowResultsTable)

package net.clc.pace.license.app;

import java.awt.*;
import javax.swing.*;
import net.clc.pace.license.dm.*;
import com.borland.dbswing.*;

/**
* <p>Title: Pace Social Studies and Sicence License Updater</p>
* <p>Description: See Title</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Computer Logic Company</p>
* @author Dr. Paul W. Nichols
* @version 1.0
*/

public class ShowResultsTable extends JInternalFrame {
private JPanel jPanel1 = new JPanel();
private DM dm;
private TableScrollPane tspResults = new TableScrollPane();
private JdbTable jdbtResults = new JdbTable();
private JPanel jPanel2 = new JPanel();
private JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
private BorderLayout borderLayout1 = new BorderLayout();
private BorderLayout borderLayout2 = new BorderLayout();

public ShowResultsTable() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
dm = net.clc.pace.license.dm.DM.getDataModule();
this.setClosable(true);
this.setTitle("Results of License Update");
this.getContentPane().setLayout(borderLayout2);
jPanel1.setLayout(borderLayout1);
/* You will need to create your own Database connection and QueryDataSet
and set the properties to the jdbtResults for this form to display
*/
jdbtResults.setDataSet(dm.getSomeQuery());
/* Make sure that you change the jdbNavToolBar.setDataSet to reflect your
QueryDataSet in dm as well */

jdbNavToolBar1.setDataSet(dm.getSomeQuery());
//-------End changes
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(tspResults, BorderLayout.CENTER);
tspResults.getViewport().add(jdbtResults, null);
this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
jPanel2.add(jdbNavToolBar1, null);
this.jdbtResults.getDataSet().refresh();
}
}

That should do it for you..





Back to top
Wayne Harper
Guest





PostPosted: Thu Dec 04, 2003 4:26 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

pNichols <paul (AT) computer-logic (DOT) net> wrote:
Quote:

That should do it for you..



yes - thanks very much for the detailed example- Ive got the internal
frame working now.
Odd that the JDesktopPane isnt on the component palette.
It looks like there is a lot more to an MDI app than I thought...
-Wayne



Back to top
pNichols
Guest





PostPosted: Fri Dec 05, 2003 5:32 am    Post subject: Re: example for app using multiple internal frames Reply with quote

Wayne Harper wrote:

Quote:
pNichols <paul (AT) computer-logic (DOT) net> wrote:

That should do it for you..



yes - thanks very much for the detailed example- Ive got the internal
frame working now.
Odd that the JDesktopPane isnt on the component palette.
It looks like there is a lot more to an MDI app than I thought...
-Wayne

Not really... I gave you the full example to make sure that you could verify
it would work <G>


Back to top
Wayne Harper
Guest





PostPosted: Fri Dec 05, 2003 3:21 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

pNichols <paul (AT) computer-logic (DOT) net> wrote:

Quote:
It looks like there is a lot more to an MDI app than I thought...
-Wayne

Not really... I gave you the full example to make sure that you could verify
it would work

yes & thanks again for that. but for example I dont see how menus for
each internal frame would be managed.
I have only done windows desktop apps up to now but would like to be
able to use Java if possible.

-Wayne


Back to top
pNichols
Guest





PostPosted: Fri Dec 05, 2003 9:10 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

Wayne Harper wrote:

Quote:
pNichols <paul (AT) computer-logic (DOT) net> wrote:

It looks like there is a lot more to an MDI app than I thought...
-Wayne

Not really... I gave you the full example to make sure that you could
verify it would work
yes & thanks again for that. but for example I dont see how menus for
each internal frame would be managed.
I have only done windows desktop apps up to now but would like to be
able to use Java if possible.

-Wayne
You do not create Menus for each Internal Frame, no more than you would for

a MDI Windows application. Your main frame should contain your Main Menu
which would be used throughout the Application.

Calling a Internal Frame from your Menu works precisely as per the code
snippet in the example.

void jMenuItem2_actionPerformed(ActionEvent e) {
ShowResultsTable srt= new ShowResultsTable();
this.jdtpMain.add(srt,BorderLayout.CENTER);
srt.setVisible(true);
}

If you had other Menus for other calls to Internal frames (and no doubt you
would), you would simply call the next internal Frame

void jMenu3_actionPerformed(ActionEvent e) {
ShowOtherInternalFrame soif= new ShowOtherInternalFrame();
this.dtpMain.add(soif,BorderLayout.CENTER);
soif.setVisbile(true);
}

Of course what I normally do is create a single instance of a JInternalFrame
and create separate panels that I will call from my JInternalFrame class.
That why, I can do a counter on the number of instances on ,y
JInternalframe class and control which Window is active. A little more work
invovled of course, when you do this, but once done, you have reusable
classes.



Back to top
Wayne Harper
Guest





PostPosted: Fri Dec 05, 2003 11:25 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

pNichols <paul (AT) computer-logic (DOT) net> wrote:

Quote:
You do not create Menus for each Internal Frame, no more than you would for
a MDI Windows application. Your main frame should contain your Main Menu
which would be used throughout the Application.


Well actually in a windows mdi application the child windows do have
their own menus that appear in the main menu as each window gets
focus. that is what Im wondering how to accomplish.
Also a window menu to switch between windows etc.
If java apps have a different paradigm I am open to learning it.
-Wayne



Back to top
Lori M Olson (TeamB)
Guest





PostPosted: Tue Dec 09, 2003 5:18 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

Wayne Harper wrote:
Quote:
Well actually in a windows mdi application the child windows do have
their own menus that appear in the main menu as each window gets
focus. that is what Im wondering how to accomplish.
Also a window menu to switch between windows etc.
If java apps have a different paradigm I am open to learning it.
-Wayne



Just a note here. I've been doing a lot of work on "Usability" in
applications over the past year. The paradigm of having menus change
when different internal frames are given focus is considered a *very
bad* in terms of usability. Just because a particular idiom is in
common use, does not mean it's a good idea.

Consistency is good. There's lots of information on usability out
there. One good place to start is http://www.foruse.com

--

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html


Back to top
Ken Warner
Guest





PostPosted: Tue Dec 09, 2003 5:48 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

Hi Lori,

A comment --

Different frame -- different menu is kindof the Mac app/finder
UI paradigm. Some people like it -- some people don't

It can be made to work (that is, be usable) if the user's sense
of context is maintained. How that is done is up to the needs
of the user population and the requirements of the application and
the capability of the hardware and of course the skills of the
UI designer.

Lastly, users adapt to various UI's. The flexibility and adaptability
of the cognitive process is not to be under estimated. The variety
of valid UI designs are about the same as the variety of opinions
about it...

Lori M Olson (TeamB) wrote:
Quote:
Wayne Harper wrote:

Well actually in a windows mdi application the child windows do have
their own menus that appear in the main menu as each window gets
focus. that is what Im wondering how to accomplish.
Also a window menu to switch between windows etc.
If java apps have a different paradigm I am open to learning it.
-Wayne



Just a note here. I've been doing a lot of work on "Usability" in
applications over the past year. The paradigm of having menus change
when different internal frames are given focus is considered a *very
bad* in terms of usability. Just because a particular idiom is in
common use, does not mean it's a good idea.

Consistency is good. There's lots of information on usability out
there. One good place to start is http://www.foruse.com



Back to top
Wayne Harper
Guest





PostPosted: Tue Dec 09, 2003 9:02 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

I found this article quite useful:

Create a scrollable virtual desktop in Swing
http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jscroll.html?

also discovered a JInternalFrame can have a menu although doesnt seem
to work in designer.

-Wayne
Back to top
Wayne Harper
Guest





PostPosted: Wed Dec 10, 2003 2:58 pm    Post subject: Re: example for app using multiple internal frames Reply with quote

Wayne Harper <wayne_a_harper (AT) not_coldmail (DOT) com> wrote:

Quote:
I found this article quite useful:

Create a scrollable virtual desktop in Swing
http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jscroll.html?



the above has since become an open source project
http://sourceforge.net/projects/jscroll/

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.