Results 1 to 13 of 13
  1. #1
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Pause the program and Start

    Hello i need two methods.
    One that stops the running of the programm and the second that continue the running of the program.
    I need to stop the running in the main method in theJavaAppDemos.java something like in the line 19.
    An continue running the program of the JavaAppDemos.java by pressing the jButton1 from the NewJFrame.java class. something like in the line 68.

    JavaAppDemos.java
    Java Code:
    public class JavaAppDemos {  
    
    public static void PauseP(){
    
    //Some thing that pause the programm
    }
    
    public static void ContinueP(){
    
    //Some thing that continue the programm
    }
      
    public static void main(String[] args) { 
    
    NewJFrame jf = new NewJFrame();  
      jf.setVisible(true);
    
    /////////////////here to pause the program//////////////////////////////////////////////////////////
    PauseP();
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    ////other code
    }
    NewJFrame.java
    Java Code:
    public class NewJFrame extends javax.swing.JFrame {  
      
        public NewJFrame() {  
            initComponents();  
        }  
      
        @SuppressWarnings("unchecked")  
        // <editor-fold defaultstate="collapsed" desc="Generated Code">  
        private void initComponents() {  
      
            jPanel1 = new javax.swing.JPanel();  
            jButton1 = new javax.swing.JButton();  
      
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
      
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);  
            jPanel1.setLayout(jPanel1Layout);  
            jPanel1Layout.setHorizontalGroup(  
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGap(0, 100, Short.MAX_VALUE)  
            );  
            jPanel1Layout.setVerticalGroup(  
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGap(0, 100, Short.MAX_VALUE)  
            );  
      
            jButton1.setText("jButton1");  
            jButton1.addMouseListener(new java.awt.event.MouseAdapter() {  
                public void mouseClicked(java.awt.event.MouseEvent evt) {  
                    jButton1MouseClicked(evt);  
                }  
            });  
            jButton1.addActionListener(new java.awt.event.ActionListener() {  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    jButton1ActionPerformed(evt);  
                }  
            });  
      
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
            getContentPane().setLayout(layout);  
            layout.setHorizontalGroup(  
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGroup(layout.createSequentialGroup()  
                    .addContainerGap(172, Short.MAX_VALUE)  
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()  
                            .addComponent(jButton1)  
                            .addGap(85, 85, 85))  
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()  
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
                            .addGap(128, 128, 128))))  
            );  
            layout.setVerticalGroup(  
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()  
                    .addGap(29, 29, 29)  
                    .addComponent(jButton1)  
                    .addGap(65, 65, 65)  
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
                    .addContainerGap(83, Short.MAX_VALUE))  
            );  
      
            pack();  
        }// </editor-fold>  
      
        private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                        
      ////////here to continue the program////////////////////////////////////////////////////////////////////////////////////////////////
    JavaAppDemos.ContinueP();
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            
        }                                       
       
        // Variables declaration - do not modify  
        private javax.swing.JButton jButton1;  
        public static javax.swing.JPanel jPanel1;  
        // End of variables declaration  
    }

    Thank You in Advanced

    Ki_ha1984

  2. #2
    OllyHal is offline Member
    Join Date
    Feb 2012
    Posts
    25
    Rep Power
    0

    Default Re: Pause the program and Start

    Why don't you continue your code in the actionlistener of the button?

  3. #3
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    Quote Originally Posted by OllyHal View Post
    Why don't you continue your code in the actionlistener of the button?
    How can i do this??

  4. #4
    OllyHal is offline Member
    Join Date
    Feb 2012
    Posts
    25
    Rep Power
    0

    Default Re: Pause the program and Start

    Java Code:
    jButton1.addActionListener(new java.awt.event.ActionListener() {  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    jButton1ActionPerformed(evt);  
    //Insert Code here
                }  
            });

  5. #5
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    Quote Originally Posted by OllyHal View Post
    Java Code:
    jButton1.addActionListener(new java.awt.event.ActionListener() {  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    jButton1ActionPerformed(evt);  
    //Insert Code here
                }  
            });
    Where i have ti put this ????

    An my 2 methods Pausep() and ContinueP() are empty whar i have to put inside of them???

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Pause the program and Start

    Quote Originally Posted by ki_ha1984 View Post
    An my 2 methods Pausep() and ContinueP() are empty whar i have to put inside of them???
    That depends on what process you're trying to pause, about which you haven't told us anything.

    Are you by any chance looking for a modal dialog?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    I am trying to pause the main method (runtime) after calling the Jframe, to fill a text area and the continue the run of the tha runtime by pressing the Jbutton1.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Pause the program and Start

    Quote Originally Posted by ki_ha1984 View Post
    I am trying to pause the main method (runtime) after calling the Jframe, to fill a text area and the continue the run of the tha runtime by pressing the Jbutton1.
    That tells us exactly nothing. To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    Did you look up what a modal dialog is?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    I dont know why you dont understand.
    I need to pause the sunning of my code in the JavaAppDemos.java class in the line 19.
    And after pressing the jbutton1 of the NewJFrame.java class, the code of the JavaAppDemos.java to continue to run from the line 20.

    I need a example or any other kind of help.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Pause the program and Start

    Quote Originally Posted by ki_ha1984 View Post
    I dont know why you dont understand.
    Because your explanation is nowhere near adequate. I don't know why you can't post a SSCCE, unless it's that you don't want better help sooner..

    Quote Originally Posted by ki_ha1984 View Post
    I need to pause the sunning of my code in the JavaAppDemos.java class in the line 19.
    And after pressing the jbutton1 of the NewJFrame.java class, the code of the JavaAppDemos.java to continue to run from the line 20.

    I need a example or any other kind of help.
    You've already been given 'any other kind of help'. Twice. I'm willing to bet that you still don't know what a modal dialog is. For that matter, have you even taken the trouble to find out what a SSCCE is?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    if i understand the SSCCE is the code of my project is it right ?????

    Sorry about my English it is not perfect, but i try.
    Last edited by ki_ha1984; 04-17-2012 at 08:06 PM.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Pause the program and Start

    I gave you a link to a page that tells you everything you need to know about what an SSCCE is. No, it most certainly is not 'the code of [your] project'

    How far along are you with understanding what a modal dialog is?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  13. #13
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Pause the program and Start

    Why should be a dialog window ???
    It is simple Jframe with buttons, jpanel and textareas.

    ck

Similar Threads

  1. how to start a .jar from another Java program?
    By theChameleon in forum New To Java
    Replies: 0
    Last Post: 10-27-2011, 09:11 PM
  2. Where should I start with this program?
    By westbakke in forum New To Java
    Replies: 3
    Last Post: 06-02-2011, 05:16 AM
  3. Replies: 1
    Last Post: 01-18-2011, 07:27 PM
  4. Need help on how to start off with a program
    By javanoobie in forum New To Java
    Replies: 6
    Last Post: 03-24-2009, 12:42 AM
  5. Replies: 5
    Last Post: 03-20-2009, 11:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •