title: JTextfield property change using Java Swing
body: <p>I use the following code for changing the properties of a JTextField. It worked properly. My problem is how to change the JTextField properties by passing parameters without using the default functions. For example if I want to change the JTextField LEFT property means using parameter (control name,left,100) like this. How do I change a JTextField property by passing parameters to the JTextField Property using the following code?</p>
  
  <pre><code>package textfield;
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  
  public class textf implements ActionListener
  {
      JTextField txt;
      JButton width;
      JFrame frame;
      JPanel panel;
      //Font font = UIManager.getFont("txt.font");
      public textf()
      {
         frame=new JFrame();
         panel=new JPanel();
         txt=new JTextField(10);
         width=new JButton("width");
         width.setBounds(20, 200, 50, 40);
  
      panel.add(txt);
      panel.add(width);
      width.addActionListener(this);
      frame.add(panel);
  
  
  
         // n.getContentPane().add(new textf());
          frame.setSize(440,310);
          frame.setVisible(true);
  
      }
      public void actionPerformed(ActionEvent e)
      {
      txt.setBorder(BorderFactory.createLineBorder(Color.red));
      txt.setHorizontalAlignment(javax.swing.JTextField.LEFT);
       txt.setSize(100,100);
        txt.setPreferredSize(new Dimension(1000, 90));
  
         txt.putClientProperty("txt.sizeVariant", "small");
  
          txt.setFont(new Font("Comic Sans",Font.ITALIC,20));
          txt.setForeground(Color.BLUE);
          txt.setHorizontalAlignment(JTextField.RIGHT);
      }
      public static void main(String[] args)
      {
          new textf();
  
      }
  
  
  }
  </code></pre>