Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.java.gui

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2006, 10:42 PM
Kova
Guest
 
Posts: n/a
Default JSpinner and date / time

Hello.
After strugeling through APIs and official tutorials I finally though I
understand the thing, but nooooo... I'm trying to make my spinner spin
from 00:00 to 59:59 (mm:ss) with seconds increasing by 1. Can anybody
tell me why stuff below dosen't work? I've run out of patience for
testing and reading over and over. Thank you.

------------------------------------------
import java.util.*;
import javax.swing.*;

public class TFrame extends JFrame {
public TFrame() {
super("TEST");
setDefaultCloseOperation(EXIT_ON_CLOSE);

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
Date startDate = calendar.getTime();
calendar.add(Calendar.MINUTE, 60);
Date maxDate = calendar.getTime();
JSpinner spinner = new JSpinner(new SpinnerDateModel(startDate,
startDate, maxDate, Calendar.SECOND));
spinner.setEditor(new JSpinner.DateEditor(spinner, "mm:ss"));

add(spinner);
setBounds(0,0,200,100);
setVisible(true);
}

public static void main(String[] args) {
new TFrame();
}

} // end of class
------------------------------------------
....dosen't work, spiner is always at 00:00.

--
Kova
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 05-02-2006, 10:39 AM
Michael Dunn
Guest
 
Posts: n/a
Default Re: JSpinner and date / time


"Kova" <kova1337@REMOVEgmail.com> wrote in message news:e362rh$p53$1@ss408.t-com.hr...
> Hello.
> After strugeling through APIs and official tutorials I finally though I understand the thing, but
> nooooo... I'm trying to make my spinner spin from 00:00 to 59:59 (mm:ss) with seconds increasing
> by 1. Can anybody tell me why stuff below dosen't work? I've run out of patience for testing and
> reading over and over. Thank you.
>
> ------------------------------------------
> import java.util.*;
> import javax.swing.*;
>
> public class TFrame extends JFrame {
> public TFrame() {
> super("TEST");
> setDefaultCloseOperation(EXIT_ON_CLOSE);
>
> Calendar calendar = Calendar.getInstance();
> calendar.set(Calendar.SECOND, 0);
> calendar.set(Calendar.MINUTE, 0);
> Date startDate = calendar.getTime();
> calendar.add(Calendar.MINUTE, 60);
> Date maxDate = calendar.getTime();
> JSpinner spinner = new JSpinner(new SpinnerDateModel(startDate,
> startDate, maxDate, Calendar.SECOND));
> spinner.setEditor(new JSpinner.DateEditor(spinner, "mm:ss"));
> add(spinner);
> setBounds(0,0,200,100);
> setVisible(true);
> }
>
> public static void main(String[] args) {
> new TFrame();
> }
>
> } // end of class
> ------------------------------------------
> ...dosen't work, spiner is always at 00:00.



The SpinnerDateModel changed after about 1.4.0
it now has a mind of it's own

change to null start/end arguments, and the +/- buttons work
new SpinnerDateModel(startDate,null, null, Calendar.SECOND)
it will now go from 00:00 to 59:59 then with a +, it will roll-over to 00:00

but the next problem is that Calendar.SECOND will be ignored as the field to +/-
it will default to the left-most displayed field - year, day, minute, whatever
place your cursor anywhere after the : and the Calendar.SECOND field will +/-

a bit more info here
http://bugs.sun.com/bugdatabase/view...bug_id=6321570


Reply With Quote
  #3 (permalink)  
Old 05-02-2006, 12:19 PM
Kova
Guest
 
Posts: n/a
Default Re: JSpinner and date / time

Michael Dunn wrote:
> The SpinnerDateModel changed after about 1.4.0
> it now has a mind of it's own
>
> change to null start/end arguments, and the +/- buttons work
> new SpinnerDateModel(startDate,null, null, Calendar.SECOND)
> it will now go from 00:00 to 59:59 then with a +, it will roll-over to 00:00
>
> but the next problem is that Calendar.SECOND will be ignored as the field to +/-
> it will default to the left-most displayed field - year, day, minute, whatever
> place your cursor anywhere after the : and the Calendar.SECOND field will +/-
>
> a bit more info here
> http://bugs.sun.com/bugdatabase/view...bug_id=6321570


ah jeez.. tnx.
I think I'll just connect 2 spinners with numbers and display it in one
spinner model to simulate mm:ss.

--
Kova
Reply With Quote
 
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 05:58 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.