當前位置: 首頁>>代碼示例>>Java>>正文


Java TextArea類代碼示例

本文整理匯總了Java中java.awt.TextArea的典型用法代碼示例。如果您正苦於以下問題:Java TextArea類的具體用法?Java TextArea怎麽用?Java TextArea使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextArea類屬於java.awt包,在下文中一共展示了TextArea類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setScrollBarVisibility

import java.awt.TextArea; //導入依賴的package包/類
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:LWTextAreaPeer.java

示例2: init

import java.awt.TextArea; //導入依賴的package包/類
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:SelectionVisible.java

示例3: actionPerformed

import java.awt.TextArea; //導入依賴的package包/類
public void actionPerformed() {
    JFrame f = new JFrame();
    TextArea textArea = new TextArea();
    textArea.setEditable(false);
    textArea.setBackground(Color.white);
    textArea.setForeground(Color.black);
    IData data = accumulatorHistory.getData();
    IData xData = ((DataInfoFunction)accumulatorHistory.getDataInfo()).getXDataSource().getIndependentData(0);
    for (int i=0; i<data.getLength(); i++) {
        double x = xData.getValue(i);
        double y = data.getValue(i);
        if (Double.isNaN(x) || Double.isNaN(y)) continue;
        textArea.append(x+"\t"+y+"\n");
    }
    f.add(textArea);
    f.pack();
    f.setSize(400,600);
    f.setVisible(true);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:20,代碼來源:ActionHistoryWindow.java

示例4: actionPerformed

import java.awt.TextArea; //導入依賴的package包/類
public void actionPerformed() {
    JFrame f = new JFrame();
    TextArea textArea = new TextArea();
    textArea.setEditable(false);
    textArea.setBackground(Color.white);
    textArea.setForeground(Color.black);
    int nLeaf = leafList.getAtomCount();
    for (int iLeaf=0; iLeaf<nLeaf; iLeaf++) {
        IAtom a = leafList.getAtom(iLeaf);
        Vector pos = a.getPosition();
        String str = Double.toString(pos.getX(0));
        for (int i=1; i<pos.getD(); i++) {
            str += " "+Double.toString(pos.getX(i));
        }
        textArea.append(str+"\n");
    }
    f.add(textArea);
    f.pack();
    f.setSize(400,600);
    f.setVisible(true);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:22,代碼來源:ActionConfigWindow.java

示例5: actionPerformed

import java.awt.TextArea; //導入依賴的package包/類
public void actionPerformed() {
    JFrame f = new JFrame();
    TextArea textArea = new TextArea();
    textArea.setEditable(false);
    textArea.setBackground(Color.white);
    textArea.setForeground(Color.black);
    int nLeaf = leafList.getAtomCount();
    for (int iLeaf=0; iLeaf<nLeaf; iLeaf++) {
        IAtomKinetic a = (IAtomKinetic)leafList.getAtom(iLeaf);
        Vector vel = a.getVelocity();
        String str = Double.toString(vel.getX(0));
        for (int i=1; i<vel.getD(); i++) {
            str += " "+Double.toString(vel.getX(i));
        }
        textArea.append(str+"\n");
    }
    f.add(textArea);
    f.pack();
    f.setSize(400,600);
    f.setVisible(true);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:22,代碼來源:ActionVelocityWindow.java

示例6: main

import java.awt.TextArea; //導入依賴的package包/類
public static void main(final String[] args) {
    final Frame frame = new Frame();
    final TextArea ta = new TextArea();
    frame.add(ta);
    frame.pack();
    frame.setVisible(true);
    sleep();
    final Dimension before = frame.getSize();
    frame.pack();
    final Dimension after = frame.getSize();
    if (!after.equals(before)) {
        throw new RuntimeException(
                "Expected size: " + before + ", actual size: " + after);
    }
    frame.dispose();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:TextAreaTwicePack.java

示例7: createObjects

import java.awt.TextArea; //導入依賴的package包/類
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:SelectionAutoscrollTest.java

示例8: TestDialog

import java.awt.TextArea; //導入依賴的package包/類
public TestDialog(Frame frame, String name)    {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();

    show();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:HighResTest.java

示例9: TestDialog

import java.awt.TextArea; //導入依賴的package包/類
public TestDialog( Frame frame, String name )
{
    super( frame, name );
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
    add( "North", instructionsText );

    messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
    add("Center", messageText);

    passB = new Button( "pass" );
    passB.setActionCommand( "pass" );
    passB.addActionListener( this );
    buttonP.add( "East", passB );

    failB = new Button( "fail" );
    failB.setActionCommand( "fail" );
    failB.addActionListener( this );
    buttonP.add( "West", failB );

    add( "South", buttonP );
    pack();

    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:DragEventSource.java

示例10: TextAreaScrolling

import java.awt.TextArea; //導入依賴的package包/類
TextAreaScrolling() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException("Robot Creation Failed");
    }

    mainFrame = new Frame();
    mainFrame.setSize(200, 200);
    mainFrame.setLocation(200, 200);

    textArea = new TextArea();
    textArea.setText("1234 5678");
    textArea.setSelectionStart(3);
    textArea.setSelectionEnd(4);
    mainFrame.add(textArea);
    mainFrame.setVisible(true);
    textArea.requestFocusInWindow();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TextAreaScrolling.java

示例11: OverScrollTest

import java.awt.TextArea; //導入依賴的package包/類
OverScrollTest() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage());
    }

    mainFrame = new Frame();
    mainFrame.setSize(400, 200);
    mainFrame.setLocation(200, 200);
    mainFrame.setLayout(new FlowLayout());

    textArea = new TextArea(2, 10);
    textArea.setSize(300, 100);
    textArea.setText("123456 789123");
    mainFrame.add(textArea);
    mainFrame.setVisible(true);
    textArea.requestFocusInWindow();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:OverScrollTest.java

示例12: init

import java.awt.TextArea; //導入依賴的package包/類
@Override
public void init() {
    ta = new TextArea(4, 20);
    ta.setText("01234\n56789");
    ta.select(3, 9);

    final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
                                             + "The text 34567 should be selected in the TextArea.\n"
                                             + "If this is what you observe, then the test passes.\n"
                                             + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    instruction.setEditable(false);
    instruction.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(ta);
    setLayout(new BorderLayout());
    add(instruction, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:SelectionVisible.java

示例13: TestDialog

import java.awt.TextArea; //導入依賴的package包/類
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ScrollSelectionTest.java

示例14: TestDialog

import java.awt.TextArea; //導入依賴的package包/類
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("Center", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:AltGraphModifierTest.java

示例15: TestDialog

import java.awt.TextArea; //導入依賴的package包/類
public TestDialog( Frame frame, String name )
{
  super( frame, name );
  int scrollBoth = TextArea.SCROLLBARS_BOTH;
  instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
  add( "North", instructionsText );

  messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
  add("Center", messageText);

  passB = new Button( "pass" );
  passB.setActionCommand( "pass" );
  passB.addActionListener( this );
  buttonP.add( "East", passB );

  failB = new Button( "fail" );
  failB.setActionCommand( "fail" );
  failB.addActionListener( this );
  buttonP.add( "West", failB );

  add( "South", buttonP );
  pack();

  show();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:Test6991580.java


注:本文中的java.awt.TextArea類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。