当前位置: 首页>>代码示例>>Java>>正文


Java TextArea.setText方法代码示例

本文整理汇总了Java中java.awt.TextArea.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextArea.setText方法的具体用法?Java TextArea.setText怎么用?Java TextArea.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.TextArea的用法示例。


在下文中一共展示了TextArea.setText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SelectionVisible.java

示例2: 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

示例3: 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

示例4: ActionEventTest

import java.awt.TextArea; //导入方法依赖的package包/类
public ActionEventTest() {
    try {
        robot = new Robot();
    } catch(AWTException e) {
        throw new RuntimeException(e.getMessage());
    }

    button = new Button("ClickMe");
    button.setEnabled(true);

    instructions = new TextArea(10, 50);
    instructions.setText(
    " This is a manual test\n" +
    " Keep the Alt, Shift & Ctrl Keys pressed &\n" +
    " Click 'ClickMe' button with left mouse button\n" +
    " Test exits automatically after mouse click.");

    add(button);
    add(instructions);
    setSize(400,400);
    setLayout(new FlowLayout());
    pack();
    setVisible(true);
    robot.waitForIdle();

    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            int md = ae.getModifiers();
            int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                    | ActionEvent.SHIFT_MASK;

            isProgInterruption = true;
            mainThread.interrupt();
            if ((md & expectedMask) != expectedMask) {
                throw new RuntimeException("Action Event modifiers"
                    + " are not set correctly.");
            }
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:ActionEventTest.java

示例5: ActionEventTest

import java.awt.TextArea; //导入方法依赖的package包/类
public ActionEventTest() {
    menuBar = new MenuBar();
    Menu menu = new Menu("Menu1");
    MenuItem menuItem = new MenuItem("MenuItem");

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            System.out.println("actionPerformed");
            int md = ae.getModifiers();
            int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                    | ActionEvent.SHIFT_MASK;

            isProgInterruption = true;
            mainThread.interrupt();
            if ((md & expectedMask) != expectedMask) {
                throw new RuntimeException("Action Event modifiers are not"
                    + " set correctly.");
            }
        }
    });
    menu.add(menuItem);
    menuBar.add(menu);
    setMenuBar(menuBar);

    instructions = new TextArea(10, 50);
    instructions.setText(
    " This is a manual test\n" +
    " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
    " Click 'Menu1' Menu from the Menu Bar\n" +
    " It will show 'MenuItem'\n" +
    " Left mouse Click the 'MenuItem'\n" +
    " Test exits automatically after mouse click.");
    add(instructions);

    setSize(400, 400);
    setVisible(true);
    validate();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ActionEventTest.java

示例6: createInstructionUI

