Example usage for javax.swing.text DateFormatter DateFormatter

List of usage examples for javax.swing.text DateFormatter DateFormatter

Introduction

In this page you can find the example usage for javax.swing.text DateFormatter DateFormatter.

Prototype

public DateFormatter(DateFormat format) 

Source Link

Document

Returns a DateFormatter configured with the specified Format instance.

Usage

From source file:Main.java

public static void main(String[] args) {
    DateFormatter[] formatters = new DateFormatter[] { new DateFormatter(new SimpleDateFormat("dd.MM.yyyy")),
            new DateFormatter(new SimpleDateFormat("ddMMyyyy")),
            new DateFormatter(new SimpleDateFormat("yyyy.MM.dd.")),
            new DateFormatter(new SimpleDateFormat("dd.MMM.yyyy")),
            new DateFormatter(new SimpleDateFormat("dd/MM/yyyy")) };
    MultiFormatter<DateFormatter> multiFormatter = new MultiFormatter<>(formatters);

    JFormattedTextField ftf = new JFormattedTextField(multiFormatter);
    ftf.setColumns(10);/* w w  w .  j  av a  2s  .  com*/

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(ftf);
    frame.add(new JButton("OK"));
    frame.pack();
    frame.setVisible(true);
}

From source file:DefaultFormatterFactoryDemo.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Mask Input");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("Date");

    DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd");
    DateFormatter displayFormatter = new DateFormatter(displayFormat);
    DateFormat editFormat = new SimpleDateFormat("MM/dd/yy");
    DateFormatter editFormatter = new DateFormatter(editFormat);
    DateFormat nullFormat = new SimpleDateFormat("'null'");
    DateFormatter nullFormatter = new DateFormatter(nullFormat);
    DefaultFormatterFactory factory = new DefaultFormatterFactory(displayFormatter, displayFormatter,
            editFormatter, nullFormatter);

    JFormattedTextField input = new JFormattedTextField(factory);
    input.setColumns(30);// www  .j a v  a  2s .c  o m
    JPanel panel = new JPanel();
    panel.add(label);
    panel.add(input);
    frame.add(panel, "North");

    frame.add(new JTextField(), "Center");
    frame.pack();
    frame.setVisible(true);
}

From source file:FormattedSample.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Formatted Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd");
    DateFormatter displayFormatter = new DateFormatter(displayFormat);
    DateFormat editFormat = new SimpleDateFormat("MM/dd/yy");
    DateFormatter editFormatter = new DateFormatter(editFormat);
    DefaultFormatterFactory factory = new DefaultFormatterFactory(displayFormatter, displayFormatter,
            editFormatter);/*  w  w  w  . jav  a 2s. c o m*/
    JFormattedTextField date2TextField = new JFormattedTextField(factory, new Date());
    frame.add(date2TextField, BorderLayout.NORTH);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JFormattedTextField source = (JFormattedTextField) actionEvent.getSource();
            Object value = source.getValue();
            System.out.println("Class: " + value.getClass());
            System.out.println("Value: " + value);
        }
    };
    date2TextField.addActionListener(actionListener);

    frame.add(new JTextField(), BorderLayout.SOUTH);
    frame.setSize(250, 100);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Formatted Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd");
    DateFormatter displayFormatter = new DateFormatter(displayFormat);
    DateFormat editFormat = new SimpleDateFormat("MM/dd/yy");
    DateFormatter editFormatter = new DateFormatter(editFormat);
    DefaultFormatterFactory factory = new DefaultFormatterFactory(displayFormatter, displayFormatter,
            editFormatter);/*  w  w w. java 2s  . c  om*/
    JFormattedTextField date2TextField = new JFormattedTextField(factory, new Date());
    frame.add(date2TextField, BorderLayout.NORTH);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JFormattedTextField source = (JFormattedTextField) actionEvent.getSource();
            Object value = source.getValue();
            System.out.println("Class: " + value.getClass());
            System.out.println("Value: " + value);
        }
    };
    date2TextField.addActionListener(actionListener);
    frame.add(new JTextField(), BorderLayout.SOUTH);

    frame.setSize(250, 100);
    frame.setVisible(true);
}

