package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;

public final class MainPanel extends JPanel {
    private final JTextField field = new JTextField(30);
    private final JTextArea  outf  = new JTextArea();
    private final SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US);
    private final DateFormat df = DateFormat.getDateTimeInstance();
    public MainPanel() {
        super(new BorderLayout());

        field.setText("Mon, 19 Apr 2004 16:31:41 +0900");
        outf.setEditable(false);
        df.setTimeZone(TimeZone.getTimeZone("JST"));

        JButton button = new JButton(new AbstractAction("Convert") {
            @Override public void actionPerformed(ActionEvent e) {
                String str = field.getText().trim();
                ParsePosition pp = new ParsePosition(0);
                Date date = format.parse(str, pp);
                if (Objects.nonNull(date)) {
                    outf.append(df.format(date) + "\n");
                } else {
                    outf.append("error\n");
                }
            }
        });

        Box box = Box.createVerticalBox();
        box.setBorder(BorderFactory.createTitledBorder("DateFormat"));
        box.add(field);
        box.add(Box.createVerticalStrut(5));
        box.add(button);
        button.setAlignmentX(Component.RIGHT_ALIGNMENT);

        add(box, BorderLayout.NORTH);
        add(new JScrollPane(outf));
        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        setPreferredSize(new Dimension(320, 240));
    }

    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

@@ -332,14 +332,16 @@
 rea 
- outf 
+textArea
  = n
@@ -618,41 +618,33 @@
 ext(
-%22Mon, 19 Apr 2004 16:31:41 +0900%22
+format.format(new Date())
 );%0A 
@@ -650,20 +650,24 @@
         
-outf
+textArea
 .setEdit
@@ -746,24 +746,284 @@
    J
-Button button = 
+Panel bp = new JPanel(new GridLayout(1, 0, 2, 2));%0A        bp.add(new JButton(new AbstractAction(%22format%22) %7B%0A            @Override public void actionPerformed(ActionEvent e) %7B%0A                field.setText(format.format(new Date()));%0A            %7D%0A        %7D));%0A        bp.add(
 new 
@@ -1054,15 +1054,13 @@
 on(%22
-Convert
+parse
 %22) %7B
@@ -1308,12 +1308,19 @@
     
-if (
+String o = 
 Obje
@@ -1340,44 +1340,11 @@
 ate)
-) %7B%0A                    outf.append(
+ ? 
 df.f
@@ -1359,15 +1359,17 @@
 te) 
-+ %22%5Cn%22)
+: %22error%22
 ;%0A  
@@ -1386,49 +1386,24 @@
     
-%7D else %7B%0A                    outf
+textArea
 .append(
 %22err
@@ -1402,24 +1402,19 @@
 end(
-%22error
+o + %22
 %5Cn%22);%0A
-    
     
@@ -1423,37 +1423,37 @@
       %7D%0A        
-    %7D
+%7D));%0A
 %0A        %7D);%0A%0A  
@@ -1449,21 +1449,65 @@
     
-%7D
+GridBagConstraints c = new GridBagConstraints(
 );%0A
-%0A
         
 Box 
@@ -1506,40 +1506,49 @@
     
-Box box = Box.createVerticalBox(
+JPanel p = new JPanel(new GridBagLayout()
 );%0A 
@@ -1554,19 +1554,17 @@
         
-box
+p
 .setBord
@@ -1611,32 +1611,33 @@
 eFormat%22));%0A
+%0A
         
 box.add(fiel
@@ -1628,102 +1628,202 @@
     
-box.add(field);%0A        box.add(Box.createVerticalStrut(5));%0A        box.add(button
+c.insets  = new Insets(2, 2, 2, 2);%0A        c.fill    = GridBagConstraints.HORIZONTAL;%0A        c.anchor  = GridBagConstraints.LINE_END;%0A        c.weightx = 1d;%0A        p.add(field, c
 );%0A
+%0A
         
 butt
@@ -1822,73 +1822,172 @@
     
-button.setAlignmentX(Component.RIGHT_ALIGNMENT);%0A%0A        add(box
+c.insets  = new Insets(2, 0, 2, 2);%0A        c.fill    = GridBagConstraints.NONE;%0A        c.weightx = 0d;%0A        c.gridy   = 1;%0A        p.add(bp, c);%0A%0A        add(p
 , Bo
@@ -2037,12 +2037,16 @@
 ane(
-outf
+textArea
 ));%0A
@@ -2166,17 +2166,16 @@
 ;%0A    %7D%0A
-%0A
     publ

add format button