Questions tagged [javax.swing.timer]
34 questions
1
vote
3 answers
TimerTask runs just once
I have a task named timer:
timer.schedule(new task1(), 1000*minutes);
The task:
class task1 extends TimerTask {
@Override
public void run()
{
try {
task();
} catch (SAXException ex) {
…

Barak
- 97
- 1
- 6
0
votes
3 answers
Enable to stop timer
I have an application that I want to refresh screen in some periods.User will select a task in combo, if job is active task, a timer will be started.So only one timer exists.
I am trying to stop timer when a new task is selected from combo.Here is…

user725455
- 465
- 10
- 36
0
votes
2 answers
JFrame not showing up properly when called from ActionListener
public class Start extends JFrame{
public static void main(String...s){
Start obj = new Start();
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
obj.setBounds(100,100,300,300);
JPanel main = new JPanel();
obj.add(main);
…

Sameer Gupta
- 15
- 4
0
votes
0 answers
periodic update of JLabel using javax.swing.timer is not stable (fluctuating)
I want to update a JLabel with a constant rate of about 300ms. Currently I am using the following code section to do this:
class setLabel {
PdfHandler PdfHandling = new PdfHandler(pdfName);//as the name implies, this object is to handle pdf's
…

TheDude
- 168
- 10
0
votes
0 answers
How to get a method to wait until the timer code has executed?
public void highlightThisText(){
int delay = 1000;
ActionListener tp = new ActionListener(){
public void actionPerformed(ActionEvent ae){
try{
System.out.println();
…

Tommot15
- 1
- 1
0
votes
0 answers
Drawing ProgressBar using Graphics2D
I wanted to make a custom countdown timer that looks like this.
When the countdown starts, I like the green bar to deplete and change color as certain percentage is reached. (Ex. 50% = Orange and 25% = Red)
I got the countdown code down but I do not…

Karyuu Ouji
- 314
- 3
- 13
0
votes
1 answer
"Cannot resolve symbol" in some of the javax.swing.Timer methods in IntelliJ IDEA
I have been searching for a couple hours now and can't seem to find an answer on this.
I import javax.swing.* so that i can use Timer in my program, but while Timer is imported and seem to be functioning, other methods that Timer has cannot be…

Deest
- 1
0
votes
2 answers
Java gui countdown
I need to make a GUI where a worker enters a station (a spot on the panel) and stays there for a set amount of seconds, shown in a countdown about the workers head (so, once the workers moves to the spot, the station's label shows 3s -> 2s -> 1s and…

user3622688
- 61
- 1
- 8
0
votes
1 answer
Refresh jTextField following a timer
I'm working on an assignment for Java subject. I'm using NetBean IDE. My assignment requests me to make a word game. The game I'm designing involves a timer with delay of 1000 ms. The timer decrements a variable from 30 to 0. The timer itself is…

loosecontroi
- 3
- 2
0
votes
1 answer
Timer Issue in Java - Time not Stopping when setRepeat(false) is set
I'm hoping someone could help me fix this issue that I'm having with timers. When timer.start() is run, the timer starts. however, it seems to repeat endlessly.
I just need the timer to execute once. How can I achieve this if…

user3633639
- 19
- 2
0
votes
1 answer
move a ball one after another
I am writing a code of game bean machine(Galton box), its mechanism that one ball fall and move randomly until it get to one of the slots (randomly) and then another ball comes doing the same thing and so on, the problem is that all balls fall at…

Engineer
- 75
- 9
0
votes
1 answer
repeating animation using java.swingTimer
I am writing the code of Game bean machine (Galton box) using animated graphics.
I am using swing.Timer to make the red ball move, by letting the Timer object take an ActionListener.
Here is the output:
The red ball here is moving randomly :…

Engineer
- 75
- 9
0
votes
2 answers
Using a Java Timer in a Quiz
I am currently creating a quiz. After each question is answered, I want the user to have a 15 second break until the next question is displayed. I also want the user to have the option to choose to proceed to the next question before the time runs…

JavaPr0grammer
- 9
- 1
- 4
0
votes
1 answer
javax.swing.timer subtracts as much as I click on start button
First of all hi! This is my first post on stackoverflow! This is my second attempt to program something in Java and the first ever attempt with a gui.
I'm actually having 2 problems. The first being the program and the second understanding a part of…

BinaryCode64
- 3
- 2
0
votes
1 answer
Undesirable repaint of a JPanel when dynamically updated
I have a window that dynamically updates the buffered image set on a JPanel using javax.swing.Timer
Everything works as expected but every time I invoke the dynamic update there seems to be another buffered image displayed below the currently…

Synex
- 207
- 6
- 18