From source file:grafix.graficos.eixos.EixoHorizontalComLabels.java

@Override
public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) {
    try {//from  w  ww .  ja va2s. c  o  m
        long l1 = this.getMaximumDate().getTime();
        long l2 = this.getMinimumDate().getTime();
        int diasExibidos = (int) ((l1 - l2) / ref);
        if (diasExibidos == diasExibidosAnterior && ticksAnteriores != null) {
            return ticksAnteriores; // otimizacao
        } else {
            List result = new ArrayList();
            int j = 0;
            for (int i = acao.getNumeroRegistros() - 1; i >= 0; i--) {
                int n = (int) (diasExibidos / QUANTIDADE_DATAS);
                if (j++ % n == 0) {
                    result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(),
                            new DateFormatter(new SimpleDateFormat("dd/MM/yy"))
                                    .valueToString(acao.getRegistro(i).getData().getStart()),
                            TextAnchor.TOP_CENTER, TextAnchor.TOP_RIGHT, 0));
                } else {
                    result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(), "",
                            TextAnchor.TOP_CENTER, TextAnchor.TOP_RIGHT, 0));
                }
            }
            ticksAnteriores = result;
            diasExibidosAnterior = diasExibidos;
            return result;
        }
    } catch (Exception e) {
        return new ArrayList();
    }
}

From source file:com.mirth.connect.plugins.messagepruner.MessagePrunerService.java

private Trigger createTrigger(Properties properties) throws ParseException {
    Trigger trigger = null;/*from  ww w  .j  a v  a  2s.co  m*/
    String interval = PropertyLoader.getProperty(properties, "interval");

    if (interval.equals("hourly"))
        trigger = TriggerUtils.makeHourlyTrigger();
    else {
        SimpleDateFormat timeDateFormat = new SimpleDateFormat("hh:mm aa");
        DateFormatter timeFormatter = new DateFormatter(timeDateFormat);

        String time = PropertyLoader.getProperty(properties, "time");
        Date timeDate = (Date) timeFormatter.stringToValue(time);
        Calendar timeCalendar = Calendar.getInstance();
        timeCalendar.setTime(timeDate);

        if (interval.equals("daily")) {
            trigger = TriggerUtils.makeDailyTrigger(timeCalendar.get(Calendar.HOUR_OF_DAY),
                    timeCalendar.get(Calendar.MINUTE));
        } else if (interval.equals("weekly")) {
            SimpleDateFormat dayDateFormat = new SimpleDateFormat("EEEEEEEE");
            DateFormatter dayFormatter = new DateFormatter(dayDateFormat);

            String dayOfWeek = PropertyLoader.getProperty(properties, "dayOfWeek");
            Date dayDate = (Date) dayFormatter.stringToValue(dayOfWeek);
            Calendar dayCalendar = Calendar.getInstance();
            dayCalendar.setTime(dayDate);

            trigger = TriggerUtils.makeWeeklyTrigger(dayCalendar.get(Calendar.DAY_OF_WEEK),
                    timeCalendar.get(Calendar.HOUR_OF_DAY), timeCalendar.get(Calendar.MINUTE));
        } else if (interval.equals("monthly")) {
            SimpleDateFormat dayDateFormat = new SimpleDateFormat("DD");
            DateFormatter dayFormatter = new DateFormatter(dayDateFormat);

            String dayOfMonth = PropertyLoader.getProperty(properties, "dayOfMonth");
            Date dayDate = (Date) dayFormatter.stringToValue(dayOfMonth);
            Calendar dayCalendar = Calendar.getInstance();
            dayCalendar.setTime(dayDate);

            trigger = TriggerUtils.makeMonthlyTrigger(dayCalendar.get(Calendar.DAY_OF_MONTH),
                    timeCalendar.get(Calendar.HOUR_OF_DAY), timeCalendar.get(Calendar.MINUTE));
        }
    }

    trigger.setStartTime(new Date());
    trigger.setName("prunerTrigger");
    trigger.setJobName("prunerJob");
    return trigger;
}

From source file:com.jgoodies.validation.tutorial.formatted.DateExample.java

