簡易テキストエディタ その3 テキストエリアAdvertisementとりあえず文字を書けるように。
文字書く画面追加。JTextPane(リンク先:java.sun.com)
で、ついでに画面端で折り返し。 文字書く画面追加
import javax.swing.*;
public class SwingTest{
public static void main(String args[]){
JFrame.setDefaultLookAndFeelDecorated(true);
try{
javax.swing.plaf.metal.
MetalLookAndFeel.setCurrentTheme(
new javax.swing.plaf.metal.DefaultMetalTheme());
UIManager.setLookAndFeel
("javax.swing.plaf.metal.MetalLookAndFeel");
}catch(Exception e){
System.out.println(e);
}
MyFrame mf = new MyFrame();
mf.setTitle("簡易テキストエディタ");
mf.setSize(400, 300);
mf.show();
}
}
class MyFrame extends JFrame{
//テキスト入力フィールド
JTextPane text = new JTextPane();
public MyFrame(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//フレームに追加
getContentPane().add(text);
}
}
完成図![]() テキストエリア完成。まだ、下に長い文章作った時にスクロールできましぇん。 Advertisement |
ショートカット・634・634ブログ ・このカテゴリのトップページに戻る ・Incubator(Pukiwiki) ・634ラボ UIコレクションギャラリー ZO-3ジェネレーター サイト検索Y!ログール |