Results 1 to 19 of 19

Thread: Timer trouble

  1. #1
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default Timer trouble

    Hi guys.

    I'm struggling with a simple timer. I know I have successfully used a timer before but suddenly I get a run time error. Can't get the stupid thing to work.

    Java Code:
    import javax.swing.Timer
    
    public class myClass extends JFrame, implements ActionListener
    {
    	private javax.swing.Timer timer
    	
    	public myClass()
    	{
    		timer = new javax.swing.Timer(1000,this);
    		timer.addActionListener(this);
    		timer.start();
    	}
    	
    	public void actionPerformed(Actionevent e)
    	{
    		if(e.getSource()==timer)
    			// perform task
    	}
    Thanks in advance.
    Sorry, I only speak machine language. Yes or a No?:confused:

  2. #2
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    And what is your error?
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  3. #3
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Don't know if this will help

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    Running it in NetBeans.
    Sorry, I only speak machine language. Yes or a No?:confused:

  4. #4
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    The error you get when compiling is very important. It actually tells you what is wrong. A null pointer exception means you are failing to initialize something.

    However, I'm not very experienced with java yet. I've only started learning it about a month ago. Im afraid I can't tell you what you're not initializing.

    (Also, if I'm wrong. Someone please correct me.)
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  5. #5
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Thanks but I need someone with a bit more experience.

    I constructed this class with a GUI editor.
    I tried the same basic code on another JFrame class I had manually coded and it works.
    Does anyone have a theory to why this may be?
    Last edited by BiteMuncher; 04-19-2011 at 08:08 PM.
    Sorry, I only speak machine language. Yes or a No?:confused:

  6. #6
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    If you have a working segment of code, and the same segment goes into another and doesn't work then why don't you compare the differences between the two segments of code?

    You didn't say that they were identical pieces of code so you may find your error is more simple than you think. That's what I would do.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  7. #7
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Sorry Dark but I don't think you are helping to solve my problem. I have at least 8 months experience in java verses your 1 month.
    I have isolated the code above, the rest of the code is irrelevant. The only difference is the problematic class was generated by a NetBeans GUI editor and the class that functions correctly was a JFrame I coded manually. Both construct, add listeners and call the start() method in the constructor methods and both use the getSource() method of the ActionEvent class exactly the same within the actionPerformed method.
    Sorry, I only speak machine language. Yes or a No?:confused:

  8. #8
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Well if you copy pasted that snippet from your code, you have a ton of syntax errors.

    However, if you didn't. I suggest a SSCCE.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  9. #9
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    ??
    It was not copied and pasted. If I copy and paste all my code you'll be reading through pages of code. The idea is to post the relevant code only.
    Sorry, I only speak machine language. Yes or a No?:confused:

  10. #10
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    An SSCCE is where you post only the parts of the code that matter. You don't need all of your code to make a a compileable code that recreates your error.

    Here you go: Short, Self Contained, Correct Example
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  11. #11
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    That's exactly what I did...............
    Sorry, I only speak machine language. Yes or a No?:confused:

  12. #12
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Obviously not, the snippet you posted does not compile. You're missing a bunch of ;'s, you have commas where they don't belong and when I copied that into my IDE it read lined the majority of the code.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  13. #13
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    I am posting a new thread as we have drifted from the subject.
    Appreciate your effort Dark but please do not reply unless you may be of assistance.
    Sorry, I only speak machine language. Yes or a No?:confused:

  14. #14
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Sorry I misunderstood the purpose.
    Re-posting:
    I did not remove all the unnecessary components as it would cause too many errors.
    Please click the "Heads" button at the bottom to start the timer

    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;

    public class StartUpFrame extends javax.swing.JFrame implements ActionListener
    {


    private javax.swing.Timer tmr;

    /** Creates new form StartUpFrame */
    public StartUpFrame() {

    initComponents();
    setDefaultCloseOperation(javax.swing.JFrame.EXIT_O N_CLOSE);
    selectBtn.addActionListener(this);
    toggleCoin.addActionListener(this);

    tmr = new javax.swing.Timer(200,this);
    tmr.addActionListener(this);






    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    TabbedPane = new javax.swing.JTabbedPane();
    ctPanel = new javax.swing.JPanel();
    tossHeadingLbl = new javax.swing.JLabel();
    jSeparator3 = new javax.swing.JSeparator();
    pReportLbl = new javax.swing.JLabel();
    jSeparator2 = new javax.swing.JSeparator();
    selectBtn = new javax.swing.JButton();
    jSeparator4 = new javax.swing.JSeparator();
    prHeadingLbl1 = new javax.swing.JLabel();
    selHeadingLbl = new javax.swing.JLabel();
    toggleCoin = new javax.swing.JToggleButton();
    coin = new javax.swing.JButton();
    logPanel = new javax.swing.JPanel();
    jSeparator1 = new javax.swing.JSeparator();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    setBounds(new java.awt.Rectangle(200, 200, 400, 400));

    TabbedPane.setBackground(new java.awt.Color(204, 204, 255));

    tossHeadingLbl.setFont(new java.awt.Font("Arial", 1, 14));
    tossHeadingLbl.setText("Coin Toss:");
    tossHeadingLbl.setAlignmentX(1.0F);
    tossHeadingLbl.setAlignmentY(1.0F);
    tossHeadingLbl.setAutoscrolls(true);

    jSeparator3.setAlignmentY(0.1F);

    pReportLbl.setFont(new java.awt.Font("MS Reference Sans Serif", 0, 12));
    pReportLbl.setForeground(new java.awt.Color(0, 0, 102));
    pReportLbl.setText("The pitch is even with good bounce");

    selectBtn.setFont(new java.awt.Font("Arial", 1, 12));
    selectBtn.setForeground(new java.awt.Color(0, 0, 102));
    selectBtn.setText("Proceed");

    prHeadingLbl1.setFont(new java.awt.Font("Arial", 1, 14));
    prHeadingLbl1.setText("Pitch Report:");
    prHeadingLbl1.setAlignmentX(1.0F);
    prHeadingLbl1.setAlignmentY(1.0F);
    prHeadingLbl1.setAutoscrolls(true);

    selHeadingLbl.setFont(new java.awt.Font("Arial", 1, 14));
    selHeadingLbl.setText("Team Selection");
    selHeadingLbl.setAlignmentX(1.0F);
    selHeadingLbl.setAlignmentY(1.0F);
    selHeadingLbl.setAutoscrolls(true);

    toggleCoin.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    toggleCoin.setForeground(new java.awt.Color(0, 0, 102));
    toggleCoin.setText("Heads");

    coin.setBackground(new java.awt.Color(204, 204, 204));
    coin.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
    coin.setForeground(new java.awt.Color(0, 0, 102));

    javax.swing.GroupLayout ctPanelLayout = new javax.swing.GroupLayout(ctPanel);
    ctPanel.setLayout(ctPanelLayout);
    ctPanelLayout.setHorizontalGroup(
    ctPanelLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGap(20, 20, 20)
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(prHeadingLbl1)
    .addComponent(pReportLbl))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 99, Short.MAX_VALUE))
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGap(10, 10, 10)
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(selectBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(selHeadingLbl)))))
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGap(10, 10, 10)
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addComponent(toggleCoin)
    .addGap(52, 52, 52)
    .addComponent(coin, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(tossHeadingLbl))
    .addGap(88, 88, 88)))))
    .addContainerGap())
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
    .addContainerGap()))
    );
    ctPanelLayout.setVerticalGroup(
    ctPanelLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGap(44, 44, 44)
    .addComponent(prHeadingLbl1)
    .addGap(18, 18, 18)
    .addComponent(pReportLbl)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(selHeadingLbl)
    .addGap(20, 20, 20)
    .addComponent(selectBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.TRAILING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addComponent(tossHeadingLbl)
    .addGap(27, 27, 27)
    .addComponent(toggleCoin, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(coin, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(89, Short.MAX_VALUE))
    .addGroup(ctPanelLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(ctPanelLayout.createSequentialGroup()
    .addGap(33, 33, 33)
    .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(360, Short.MAX_VALUE)))
    );

    TabbedPane.addTab("Coin Toss", ctPanel);

    javax.swing.GroupLayout logPanelLayout = new javax.swing.GroupLayout(logPanel);
    logPanel.setLayout(logPanelLayout);
    logPanelLayout.setHorizontalGroup(
    logPanelLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(logPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
    .addContainerGap())
    );
    logPanelLayout.setVerticalGroup(
    logPanelLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(logPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(382, Short.MAX_VALUE))
    );

    TabbedPane.addTab("Log Standings", logPanel);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(TabbedPane)
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(TabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new StartUpFrame().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JTabbedPane TabbedPane;
    private javax.swing.JButton coin;
    private javax.swing.JPanel ctPanel;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JPanel logPanel;
    private javax.swing.JLabel pReportLbl;
    private javax.swing.JLabel prHeadingLbl1;
    private javax.swing.JLabel selHeadingLbl;
    private javax.swing.JButton selectBtn;
    private javax.swing.JToggleButton toggleCoin;
    private javax.swing.JLabel tossHeadingLbl;
    // End of variables declaration



    public void actionPerformed(ActionEvent e)
    {


    if(e.getSource()==tmr)
    {
    JOptionPane.showMessageDialog(null,"Timer test");
    tmr.stop();

    }

    }


    }
    Sorry, I only speak machine language. Yes or a No?:confused:

  15. #15
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Sorry I misunderstood the purpose.
    Re-posting:
    I did not remove all the unnecessary components as it would cause too many errors.
    Please click the "Heads" button at the bottom to start the timer
    Java Code:
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class StartUpFrame extends javax.swing.JFrame implements ActionListener
    {
    
        
        private javax.swing.Timer tmr;
       
        /** Creates new form StartUpFrame */
        public StartUpFrame() {
    
            initComponents();
            setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
            selectBtn.addActionListener(this);
            toggleCoin.addActionListener(this);
    
            tmr = new javax.swing.Timer(200,this);
            tmr.addActionListener(this);
    
    
            
                
           
    
        }
       
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
    
            TabbedPane = new javax.swing.JTabbedPane();
            ctPanel = new javax.swing.JPanel();
            tossHeadingLbl = new javax.swing.JLabel();
            jSeparator3 = new javax.swing.JSeparator();
            pReportLbl = new javax.swing.JLabel();
            jSeparator2 = new javax.swing.JSeparator();
            selectBtn = new javax.swing.JButton();
            jSeparator4 = new javax.swing.JSeparator();
            prHeadingLbl1 = new javax.swing.JLabel();
            selHeadingLbl = new javax.swing.JLabel();
            toggleCoin = new javax.swing.JToggleButton();
            coin = new javax.swing.JButton();
            logPanel = new javax.swing.JPanel();
            jSeparator1 = new javax.swing.JSeparator();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setBounds(new java.awt.Rectangle(200, 200, 400, 400));
    
            TabbedPane.setBackground(new java.awt.Color(204, 204, 255));
    
            tossHeadingLbl.setFont(new java.awt.Font("Arial", 1, 14));
            tossHeadingLbl.setText("Coin Toss:");
            tossHeadingLbl.setAlignmentX(1.0F);
            tossHeadingLbl.setAlignmentY(1.0F);
            tossHeadingLbl.setAutoscrolls(true);
    
            jSeparator3.setAlignmentY(0.1F);
    
            pReportLbl.setFont(new java.awt.Font("MS Reference Sans Serif", 0, 12));
            pReportLbl.setForeground(new java.awt.Color(0, 0, 102));
            pReportLbl.setText("The pitch is even with good bounce");
    
            selectBtn.setFont(new java.awt.Font("Arial", 1, 12));
            selectBtn.setForeground(new java.awt.Color(0, 0, 102));
            selectBtn.setText("Proceed");
    
            prHeadingLbl1.setFont(new java.awt.Font("Arial", 1, 14));
            prHeadingLbl1.setText("Pitch Report:");
            prHeadingLbl1.setAlignmentX(1.0F);
            prHeadingLbl1.setAlignmentY(1.0F);
            prHeadingLbl1.setAutoscrolls(true);
    
            selHeadingLbl.setFont(new java.awt.Font("Arial", 1, 14));
            selHeadingLbl.setText("Team Selection");
            selHeadingLbl.setAlignmentX(1.0F);
            selHeadingLbl.setAlignmentY(1.0F);
            selHeadingLbl.setAutoscrolls(true);
    
            toggleCoin.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
            toggleCoin.setForeground(new java.awt.Color(0, 0, 102));
            toggleCoin.setText("Heads");
    
            coin.setBackground(new java.awt.Color(204, 204, 204));
            coin.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
            coin.setForeground(new java.awt.Color(0, 0, 102));
    
            javax.swing.GroupLayout ctPanelLayout = new javax.swing.GroupLayout(ctPanel);
            ctPanel.setLayout(ctPanelLayout);
            ctPanelLayout.setHorizontalGroup(
                ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(ctPanelLayout.createSequentialGroup()
                    .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(ctPanelLayout.createSequentialGroup()
                            .addGap(20, 20, 20)
                            .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(prHeadingLbl1)
                                .addComponent(pReportLbl))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE))
                        .addGroup(ctPanelLayout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)
                                .addGroup(ctPanelLayout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(selectBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(selHeadingLbl)))))
                        .addGroup(ctPanelLayout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)
                                .addGroup(ctPanelLayout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(ctPanelLayout.createSequentialGroup()
                                            .addComponent(toggleCoin)
                                            .addGap(52, 52, 52)
                                            .addComponent(coin, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(tossHeadingLbl))
                                    .addGap(88, 88, 88)))))
                    .addContainerGap())
                .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ctPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                        .addContainerGap()))
            );
            ctPanelLayout.setVerticalGroup(
                ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(ctPanelLayout.createSequentialGroup()
                    .addGap(44, 44, 44)
                    .addComponent(prHeadingLbl1)
                    .addGap(18, 18, 18)
                    .addComponent(pReportLbl)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(selHeadingLbl)
                    .addGap(20, 20, 20)
                    .addComponent(selectBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(ctPanelLayout.createSequentialGroup()
                            .addComponent(tossHeadingLbl)
                            .addGap(27, 27, 27)
                            .addComponent(toggleCoin, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(coin, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(89, Short.MAX_VALUE))
                .addGroup(ctPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ctPanelLayout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(360, Short.MAX_VALUE)))
            );
    
            TabbedPane.addTab("Coin Toss", ctPanel);
    
            javax.swing.GroupLayout logPanelLayout = new javax.swing.GroupLayout(logPanel);
            logPanel.setLayout(logPanelLayout);
            logPanelLayout.setHorizontalGroup(
                logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(logPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                    .addContainerGap())
            );
            logPanelLayout.setVerticalGroup(
                logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(logPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(382, Short.MAX_VALUE))
            );
    
            TabbedPane.addTab("Log Standings", logPanel);
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(TabbedPane)
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(TabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>
    
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new StartUpFrame().setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify
        private javax.swing.JTabbedPane TabbedPane;
        private javax.swing.JButton coin;
        private javax.swing.JPanel ctPanel;
        private javax.swing.JSeparator jSeparator1;
        private javax.swing.JSeparator jSeparator2;
        private javax.swing.JSeparator jSeparator3;
        private javax.swing.JSeparator jSeparator4;
        private javax.swing.JPanel logPanel;
        private javax.swing.JLabel pReportLbl;
        private javax.swing.JLabel prHeadingLbl1;
        private javax.swing.JLabel selHeadingLbl;
        private javax.swing.JButton selectBtn;
        private javax.swing.JToggleButton toggleCoin;
        private javax.swing.JLabel tossHeadingLbl;
        // End of variables declaration
    
        
    
        public void actionPerformed(ActionEvent e)
        {
           
            if(e.getSource()==toggleCoin)
            {
                if(toggleCoin.getText().compareTo("Heads")==0)
                    toggleCoin.setText("Tails");
                else
                    toggleCoin.setText("Heads");
    
                tmr.start();
            }
    
            if(e.getSource()==tmr)
            {
                JOptionPane.showMessageDialog(null,"Timer test");
                tmr.stop();
                
            }
    
        }
    
        
    }
    Last edited by BiteMuncher; 04-19-2011 at 10:48 PM.
    Sorry, I only speak machine language. Yes or a No?:confused:

  16. #16
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  17. #17
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    I apologize, if you read the previous thread you will understand why I started a this one.
    Any way to remove the previous thread?
    Sorry, I only speak machine language. Yes or a No?:confused:

  18. #18
    BiteMuncher's Avatar
    BiteMuncher is offline Member
    Join Date
    Feb 2011
    Location
    South Africa
    Posts
    51
    Rep Power
    0

    Default

    Mixed it up this the old thread.
    Sorry, I only speak machine language. Yes or a No?:confused:

  19. #19
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Stopping a Timer from Inside the timer
    By krishnan in forum Java Applets
    Replies: 2
    Last Post: 10-04-2010, 11:15 PM
  2. Timer
    By Learning Java in forum New To Java
    Replies: 3
    Last Post: 08-11-2010, 12:18 PM
  3. EJB Timer
    By mrjunsy in forum Advanced Java
    Replies: 0
    Last Post: 08-22-2008, 04:09 PM
  4. EJB Timer
    By mrjunsy in forum New To Java
    Replies: 0
    Last Post: 08-04-2008, 06:47 PM
  5. Replies: 0
    Last Post: 04-04-2008, 02:46 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
  •