/**
 * Appends the demo rows to the given builder and returns the List of
 * formatted text fields./*from   w ww . j  a  v a  2  s  .c om*/
 * 
 * @param builder  the builder used to add components to
 * @return the List of formatted text fields
 */
private List appendDemoRows(DefaultFormBuilder builder) {
    // The Formatter is choosen by the initial value.
    JFormattedTextField defaultDateField = new JFormattedTextField(new Date());

    // The Formatter is choosen by the given Format.
    JFormattedTextField noInitialValueField = new JFormattedTextField(DateFormat.getDateInstance());

    // Uses a custom DateFormat.
    DateFormat customFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    JFormattedTextField customFormatField = new JFormattedTextField(new DateFormatter(customFormat));

    // Uses a RelativeDateFormat.
    DateFormat relativeFormat = new RelativeDateFormat();
    JFormattedTextField relativeFormatField = new JFormattedTextField(new DateFormatter(relativeFormat));

    // Uses a custom DateFormatter that allows relative input and
    // prints natural language strings.
    JFormattedTextField relativeFormatterField = new JFormattedTextField(new RelativeDateFormatter());

    // Uses a custom FormatterFactory that used different formatters
    // for the display and while editing.
    DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory(
            new RelativeDateFormatter(false, true), new RelativeDateFormatter(true, true));
    JFormattedTextField relativeFactoryField = new JFormattedTextField(formatterFactory);

    // Wraps a DateFormatter to map empty strings to null and vice versa.
    JFormattedTextField numberOrNullField = new JFormattedTextField(new EmptyDateFormatter());

    // Wraps a DateFormatter to map empty strings to -1 and vice versa.
    Date epoch = new Date(0); // January 1, 1970
    JFormattedTextField numberOrEmptyValueField = new JFormattedTextField(new EmptyDateFormatter(epoch));
    numberOrEmptyValueField.setValue(epoch);

    // Commits value on valid edit text
    DefaultFormatter formatter = new RelativeDateFormatter();
    formatter.setCommitsOnValidEdit(true);
    JFormattedTextField commitOnValidEditField = new JFormattedTextField(formatter);

    // A date field as created by the BasicComponentFactory:
    // Uses relative date input, and maps empty strings to null.
    ValueModel dateHolder = new ValueHolder();
    JFormattedTextField componentFactoryField = ExampleComponentFactory.createDateField(dateHolder);

    Format displayFormat = new DisplayFormat(DateFormat.getDateInstance());
    List fields = new LinkedList();
    fields.add(Utils.appendRow(builder, "Default", defaultDateField, displayFormat));
    fields.add(Utils.appendRow(builder, "No initial value", noInitialValueField, displayFormat));
    fields.add(Utils.appendRow(builder, "Empty <->  null", numberOrNullField, displayFormat));
    fields.add(Utils.appendRow(builder, "Empty <-> epoch", numberOrEmptyValueField, displayFormat));
    fields.add(Utils.appendRow(builder, "Short format", customFormatField, displayFormat));
    fields.add(Utils.appendRow(builder, "Relative format", relativeFormatField, displayFormat));
    fields.add(Utils.appendRow(builder, "Relative formatter", relativeFormatterField, displayFormat));
    fields.add(Utils.appendRow(builder, "Relative factory", relativeFactoryField, displayFormat));
    fields.add(Utils.appendRow(builder, "Commits on valid edit", commitOnValidEditField, displayFormat));
    fields.add(Utils.appendRow(builder, "Relative, maps null", componentFactoryField, displayFormat));

    return fields;
}

From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java

