Re: Bringing one JInternalFrame to the front of the JDesktopPane

2004-02-18 Thread Brian Gagne
Calling just the desktop manager method only does part of the job and
leaves the state inconsistent.
This code should fix your problem:  pnButtons.add(new JButton(new AbstractAction("Open 1"){ public void actionPerformed(ActionEvent arg0) {  try { ifr1.setIcon(false); ifr1.setSelected(true); } catch( java.beans.PropertyVetoException e ) {}
  ifr1.toFront(); } })); pnButtons.add(new JButton(new AbstractAction("Open 2"){ public void actionPerformed(ActionEvent arg0) {  try { ifr2.setIcon(false);
 ifr2.setSelected(true); } catch( java.beans.PropertyVetoException e ) {}  ifr2.toFront(); } }));[EMAIL PROTECTED] wrote:
I'm using one JDesktopPane in my project and I need to set oneJInternalFrame in front of all the other and selected. Until know this isthe better I can do. If the JInternalFrame is iconifyed this don't work. Iknow this must be a very simple thing to do but I don't find how. import java.awt.event.ActionEvent;import javax.swing.AbstractAction;import javax.swing.JButton;import javax.swing.JDesktopPane;import javax.swing.JFrame;import javax.swing.JInternalFrame;import javax.swing.JPanel;import javax.swing.JSplitPane;public class Test {public static void main(String[] args) {JFrame frm = new JFrame();JSplitPane spn = new JSplitPane();JPanel pnButtons = new JPanel();final JDesktopPane dsk = new JDesktopPane(); final JInternalFrame ifr1 = newJInternalFrame("1",true,true,true,true);final
 JInternalFrame ifr2 = newJInternalFrame("2",true,true,true,true); pnButtons.add(new JButton(new AbstractAction("Open 1"){public void actionPerformed(ActionEvent arg0) {dsk.getDesktopManager().deiconifyFrame(ifr1);ifr1.hide();ifr1.show();}}));pnButtons.add(new JButton(new AbstractAction("Open 2"){public void actionPerformed(ActionEvent arg0) {dsk.getDesktopManager().deiconifyFrame(ifr2);ifr2.hide();ifr2.show();}}));dsk.add(ifr1);ifr1.pack();ifr1.setSize(200,100);ifr1.show();dsk.add(ifr2);ifr2.pack();ifr2.setSize(200,100);ifr2.show();spn.setLeftComponent(pnButtons);spn.setRightComponent(dsk);frm.setContentPane(spn);frm.setSize(800, 600);frm.show();}}___Advanced-swing mailing list[EMAIL PROTECTED]http://eos.dk/mailman/listinfo/advanced-swing
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

RE: Bringing one JInternalFrame to the front of the JDesktopPane

2004-02-18 Thread Marcos . Rebelo
Thanks, seems to be perfect. 
 
In the end of this work I shall write a book called Tips for real dummy
programmers like me.
 
Thanks
Marcos

-Original Message-
From: Brian Gagne [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 18, 2004 5:19 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Bringing one JInternalFrame to the front of the JDesktopPane


Calling just the desktop manager method only does part of the job and

leaves the state inconsistent.
This code should fix your problem:
   pnButtons.add(new JButton(new AbstractAction(Open 1){
public void actionPerformed(ActionEvent arg0) {

  try
  {
  ifr1.setIcon(false);
  ifr1.setSelected(true);
  } catch( java.beans.PropertyVetoException e ) {}
 

 
  ifr1.toFront();
}
}));
pnButtons.add(new JButton(new AbstractAction(Open 2){
public void actionPerformed(ActionEvent arg0) {
  
try
{
  ifr2.setIcon(false);
 

 ifr2.setSelected(true);
} catch( java.beans.PropertyVetoException e ) {}

ifr2.toFront();
}
}));


[EMAIL PROTECTED] wrote: 

I'm using one JDesktopPane in my project and I need to set one
JInternalFrame in front of all the other and selected. Until know this is
the better I can do. If the JInternalFrame is iconifyed this don't work. I
know this must be a very simple thing to do but I don't find how. 


import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class Test {

public static void main(String[] args) {
JFrame frm = new JFrame();
JSplitPane spn = new JSplitPane();
JPanel pnButtons = new JPanel();
final JDesktopPane dsk = new JDesktopPane(); 
final JInternalFrame ifr1 = new
JInternalFrame(1,true,true,true,true);
final JInternalFrame ifr2 = new
JInternalFrame(2,true,true,true,true); 

pnButtons.add(new JButton(new AbstractAction(Open 1){
public void actionPerformed(ActionEvent arg0) {
dsk.getDesktopManager().deiconifyFrame(ifr1);
ifr1.hide();
ifr1.show();
}
}));

pnButtons.add(new JButton(new AbstractAction(Open 2){
public void actionPerformed(ActionEvent arg0) {
dsk.getDesktopManager().deiconifyFrame(ifr2);
ifr2.hide();
ifr2.show();
}
}));


dsk.add(ifr1);
ifr1.pack();
ifr1.setSize(200,100);
ifr1.show();

dsk.add(ifr2);
ifr2.pack();
ifr2.setSize(200,100);
ifr2.show();

spn.setLeftComponent(pnButtons);
spn.setRightComponent(dsk);
frm.setContentPane(spn);
frm.setSize(800, 600);
frm.show();
}
}
___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



  _  

Do you Yahoo!?
Yahoo!
http://us.rd.yahoo.com/mailtag_us/*http://antispam.yahoo.com/tools?tool=1
Mail SpamGuard - Read only the mail you want. 

___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing