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


Java JTextArea.setEnabled方法代码示例

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


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

示例1: displayArea

import javax.swing.JTextArea; //导入方法依赖的package包/类
protected JTextArea displayArea(int linecount)
{
    JTextArea ta = new JTextArea();
    ta.setEditable(false);
    ta.setLineWrap(false);
    ta.setEnabled(true);

    // ugly hack to set a preferred height based on lines of text
    ta.setSize(100,Short.MAX_VALUE);
    StringBuilder b = new StringBuilder();
    for (int ii = 0; ii < linecount-1; ii++) {
        b.append(ii+"\n"+ii);
    }
    ta.setText(b.toString());
    int h = (int)(ta.getPreferredSize().height*0.9);
    ta.setPreferredSize(new Dimension(Short.MAX_VALUE, h));
    ta.setText("");
    return ta;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:20,代码来源:DriverCarPanel.java

示例2: SuspendInfoPanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
public SuspendInfoPanel() {
    setLayout(new java.awt.GridBagLayout());
    JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.setBackground(getBackground());
    infoText.setDisabledTextColor(new JLabel().getForeground());
    infoText.setLineWrap(true);
    infoText.setWrapStyleWord(true);
    infoText.setPreferredSize(
            new Dimension(
                infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()),
                infoText.getPreferredSize().height));
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    //gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    //gridBagConstraints.weightx = 1.0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(infoText, gridBagConstraints);
    infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    
    JButton pauseButton = new JButton();
    pauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doStopCurrentDebugger();
        }
    });
    org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause"));
    pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(pauseButton, gridBagConstraints);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:InstancesView.java

示例3: createMultilineLabel

import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
 * Creates a text component to be used as a multi-line, automatically
 * wrapping label.
 * <p>
 * <strong>Restriction:</strong><br>
 * The component may have its preferred size very wide.
 *
 * @param  text  text of the label
 * @param  color  desired color of the label,
 *                or {@code null} if the default color should be used
 * @return  created multi-line text component
 */
