Java API 分類導覽 - java.awt.TextArea SCROLLBARS_NONE

TextArea 類別 (class) 的 SCROLLBARS_NONE 屬性 (field) 為整數常數 3 ,通常用為建構子的參數 (parameter) ,設定不顯示文字輸入框的捲軸。



修飾子
public static final int SCROLLBARS_NONE


舉例如下
import java.awt.*;
import java.awt.event.*;

public class TextAreaDemo2 {
    Frame frame;
    TextArea text1, text2, text3, text4;
    
    public static void main(String[] args) {
        new TextAreaDemo2();
    }
    
    public TextAreaDemo2() {
        frame = new Frame("AWTDemo");
        frame.addWindowListener(new AdapterDemo());
        frame.setLayout(new FlowLayout());
        frame.setSize(640, 480);
        
        String s = "There is no spoon."; 
        text1 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_BOTH);
        text2 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_VERTICAL_ONLY);
        text3 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_HORIZONTAL_ONLY);
        text4 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_NONE);

        frame.add(text1);
        frame.add(text2);
        frame.add(text3);
        frame.add(text4);
        
        frame.setVisible(true);
        
        System.out.println("SCROLLBARS_BOTH: " + TextArea.SCROLLBARS_BOTH);
        System.out.println("SCROLLBARS_VERTICAL_ONLY: " + TextArea.SCROLLBARS_VERTICAL_ONLY);
        System.out.println("SCROLLBARS_HORIZONTAL_ONLY: " + TextArea.SCROLLBARS_HORIZONTAL_ONLY);
        System.out.println("SCROLLBARS_NONE: " + TextArea.SCROLLBARS_NONE);
    }
}

class AdapterDemo extends WindowAdapter {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
}

/* 《程式語言教學誌》的範例程式
    http://pydoing.blogspot.com/
    檔名:TextAreaDemo2.java
    功能:示範 Java 程式 
    作者:張凱慶
    時間:西元 2012 年 3 月 */


此例的 TextAreaDemo2 類別建立四個 TextArea 物件,分別以 SCROLLBARS_BOTH 、 SCROLLBARS_VERTICAL_ONLY 、 SCROLLBARS_HORIZONTAL_ONLY 、 SCROLLBARS_NONE 當建構子參數
String s = "There is no spoon."; 
text1 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_BOTH);
text2 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_VERTICAL_ONLY);
text3 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_HORIZONTAL_ONLY);
text4 = new TextArea(s, 10, 20, TextArea.SCROLLBARS_NONE);


最後在命令列印出 SCROLLBARS_BOTH 、 SCROLLBARS_VERTICAL_ONLY 、 SCROLLBARS_HORIZONTAL_ONLY 、 SCROLLBARS_NONE 的常數值
System.out.println("SCROLLBARS_BOTH: " + TextArea.SCROLLBARS_BOTH);
System.out.println("SCROLLBARS_VERTICAL_ONLY: " + TextArea.SCROLLBARS_VERTICAL_ONLY);
System.out.println("SCROLLBARS_HORIZONTAL_ONLY: " + TextArea.SCROLLBARS_HORIZONTAL_ONLY);
System.out.println("SCROLLBARS_NONE: " + TextArea.SCROLLBARS_NONE);


編譯後執行,結果如下



中英文術語對照
類別class
屬性field
參數parameter


您可以繼續參考
AWT 元件


相關目錄
Java API 分類導覽
Java 教材
首頁


參考資料
http://docs.oracle.com/javase/6/docs/api/java/awt/TextArea.html

沒有留言: