Pages

Wednesday, December 12, 2012

Mengatur Padding TextArea pada Java

java image

package textareapadding;

import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.border.Border;

public class TextAreaPadding extends JFrame {
    
    public TextAreaPadding() {
        super("Text Area Padding");
        setSize(300, 100);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        JTextArea area = new JTextArea("Some Text, Some Text, Some Text .........................................");
        Border border = BorderFactory.createLineBorder(Color.DARK_GRAY);
        area.setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(10, 10, 10, 10)));
        area.setLineWrap(true);
        area.setEditable(false);
        add(area);
        setVisible(true);
    }

    public static void main(String[] args) {
        new TextAreaPadding();
    }
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...