public static JTextComponent createMultilineLabel(String text, Color color) {
    JTextArea textArea = new JTextArea(text);
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEnabled(false);
    textArea.setOpaque(false);
    textArea.setColumns(25);
    textArea.setDisabledTextColor((color != null)
                                  ? color
                                  : new JLabel().getForeground());
    
    return textArea;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:GuiUtils.java

示例4: KeyDemoFrame

import javax.swing.JTextArea; //导入方法依赖的package包/类
public KeyDemoFrame()
{
   super("Demonstrating Keystroke Events");

   textArea = new JTextArea(10, 15); // set up JTextArea
   textArea.setText("Press any key on the keyboard...");
   textArea.setEnabled(false);
   textArea.setDisabledTextColor(Color.BLACK);
   add(textArea); // add textarea to JFrame

   addKeyListener(this); // allow frame to process key events
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:13,代码来源:KeyDemoFrame.java

示例5: layoutSelectResourcePanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
 * @author  Marian Petras
 */
static void layoutSelectResourcePanel(final Container thePanel,
                                      final String instructionsText,
                                      final String selectionLabelText,
                                      final Component selectionComp,
                                      final JButton button1,
                                      final JButton button2) {
    JTextArea instructions = new JTextArea();
    JLabel lblSelection = new JLabel();

    instructions.setColumns(20);
    instructions.setEditable(false);
    instructions.setLineWrap(true);
    instructions.setText(instructionsText);
    instructions.setWrapStyleWord(true);
    instructions.setDisabledTextColor(new JLabel().getForeground());
    instructions.setEnabled(false);
    instructions.setOpaque(false);

    lblSelection.setLabelFor(selectionComp);
    Mnemonics.setLocalizedText(lblSelection, selectionLabelText);

    JScrollPane scrollPane = new JScrollPane(selectionComp);

    Container filesSelection = new JPanel();
    GroupLayout layout = new GroupLayout(filesSelection);
    filesSelection.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(LEADING)
        .addComponent(lblSelection)
        .addGroup(layout.createSequentialGroup()
            .addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
            .addPreferredGap(RELATED)
            .addGroup(layout.createParallelGroup(LEADING)
                .addComponent(button1)
                .addComponent(button2)))
    );

    layout.linkSize(SwingConstants.HORIZONTAL, button1, button2);

    layout.setVerticalGroup(
        layout.createParallelGroup(LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(lblSelection)
            .addPreferredGap(RELATED)
            .addGroup(layout.createParallelGroup(LEADING)
                .addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(button1)
                    .addPreferredGap(RELATED)
                    .addComponent(button2))))
    );

    LayoutStyle layoutStyle = layout.getLayoutStyle();
    if (layoutStyle == null) {
        layoutStyle = LayoutStyle.getInstance();
    }

    BorderLayout mainLayout = new BorderLayout();
    thePanel.setLayout(mainLayout);
    thePanel.add(instructions, BorderLayout.PAGE_START);
    thePanel.add(filesSelection, BorderLayout.CENTER);
    mainLayout.setVgap(layoutStyle.getPreferredGap(instructions,
                                                   lblSelection,
                                                   UNRELATED,
                                                   SwingConstants.NORTH,
                                                   thePanel));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:71,代码来源:Util.java

示例6: createControlPanelUI

import javax.swing.JTextArea; //导入方法依赖的package包/类
public final void createControlPanelUI() throws Exception {
    layout = new GridBagLayout();
    mainControlPanel = new JPanel(layout);
    instructionPanel = new JPanel(layout);
    testPanel = new JPanel(layout);
    resultButtonPanel = new JPanel(layout);
    controlPanel = new JPanel(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    String instructions
            = "1) Click on MENU using mouse "
            + "\n2) Click on MENU ITEM using mouse "
            + "\n3) Check output on textArea if equal to STRING "
            + "\n\n If correct string, press \"Pass\" "
            + "\n Otherwise, press \"Fail\" ";
    instructionTextArea = new JTextArea();
    instructionTextArea.setText(instructions);
    instructionTextArea.setEnabled(false);
    instructionTextArea.setDisabledTextColor(Color.black);
    instructionTextArea.setBackground(Color.white);
    instructionTextArea.setBorder(
            BorderFactory.createLineBorder(Color.black));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    instructionPanel.add(instructionTextArea, gbc);
    testTextArea = new JTextArea();
    testTextArea.setEnabled(true);
    testTextArea.setDisabledTextColor(Color.black);
    testTextArea.setBackground(Color.white);
    testTextArea.setBorder(
            BorderFactory.createLineBorder(Color.black));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    testPanel.add(testTextArea, gbc);
    passButton = new JButton("Pass");
    passButton.setActionCommand("Pass");
    passButton.addActionListener(this);
    failButton = new JButton("Fail");
    failButton.setActionCommand("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 = 0;
    mainControlPanel.add(instructionPanel, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    mainControlPanel.add(testPanel, gbc);
    gbc.gridx = 0;
    gbc.gridy = 2;
    mainControlPanel.add(resultButtonPanel, gbc);
    gbc.gridx = 0;
    gbc.gridy = 3;
    mainControlPanel.add(controlPanel, gbc);
    mainFrame = new JFrame("Control Panel");
    mainFrame.add(mainControlPanel);
    menuBar = new JMenuBar();
    menu = new JMenu("MENU");
    menuItem = new JMenuItem("MENU ITEM");
    menuItem.addActionListener((e) -> {
        testTextArea.setText(TEST_STRING);
    });
    menu.add(menuItem);
    menuBar.add(menu);
    mainFrame.setJMenuBar(menuBar);
    mainFrame.pack();
    mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    mainFrame.setVisible(true);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:77,代码来源:ClickMenuTestManual.java


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