Ce programme crée un JTextField personnalisé Voici comment appeler cette classe.
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class RoundTextUITest extends JPanel
{
public RoundTextUITest()
{
JTextField tf= new JTextField();
tf.setUI(new RoundTextUI());
tf.setPreferredSize(new Dimension(150,30));
tf.setText("Testing 1 2 3 4");
add(tf);
}
public static void main(String [] args)
{
JFrame frame = new JFrame("Customer Interface");
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.getContentPane().add(new RoundTextUITest(),BorderLayout.CENTER);
frame.setSize(640, 480);
frame.setVisible(true);
}
}
|