import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class DemoTextArea {
public JTextArea
textArea;
public JScrollPane
scroller;
public
DemoTextArea() {
textArea = new
JTextArea(345,190);
textArea.setText(
"Ini adalah contoh teksnya ;) " );//memasukkan teksnya bisa juga pa
di outputnya
textArea.setLineWrap(true);
//di-wrap atau dipotong
scroller = new
JScrollPane(textArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.setLocation(0,0);
scroller.setSize(new Dimension(345, 190));
}
public void
createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new
JFrame("TextArea");//Judul Framenya
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(scroller);
frame.setBounds(0,
0, 355, 200);//ukuran frame
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void
main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void
run() {
DemoTextArea
app = new DemoTextArea();
app.createAndShowGUI();
}
});
}
}
Tidak ada komentar:
Posting Komentar