public void fillProperties(PollConnectorPropertiesInterface propertiesInterface) {
    PollConnectorProperties properties = null;

    if (propertiesInterface != null) {
        properties = propertiesInterface.getPollConnectorProperties();
    } else {/*from  w w w  . j a  va2s . com*/
        properties = new PollConnectorProperties();
    }

    String selectedPollingType = (String) scheduleTypeComboBox.getSelectedItem();

    properties.setPollOnStart(yesStartPollRadioButton.isSelected());
    if (selectedPollingType.equals(PollingType.INTERVAL.getDisplayName())) {
        properties.setPollingType(PollingType.INTERVAL);

        String type = (String) pollingFrequencyTypeComboBox.getSelectedItem();
        int frequency = NumberUtils.toInt(pollingFrequencyField.getText(), 0);
        if (type.equals(POLLING_FREQUENCY_HOURS)) {
            frequency *= 3600000;
        } else if (type.equals(POLLING_FREQUENCY_MINUTES)) {
            frequency *= 60000;
        } else if (type.equals(POLLING_FREQUENCY_SECONDS)) {
            frequency *= 1000;
        }

        properties.setPollingFrequency(frequency);
    } else if (selectedPollingType.equals(PollingType.TIME.getDisplayName())) {
        properties.setPollingType(PollingType.TIME);

        try {
            SimpleDateFormat timeDateFormat = new SimpleDateFormat("hh:mm aa");
            DateFormatter timeFormatter = new DateFormatter(timeDateFormat);
            Date timeDate = (Date) timeFormatter.stringToValue(pollingTimePicker.getDate());
            Calendar timeCalendar = Calendar.getInstance();
            timeCalendar.setTime(timeDate);

            properties.setPollingHour(timeCalendar.get(Calendar.HOUR_OF_DAY));
            properties.setPollingMinute(timeCalendar.get(Calendar.MINUTE));
        } catch (ParseException e) {
            // Do nothing since they could be manually entering in the time...
        }
    } else if (selectedPollingType.equals(PollingType.CRON.getDisplayName())) {
        properties.setPollingType(PollingType.CRON);

        List<CronProperty> cronJobs = new ArrayList<CronProperty>();

        for (int rowCount = 0; rowCount < cronJobsTable.getRowCount(); rowCount++) {
            String description = (String) cronJobsTable.getValueAt(rowCount, 1);
            String expression = (String) cronJobsTable.getValueAt(rowCount, 0);

            if (StringUtils.isNotBlank(expression)) {
                cronJobs.add(new CronProperty(description, expression));
            }
        }

        properties.setCronJobs(cronJobs);
    }

    properties.setPollConnectorPropertiesAdvanced(cachedAdvancedConnectorProperties);

    selectedPollingType = null;
    if (properties != null) {
        nextFireTimeProperties = properties.clone();
    }
}

From source file:com.pos.spatobiz.app.view.karyawan.HapusKaryawan.java

