Results 1 to 19 of 19
Thread: Timer trouble
- 04-19-2011, 07:42 PM #1
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.
Thanks in advance.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 }Sorry, I only speak machine language. Yes or a No?:confused:
- 04-19-2011, 07:43 PM #2
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.
- 04-19-2011, 07:49 PM #3
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:
- 04-19-2011, 07:58 PM #4
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.
- 04-19-2011, 08:06 PM #5
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:
- 04-19-2011, 08:10 PM #6
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.
- 04-19-2011, 08:20 PM #7
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:
- 04-19-2011, 08:31 PM #8
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.
- 04-19-2011, 08:34 PM #9
??
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:
- 04-19-2011, 08:37 PM #10
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.
- 04-19-2011, 08:38 PM #11
That's exactly what I did...............
Sorry, I only speak machine language. Yes or a No?:confused:
- 04-19-2011, 08:41 PM #12
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.
- 04-19-2011, 08:44 PM #13
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:
- 04-19-2011, 10:44 PM #14
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:
- 04-19-2011, 10:45 PM #15
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:
-
Do you have two threads in this forum with the same question?
- 04-19-2011, 10:54 PM #17
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:
- 04-19-2011, 10:55 PM #18
Mixed it up this the old thread.
Sorry, I only speak machine language. Yes or a No?:confused:
-
If all active discussion is to be in the other thread, let me lock this one.
Similar Threads
-
Stopping a Timer from Inside the timer
By krishnan in forum Java AppletsReplies: 2Last Post: 10-04-2010, 11:15 PM -
Timer
By Learning Java in forum New To JavaReplies: 3Last Post: 08-11-2010, 12:18 PM -
EJB Timer
By mrjunsy in forum Advanced JavaReplies: 0Last Post: 08-22-2008, 04:09 PM -
EJB Timer
By mrjunsy in forum New To JavaReplies: 0Last Post: 08-04-2008, 06:47 PM -
How to cancel an individual timer in spite of canceling whole timer
By Java Tip in forum java.utilReplies: 0Last Post: 04-04-2008, 02:46 PM


LinkBack URL
About LinkBacks

Bookmarks