Link to home
Start Free TrialLog in
Avatar of akoifman
akoifman

asked on

JDateTimeChooser?

Hi,

I need a GUI widget to choose date and time.  Can you point me to one?

Thanks,

Alex.
ASKER CERTIFIED SOLUTION
Avatar of stalefish
stalefish

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akoifman
akoifman

ASKER

Hi,

What about a Time widget.  

Thanks for the Date widget.

Alex.
I've search all over and can't seem to find one. Unless you want to pay money for a jClass package : http://www.klgroup.com/jclass/field/index.html

They do have somethng for time, but I think its pretty crappy.

Should be easy enough to design though. Something along the lines of:

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

public class TimeChooserPanel extends JPanel{
      private final static String[] AMPM = {"A.M.", "P.M."};
      private JComboBox hour, minute, ampm;
      
      public TimeChooserPanel(){
            super();
            create();
      }
      
      public void create(){
            hour = new JComboBox();
            minute = new JComboBox();
            ampm = new JComboBox(AMPM);
            for(int i = 1; i<12; i++) hour.addItem(Integer.toString(i));
            for(int i = 0; i<59; i++) minute.addItem(Integer.toString(i));
            this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            this.add(hour);
            this.add(minute);
            this.add(ampm);
      }

}