/** This method is called from within the constructor to
 * initialize the form.//from w  w w  . j ava 2  s  .  c  om
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jeniskelamin = new ButtonGroup();
    labelKode = new WhiteLabel();
    labelNama = new WhiteLabel();
    labelTanggalLahir = new WhiteLabel();
    labelAlamat = new WhiteLabel();
    textKode = new TextBoxTransfer();
    textNama = new TextBoxTransfer();
    textTanggalLahir = new DateBox();
    textAlamat = new WhiteTextArea();
    textTelepon = new TextBoxTransfer();
    labelTelepon = new WhiteLabel();
    labelEmail = new WhiteLabel();
    labelJenisKelamin = new WhiteLabel();
    labelPhoto = new WhiteLabel();
    textEmail = new TextBoxTransfer();
    radioPria = new JRadioButton();
    radioWanita = new JRadioButton();
    imageChooser = new ImageChooser();
    buttonBatal = new Button();
    buttonHapus = new Button();
    buttonCari = new Button();

    setBackground(new Color(0, 0, 0));

    labelKode.setHorizontalAlignment(SwingConstants.RIGHT);
    labelKode.setText("Kode :");

    labelNama.setHorizontalAlignment(SwingConstants.RIGHT);
    labelNama.setText("Nama :");

    labelTanggalLahir.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTanggalLahir.setText("Tanggal Lahir :");

    labelAlamat.setHorizontalAlignment(SwingConstants.RIGHT);
    labelAlamat.setText("Alamat :");

    textNama.setEnabled(false);

    textTanggalLahir.setEnabled(false);
    textTanggalLahir.setFormatterFactory(
            new DefaultFormatterFactory(new DateFormatter(DateFormat.getDateInstance(DateFormat.LONG))));
    textTanggalLahir.setPreferredSize(new Dimension(120, 24));
    textTanggalLahir.setValue(new Date());

    textAlamat.setEnabled(false);

    textTelepon.setEnabled(false);

    labelTelepon.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTelepon.setText("Telepon :");

    labelEmail.setHorizontalAlignment(SwingConstants.RIGHT);
    labelEmail.setText("Email :");

    labelJenisKelamin.setHorizontalAlignment(SwingConstants.RIGHT);
    labelJenisKelamin.setText("Jenis Kelamin :");

    labelPhoto.setHorizontalAlignment(SwingConstants.RIGHT);
    labelPhoto.setText("Photo :");

    textEmail.setEnabled(false);

    jeniskelamin.add(radioPria);
    radioPria.setFont(new Font("Tahoma", 1, 11));
    radioPria.setForeground(new Color(255, 255, 255));
    radioPria.setSelected(true);
    radioPria.setText("Pria");
    radioPria.setEnabled(false);
    radioPria.setOpaque(false);

    jeniskelamin.add(radioWanita);
    radioWanita.setFont(new Font("Tahoma", 1, 11));
    radioWanita.setForeground(new Color(255, 255, 255));
    radioWanita.setText("Wanita");
    radioWanita.setEnabled(false);
    radioWanita.setOpaque(false);

    imageChooser.setEnabled(false);

    buttonBatal.setMnemonic('B');
    buttonBatal.setText("Batal");

    buttonHapus.setMnemonic('H');
    buttonHapus.setText("Hapus");

    buttonCari.setText("Cari");

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(
                            Alignment.TRAILING, layout
                                    .createSequentialGroup().addContainerGap().addGroup(layout
                                            .createParallelGroup(Alignment.TRAILING).addGroup(layout
                                                    .createSequentialGroup().addComponent(
                                                            buttonHapus, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(
                                                            buttonBatal, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))
                                            .addGroup(layout.createSequentialGroup().addGroup(layout
                                                    .createParallelGroup(Alignment.LEADING).addGroup(layout
                                                            .createParallelGroup(Alignment.TRAILING, false)
                                                            .addComponent(labelPhoto, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelJenisKelamin, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    labelEmail, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                    .addGroup(layout
                                                            .createParallelGroup(Alignment.TRAILING, false)
                                                            .addComponent(labelTelepon,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelTanggalLahir, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelAlamat, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelNama, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    labelKode, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                                    .addPreferredGap(ComponentPlacement.RELATED)
                                                    .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                                                            .addComponent(textAlamat, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(textNama, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 552,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(textTanggalLahir, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 552,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(textTelepon, GroupLayout.DEFAULT_SIZE,
                                                                    552, Short.MAX_VALUE)
                                                            .addGroup(Alignment.LEADING, layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(radioPria)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(radioWanita))
                                                            .addComponent(
                                                                    imageChooser, Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 253,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(textEmail, GroupLayout.DEFAULT_SIZE,
                                                                    552, Short.MAX_VALUE)
                                                            .addGroup(layout.createSequentialGroup()
                                                                    .addComponent(textKode,
                                                                            GroupLayout.DEFAULT_SIZE, 488,
                                                                            Short.MAX_VALUE)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(buttonCari,
                                                                            GroupLayout.PREFERRED_SIZE,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            GroupLayout.PREFERRED_SIZE)))))
                                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonCari, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textAlamat, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelJenisKelamin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioPria).addComponent(radioWanita))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelPhoto, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(imageChooser, GroupLayout.PREFERRED_SIZE, 189, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(buttonBatal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonHapus, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
}

From source file:com.pos.spatobiz.app.view.karyawan.TambahKaryawan.java

/** This method is called from within the constructor to
 * initialize the form./*from   www.  j a v a 2 s  . c  o m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jeniskelamin = new ButtonGroup();
    labelKode = new WhiteLabel();
    labelNama = new WhiteLabel();
    labelTanggalLahir = new WhiteLabel();
    labelAlamat = new WhiteLabel();
    textKode = new TextBoxTransfer();
    textNama = new TextBoxTransfer();
    textTanggalLahir = new DateBox();
    textAlamat = new WhiteTextArea();
    errorKode = new RedLabel();
    errorNama = new RedLabel();
    errorTanggalLahir = new RedLabel();
    errorAlamat = new RedLabel();
    textTelepon = new TextBoxTransfer();
    labelTelepon = new WhiteLabel();
    labelEmail = new WhiteLabel();
    labelJenisKelamin = new WhiteLabel();
    labelPhoto = new WhiteLabel();
    textEmail = new TextBoxTransfer();
    radioPria = new JRadioButton();
    radioWanita = new JRadioButton();
    errorTelepon = new RedLabel();
    errorEmail = new RedLabel();
    imageChooser = new ImageChooser();
    buttonBatal = new Button();
    buttonTambah = new Button();

    setBackground(new Color(0, 0, 0));

    labelKode.setHorizontalAlignment(SwingConstants.RIGHT);
    labelKode.setText("Kode :");

    labelNama.setHorizontalAlignment(SwingConstants.RIGHT);
    labelNama.setText("Nama :");

    labelTanggalLahir.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTanggalLahir.setText("Tanggal Lahir :");

    labelAlamat.setHorizontalAlignment(SwingConstants.RIGHT);
    labelAlamat.setText("Alamat :");

    textTanggalLahir.setFormatterFactory(
            new DefaultFormatterFactory(new DateFormatter(DateFormat.getDateInstance(DateFormat.LONG))));
    textTanggalLahir.setPreferredSize(new Dimension(120, 24));
    textTanggalLahir.setValue(new Date());

    errorKode.setText("error kode");

    errorNama.setText("error nama");

    errorTanggalLahir.setText("error tanggal lahir");

    errorAlamat.setText("error alamat");

    labelTelepon.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTelepon.setText("Telepon :");

    labelEmail.setHorizontalAlignment(SwingConstants.RIGHT);
    labelEmail.setText("Email :");

    labelJenisKelamin.setHorizontalAlignment(SwingConstants.RIGHT);
    labelJenisKelamin.setText("Jenis Kelamin :");

    labelPhoto.setHorizontalAlignment(SwingConstants.RIGHT);
    labelPhoto.setText("Photo :");

    jeniskelamin.add(radioPria);
    radioPria.setFont(new Font("Tahoma", 1, 11)); // NOI18N
    radioPria.setForeground(new Color(255, 255, 255));
    radioPria.setSelected(true);
    radioPria.setText("Pria");
    radioPria.setOpaque(false);

    jeniskelamin.add(radioWanita);
    radioWanita.setFont(new Font("Tahoma", 1, 11));
    radioWanita.setForeground(new Color(255, 255, 255));
    radioWanita.setText("Wanita");
    radioWanita.setOpaque(false);

    errorTelepon.setText("error telepon");

    errorEmail.setText("error email");

    buttonBatal.setMnemonic('B');
    buttonBatal.setText("Batal");

    buttonTambah.setMnemonic('T');
    buttonTambah.setText("Tambah");

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
                    layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelPhoto, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelJenisKelamin, Alignment.LEADING,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelEmail, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelTelepon, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelTanggalLahir, Alignment.LEADING,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelAlamat, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelNama, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelKode, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(textAlamat, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textNama, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textTanggalLahir, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            403, Short.MAX_VALUE)
                                    .addComponent(textKode, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textTelepon, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                                    .addGroup(Alignment.LEADING,
                                            layout.createSequentialGroup().addComponent(radioPria)
                                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                                    .addComponent(radioWanita))
                                    .addComponent(imageChooser, Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                            253, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textEmail, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
                            .addGap(4, 4, 4)
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addComponent(errorKode, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorNama, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorTanggalLahir, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorAlamat, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorTelepon, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorEmail, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                    .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(buttonTambah, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(buttonBatal,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textAlamat, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelJenisKelamin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioPria).addComponent(radioWanita))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelPhoto, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(imageChooser, GroupLayout.PREFERRED_SIZE, 189, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(buttonBatal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonTambah, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
}