I have a JTextField
and I want to install Margin. But when I set any border, it does not work properly. The margin function does not work. This is my code;
import java.awt.Color; import java.awt.Insets; import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.JOptionPane; import javax.swing.JTextField; public class ImageField { public static void main(String[] args) throws IOException { JTextField textField = new JTextField(); textField.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); textField.setMargin(new Insets(0, 20, 0, 0)); JOptionPane.showMessageDialog(null, textField, "", JOptionPane.PLAIN_MESSAGE); } }
If I start this line, it works
source share