import java.awt.TextArea; //导入方法依赖的package包/类
private void createInstructionUI() {
    mainFrame = new Frame("Updating TrayIcon Popup Menu Item Test");
    layout = new GridBagLayout();
    mainControlPanel = new Panel(layout);
    resultButtonPanel = new Panel(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    String instructions
            = "INSTRUCTIONS:"
            + "\n   1. Click on the System Tray Icon"
            + "\n   2. Click on any of the displayed Menu items"
            + "\n   3. Repeat step 1 and count the number of items in the "
            + "Menu"
            + "\n   4. The number of items in the Menu should increase by 1"
            + "\n   5. Repeating steps 1, 2 and 3 should not break 4th step"
            + "\n   6. Click Fail if the 4th step is broken, Otherwise "
            + "click Pass ";

    instructionTextArea = new TextArea();
    instructionTextArea.setText(instructions);
    instructionTextArea.setEnabled(false);
    instructionTextArea.setBackground(Color.white);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainControlPanel.add(instructionTextArea, gbc);

    passButton = new Button("Pass");
    passButton.setName("Pass");
    passButton.addActionListener(this);

    failButton = new Button("Fail");
    failButton.setName("Fail");
    failButton.addActionListener(this);

    gbc.gridx = 0;
    gbc.gridy = 0;
    resultButtonPanel.add(passButton, gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    resultButtonPanel.add(failButton, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    mainControlPanel.add(resultButtonPanel, gbc);

    mainFrame.add(mainControlPanel);
    mainFrame.pack();
    mainFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:UpdatePopupMenu.java

示例7: createInstructionUI

import java.awt.TextArea; //导入方法依赖的package包/类
private void createInstructionUI() {
    instructionFrame = new Frame("Native Print Dialog and Page Dialog");
    layout = new GridBagLayout();
    mainControlPanel = new Panel(layout);
    resultButtonPanel = new Panel(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    String instructions
            = "\nINSTRUCTIONS:\n"
            + "\n   1. Click on the 'show a native print dialog' button. A "
            + "native print dialog will come up."
            + "\n   2. Click on the 'Cancel' button on Mac OS X or "
            + "'close'(X) on other paltforms. Dialog will be closed."
            + "\n   3. After the dialog is closed another window should "
            + "become the active window."
            + "\n   4. If there no any active window then the test has "
            + "failed. Click on 'Fail' Button."
            + "\n   5. Click on the 'show a native page dialog' button. A "
            + "native page dialog will come up."
            + "\n   6. Click on the 'Cancel' button on Mac OS X or "
            + "'close'(X) on other paltforms. Dialog will be closed."
            + "\n   7. After the dialog is closed another window should "
            + "become the active window."
            + "\n   8. If there no any active window then the test has "
            + "failed. Click on 'Fail' Button."
            + "\n   9. Test Passed. Click on 'Pass' Button.";

    instructionTextArea = new TextArea(13, 80);
    instructionTextArea.setText(instructions);
    instructionTextArea.setEnabled(false);
    instructionTextArea.setBackground(Color.white);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainControlPanel.add(instructionTextArea, gbc);

    passButton = new Button("Pass");
    passButton.setName("Pass");
    passButton.addActionListener((ActionListener) this);

    failButton = new Button("Fail");
    failButton.setName("Fail");
    failButton.addActionListener((ActionListener) this);

    setButtonEnable(false);

    gbc.gridx = 0;
    gbc.gridy = 0;
    resultButtonPanel.add(passButton, gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    resultButtonPanel.add(failButton, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    mainControlPanel.add(resultButtonPanel, gbc);

    instructionFrame.add(mainControlPanel);
    instructionFrame.pack();
    instructionFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:RestoreActiveWindowTest.java

示例8: createInstructionUI

import java.awt.TextArea; //导入方法依赖的package包/类
private void createInstructionUI() {
    mainFrame = new Frame("Drag and drop link from web browser");
    layout = new GridBagLayout();
    mainControlPanel = new Panel(layout);
    resultButtonPanel = new Panel(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    String instructions
            = "INSTRUCTIONS:"
            + "\n   1. Open any browser."
            + "\n   2. Select and drag URL from the browser page and "
            + "drop it on the panel"
            + "\n   3. If test fails, then a popup message will be displayed,"
            + " click Ok and \n       click Fail button."
            + "\n   5. Otherwise test passed. Click Pass button.";

    instructionTextArea = new TextArea();
    instructionTextArea.setText(instructions);
    instructionTextArea.setEnabled(false);
    instructionTextArea.setBackground(Color.white);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainControlPanel.add(instructionTextArea, gbc);

    passButton = new Button("Pass");
    passButton.setName("Pass");
    passButton.addActionListener(this);

    failButton = new Button("Fail");
    failButton.setName("Fail");
    failButton.addActionListener(this);

    gbc.gridx = 0;
    gbc.gridy = 0;
    resultButtonPanel.add(passButton, gbc);
    gbc.gridx = 1;
    gbc.gridy = 0;
    resultButtonPanel.add(failButton, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    mainControlPanel.add(resultButtonPanel, gbc);

    mainFrame.add(mainControlPanel);
    mainFrame.pack();
    mainFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:DragLinkFromBrowser.java


注:本文中的java.awt.TextArea.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。