Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 26th, 2007, 06:43 PM
xreddawg909x xreddawg909x is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 91 xreddawg909x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 27 m 20 sec
Reputation Power: 4
Child/parent frames

i have a parent frame that opens up a child frame when a JButton is clicked

Code:
JFrame frame = new JFrame("Confirm");
    JComponent y = new NewJPanel();
    y.setBackground(Color.BLACK);
    y.setForeground(Color.YELLOW);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_C  LOSE);
    frame.setContentPane(y);
    frame.setSize(300, 400);
    frame.setVisible(true);
    
    
    frame.requestFocus();    
//the frame opens up a pre-existing Jpanel 



now i have "dispose on close " so there is no "cascading effect" when the child is closed by the "x" at the top right of t he window, but i need the jframe to close by pressing "exit" button on the child JFrame without putting System.exit(0) which closes parent and child regardless of "Dispose_on_close"
is there any command i can place for the actionPerformed for "exit button" which doesnt cause the cascading effect

also is there any way to disable/enable buttons on the parent JFrame from the child JFrame? for example: when the "exit button" is clicked on the Child frame it would enable another button on the parent JFrame ?

Reply With Quote
  #2  
Old July 26th, 2007, 10:05 PM
xreddawg909x xreddawg909x is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 91 xreddawg909x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 27 m 20 sec
Reputation Power: 4
ok so i scrapped the whole child frame trying to close itself
but now i have a new dilemma, how would i have the parent window close the child window when a jbutton is pressed ?
i Set up the open child jframe like this -

Code:
//Button Actions
private class EventHandler implements ActionListener 
{        
   
public void actionPerformed(ActionEvent evt) 
{
           //created child jframe here so buttons may access the objects "frame" & "y"
           JFrame frame = new JFrame("Confirm"); 
           JComponent y = new NewJPanel();
           
           frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_C  LOSE);
           
           if(evt.getSource() == RefiButton)
           {
               reason = Refi;
           }
           else if(evt.getSource() == PayCredButton)
           {
               reason = PayCredit;
           }
           else if(evt.getSource() == GetCashButton)
           {
               reason = Cash;
           }
           else if(evt.getSource()== ShortSaleButton)
           {
               reason = Sale;
           }
           else if(evt.getSource() == ForeClosedButton)
           {
               reason = ForeClose;
           }
           else if(evt.getSource() == SellPropButton)
           {
               reason = Sell;
           }
           else if(evt.getSource() == BuyInvestButton)
           {
               reason = Invest;
           }    
           else if(evt.getSource() == BuyNoDownButton)
           {
               reason = Buy;
           }
    
        if(evt.getSource() == Clear)
        {
            restart();
            frame.dispose();                  
        }    
        
        if(evt.getSource()== Confirm)
        {
           
           y.setBackground(Color.BLACK);
           y.setForeground(Color.YELLOW);
           frame.requestFocus();           
           frame.add(y);
           frame.setSize(300, 400);
           frame.setVisible(true);   
           No.setEnabled(true);   
           Yes.setEnabled(true);
        }    
        
        if(evt.getSource() == Submit )
        {            
            create_file(FName, LName, Address,cit,sta,zip,Email,phoneNumber,reason);  
            JOptionPane.showMessageDialog(null,"Thank You!\n You will be contacted shortly about your request."); 
            frame.dispose();
            restart();
        } 
        
        if(evt.getSource() == No)
        {
              //for somer reason child jframe does not close when this         jbutton is clicked
             frame.dispose();  
             No.setEnabled(false);
             Yes.setEnabled(false);
             Submit.setEnabled(false);
        }    
          
        if(evt.getSource()== Yes)
        {
            //for somer reason child jframe does not close when this         button is clicked
            frame.dispose();
                       
            Submit.setEnabled(true);
        }            
        
}


}





Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Child/parent frames


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT