Can this time converter be written more efficiently? I'm new to Java, and I would like to know.

main
----

```
import javax.swing.JFrame;

public class main {
        public static void main(String[] args) {
    window wn = new window();
        wn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        wn.setSize(275, 170);
        wn.setVisible(true);
    }
}

```

time
----

```
public class time {
    private int hour;
    private int minute;
    private String ampm;

    public void setTime(int h, int m, String t) {
        hour = ((h>=0 && h<=24) ? h : 0);
        minute = ((m>=0 && m<=60) ? m : 0);
        ampm = t;
    }

    public String to24h() {
        if (ampm == "PM") {
            hour += 12;
        }
        return String.format("%02d:%02d", hour, minute);
    }
}

```

window
------

```
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;

@SuppressWarnings("serial")
public class window extends JFrame {

    private JLabel label;
    private JTextField hours;
    private JTextField minutes;
    private JTextField output;
    private JButton twelve_button;
    public time timeConvert = new time();
    int tHours;
    int tMinutes;
    private String[] times = {"AM", "PM"};
    private JComboBox combo;
    String tAMPM;

    public window() {
        super("Time Converter");
        setLayout(new FlowLayout());

        label = new JLabel("Time");
        add(label);

        hours = new JTextField(2);
        add(hours);

        label = new JLabel(":");
        add(label);

        minutes = new JTextField(2);
        add(minutes);

        combo = new JComboBox(times);
        add(combo);

        twelve_button = new JButton("Convert to 24 hours");
        add(twelve_button);

        output = new JTextField(10);
        output.setEditable(false);
        add(output);

        label = new JLabel("It's my 'hello world' of java development!");
        add(label);

        label = new JLabel("by jackwilsdon");
        add(label);

        theHandler handler = new theHandler();

        hours.addActionListener(handler);
        minutes.addActionListener(handler);
        twelve_button.addActionListener(handler);
    }

    private class theHandler implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            if (event.getSource() == twelve_button) {
                if (hours.getText() != null && minutes.getText() != null) {
                    try {
                        tHours = Integer.parseInt(hours.getText());
                        tMinutes = Integer.parseInt(minutes.getText());
                        tAMPM = (String)combo.getSelectedItem();
                        timeConvert.setTime(tHours, tMinutes, tAMPM);
                        if (tHours > 12) {
                            output.setText("Please enter a 12 hour number!");
                        } else if (tMinutes > 60) {
                            output.setText("Please enter a 12 hour number!");
                        } else {
                            output.setText(timeConvert.to24h());
                        }
                    }
                    catch(NumberFormatException nFE) {
                        output.setText("Please enter a number!");
                    }
                }
            }
        }
    }
}

```