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

public final class MainPanel extends JPanel {
    private final JTextField field1 = new JTextField("aaaaaaaaaa");
    private final JTextField field2 = new JTextField();
    private final JTextField field3 = new JTextField("123465789735");
    public MainPanel() {
        super(new BorderLayout());
        Color c = field1.getBackground();
        field1.addFocusListener(new BGFocusListener(c, new Color(230, 230, 255)));
        field2.addFocusListener(new BGFocusListener(c, new Color(255, 255, 230)));
        field3.addFocusListener(new BGFocusListener(c, new Color(255, 230, 230)));
        Box box = Box.createVerticalBox();
        box.add(makePanel("Color(230, 230, 255)", field1));
        box.add(Box.createVerticalStrut(5));
        box.add(makePanel("Color(255, 255, 230)", field2));
        box.add(Box.createVerticalStrut(5));
        box.add(makePanel("Color(255, 230, 230)", field3));
        box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        add(box, BorderLayout.NORTH);
        setPreferredSize(new Dimension(320, 240));
    }
    private static JPanel makePanel(String title, JComponent c) {
        JPanel p = new JPanel(new BorderLayout());
        p.setBorder(BorderFactory.createTitledBorder(title));
        p.add(c);
        return p;
    }
    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.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

class BGFocusListener implements FocusListener {
    private final Color dColor;
    private final Color oColor;
    public BGFocusListener(Color oColor, Color dColor) {
        this.dColor = dColor;
        this.oColor = oColor;
    }
    @Override public void focusGained(FocusEvent e) {
        e.getComponent().setBackground(dColor);
    }
    @Override public void focusLost(FocusEvent e) {
        e.getComponent().setBackground(oColor);
    }
}

@@ -461,50 +461,8 @@
 ));%0A
-        Color c = field1.getBackground();%0A
     
@@ -501,35 +501,32 @@
 BGFocusListener(
-c, 
 new Color(230, 2
@@ -581,35 +581,32 @@
 BGFocusListener(
-c, 
 new Color(255, 2
@@ -673,11 +673,8 @@
 ner(
-c, 
 new 
@@ -2306,26 +2306,25 @@
 final Color 
-dC
+c
 olor;%0A    pr
@@ -2327,44 +2327,15 @@
   pr
-ivate final Color oColor;%0A    public
+otected
  BGF
@@ -2357,24 +2357,9 @@
 lor 
-oColor, Color dC
+c
 olor
@@ -2379,49 +2379,17 @@
 his.
-dColor = dColor;%0A        this.oC
+c
 olor = 
-oC
+c
 olor
@@ -2493,10 +2493,9 @@
 und(
-dC
+c
 olor
@@ -2598,14 +2598,50 @@
 und(
-oColor
+UIManager.getColor(%22TextField.background%22)
 );%0A 

use UIManager.getColor(TextField.background)