javax.swing.JTextArea.setText()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中javax.swing.JTextArea.setText()方法的一些代码示例,展示了JTextArea.setText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextArea.setText()方法的具体详情如下:
包路径:javax.swing.JTextArea
类名称:JTextArea
方法名:setText

JTextArea.setText介绍

暂无

代码示例

代码示例来源:origin: iluwatar/java-design-patterns

add(panel, BorderLayout.CENTER);
panel.setLayout(new GridLayout(6, 2));
panel.add(new JLabel("Name"));
panel.add(jtFields[0]);
panel.add(new JLabel("Contact Number"));
panel.add(jtFields[1]);
panel.add(new JLabel("Address"));
  i.setText("");

代码示例来源:origin: dcevm/dcevm

private JComponent getCenterPanel() {
  JPanel center = new JPanel(new BorderLayout());
  center.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  center.setBackground(Color.WHITE);
  JTextArea license = new javax.swing.JTextArea();
  license.setLineWrap(true);
  license.setWrapStyleWord(true);
  license.setEditable(false);
  license.setFont(license.getFont().deriveFont(11.0f));
  StringBuilder licenseText = new StringBuilder();
  licenseText.append("Enhance current Java (JRE/JDK) installations with DCEVM (http://github.com/dcevm/dcevm).");
  licenseText.append("\n\nYou can either replace current Java VM or install DCEVM as alternative JVM (run with -XXaltjvm=dcevm command-line option).");
  licenseText.append("\nInstallation as alternative JVM is preferred, it gives you more control where you will use DCEVM.\nWhy this is important? Because DCEVM forces your JVM to use only one GC algorithm, and this may cause performance penalty.");
  licenseText.append("\n\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation.\n\nThis code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License version 2 for more details (a copy is included in the LICENSE file that accompanied this code).\n\nYou should have received a copy of the GNU General Public License version 2 along with this work; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.");
  licenseText.append("\n\n\nASM LICENSE TEXT:\nCopyright (c) 2000-2005 INRIA, France Telecom\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.");
  license.setText(licenseText.toString());
  JScrollPane licenses = new JScrollPane(license, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  licenses.setPreferredSize(new Dimension(150, 150));
  center.add(licenses, BorderLayout.NORTH);
  center.add(getChooserPanel(), BorderLayout.CENTER);
  return center;
}

代码示例来源:origin: 4thline/cling

@Override
  public void run() {
    errorWindow.getContentPane().removeAll();
    JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    StringBuilder text = new StringBuilder();
    text.append("An exceptional error occurred!\nYou can try to continue or exit the application.\n\n");
    text.append("Please tell us about this here:\nhttp://www.4thline.org/projects/mailinglists-cling.html\n\n");
    text.append("-------------------------------------------------------------------------------------------------------------\n\n");
    Writer stackTrace = new StringWriter();
    throwable.printStackTrace(new PrintWriter(stackTrace));
    text.append(stackTrace.toString());
    textArea.setText(text.toString());
    JScrollPane pane = new JScrollPane(textArea);
    errorWindow.getContentPane().add(pane, BorderLayout.CENTER);
    JButton exitButton = new JButton("Exit Application");
    exitButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        System.exit(1);
      }
    });
    errorWindow.getContentPane().add(exitButton, BorderLayout.SOUTH);
    errorWindow.pack();
    Application.center(errorWindow);
    textArea.setCaretPosition(0);
    errorWindow.setVisible(true);
  }
});

代码示例来源:origin: pmd/pmd

private void init() {
  JTextArea errorArea = new JTextArea();
  errorArea.setEditable(false);
  errorArea.setText(exc.getMessage() + "\n");
  getContentPane().setLayout(new BorderLayout());
  JPanel messagePanel = new JPanel(new BorderLayout());
  messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory
      .createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
  messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
  getContentPane().add(messagePanel, BorderLayout.CENTER);
  JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
  okBtn.addActionListener(this);
  btnPane.add(okBtn);
  getRootPane().setDefaultButton(okBtn);
  getContentPane().add(btnPane, BorderLayout.SOUTH);
  pack();
  setLocationRelativeTo(getParent());
  setVisible(true);
}

代码示例来源:origin: redwarp/9-Patch-Resizer

public AboutDialog(JFrame parent) {
  this.setResizable(false);
  this.setSize(new Dimension(400, 250));
  this.getContentPane().setLayout(new BorderLayout(0, 0));
  JLabel lblResizer = new JLabel(Localization.get("app_name") + " "
      + Configuration.getVersion());
  lblResizer.setBorder(new EmptyBorder(10, 10, 10, 10));
  lblResizer.setVerticalTextPosition(SwingConstants.BOTTOM);
  lblResizer.setIconTextGap(10);
  lblResizer.setFont(lblResizer.getFont().deriveFont(
      lblResizer.getFont().getStyle() | Font.BOLD, 16f));
  lblResizer.setIcon(new ImageIcon(AboutDialog.class
      .getResource("/img/icon_64.png")));
  this.getContentPane().add(lblResizer, BorderLayout.NORTH);
  JTextArea txtrResizerIsA = new JTextArea();
  txtrResizerIsA.setEditable(false);
  txtrResizerIsA.setWrapStyleWord(true);
  txtrResizerIsA.setBorder(new EmptyBorder(0, 10, 10, 10));
  txtrResizerIsA.setFont(UIManager.getFont("Label.font"));
  txtrResizerIsA.setLineWrap(true);
  txtrResizerIsA.setText(Localization.get("about_text"));
  txtrResizerIsA.setBackground(new Color(0, 0, 0, 0));
  this.getContentPane().add(txtrResizerIsA, BorderLayout.CENTER);
  this.setLocationRelativeTo(parent);
}

代码示例来源:origin: org.codehaus.groovy/groovy

private void jbInit(Reader reader) throws Exception {
  final Border border = BorderFactory.createEmptyBorder();
  jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
  tokenPane.setEditable(false);
  tokenPane.setText("");
  scriptPane.setFont(new java.awt.Font("DialogInput", 0, 12));
  scriptPane.setEditable(false);
  scriptPane.setMargin(new Insets(5, 5, 5, 5));
  scriptPane.setText("");
  jScrollPane1.setBorder(border);
  jScrollPane2.setBorder(border);
  jSplitPane1.setMinimumSize(new Dimension(800, 600));
  mainPanel.add(jSplitPane1, BorderLayout.CENTER);
  if (reader == null) {
    mainPanel.add(jbutton, BorderLayout.NORTH);
  }
  this.getContentPane().add(mainPanel);
  jSplitPane1.add(jScrollPane1, JSplitPane.LEFT);
  jScrollPane1.getViewport().add(tokenPane, null);
  jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT);
  jScrollPane2.getViewport().add(scriptPane, null);
  jScrollPane1.setColumnHeaderView(new JLabel(" Token Stream:"));
  jScrollPane2.setColumnHeaderView(new JLabel(" Input Script:"));
  jSplitPane1.setResizeWeight(0.5);
}

代码示例来源:origin: kiegroup/optaplanner

private JPanel createMiddlePanel() {
  middlePanel = new JPanel(new CardLayout());
  JPanel usageExplanationPanel = new JPanel(new BorderLayout(5, 5));
  ImageIcon usageExplanationIcon = new ImageIcon(getClass().getResource(solutionPanel.getUsageExplanationPath()));
  JLabel usageExplanationLabel = new JLabel(usageExplanationIcon);
  // Allow splitPane divider to be moved to the right
  usageExplanationLabel.setMinimumSize(new Dimension(100, 100));
  usageExplanationPanel.add(usageExplanationLabel, BorderLayout.CENTER);
  JPanel descriptionPanel = new JPanel(new BorderLayout(2, 2));
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  descriptionPanel.add(new JLabel("Example description"), BorderLayout.NORTH);
  JTextArea descriptionTextArea = new JTextArea(8, 70);
  descriptionTextArea.setEditable(false);
  descriptionTextArea.setText(solutionBusiness.getAppDescription());
  descriptionPanel.add(new JScrollPane(descriptionTextArea,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
  usageExplanationPanel.add(descriptionPanel, BorderLayout.SOUTH);
  middlePanel.add(usageExplanationPanel, "usageExplanationPanel");
  JComponent wrappedSolutionPanel;
  if (solutionPanel.isWrapInScrollPane()) {
    wrappedSolutionPanel = new JScrollPane(solutionPanel);
  } else {
    wrappedSolutionPanel = solutionPanel;
  }
  middlePanel.add(wrappedSolutionPanel, "solutionPanel");
  return middlePanel;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Create a new Dialog with a title and a message.
 * @param message
 * @param title 
 */
public ErrorDialog(String message, String title) {
  setTitle(title);
  setSize(new Dimension(600, 400));
  setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  setLocationRelativeTo(null);   
  
  Container container = getContentPane();
  container.setLayout(new BorderLayout());
  
  JTextArea textArea = new JTextArea();
  textArea.setText(message);
  textArea.setEditable(false);
  textArea.setMargin(new Insets(PADDING, PADDING, PADDING, PADDING));
  add(new JScrollPane(textArea), BorderLayout.CENTER);
  
  final JDialog dialog = this;
  JButton button = new JButton(new AbstractAction("OK"){
    @Override
    public void actionPerformed(ActionEvent e) {
      dialog.dispose();
    }
  });
  add(button, BorderLayout.SOUTH);
}

代码示例来源:origin: runelite/runelite

notesEditor.setText(data);
notesContainer.add(notesEditor, BorderLayout.CENTER);
notesContainer.setBorder(new EmptyBorder(10, 10, 10, 10));

代码示例来源:origin: deathmarine/Luyten

if (message.contains("\n")) {
  for (String s : message.split("\n")) {
    pane.add(new JLabel(s));
  pane.add(new JLabel(message));
pane.add(new JLabel(" \n")); // Whitespace
final JTextArea exception = new JTextArea(25, 100);
exception.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
exception.setText(stacktrace);
exception.addMouseListener(new MouseAdapter() {
  @Override

代码示例来源:origin: 4thline/cling

setResizable(true);
JTextArea textArea = new JTextArea();
JScrollPane textPane = new JScrollPane(textArea);
textPane.setPreferredSize(new Dimension(500, 400));
textArea.setText(pretty);

代码示例来源:origin: eclipse/hono

private JPanel getTriggerTypePanel() {
  final JPanel triggerOuterPanel = new VerticalPanel(50, 0.0F);
  triggerOuterPanel.setBorder(
      BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Commands triggered by"));
  final JPanel triggerPanel = new JPanel(new BorderLayout(10, 50));
  setDescriptionTextAreaDesign(triggerTypeDescription, triggerPanel);
  triggerPanel.add(triggerType, BorderLayout.LINE_START);
  triggerPanel.add(triggerTypeDescription, BorderLayout.CENTER);
  triggerType.addActionListener(e -> triggerTypeDescription.setText(getDescriptionTextForSelectedTrigger()));
  triggerOuterPanel.add(triggerPanel);
  return triggerOuterPanel;
}

代码示例来源:origin: kiegroup/jbpm

getRootPane().add(panel, BorderLayout.CENTER);
JTextArea params = new JTextArea();
params.setText(getParameters());
params.setEditable(false);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(5, 5, 5, 5);
panel.add(params, c);
c.gridy = 1;
c.insets = new Insets(5, 5, 5, 5);
panel.add(resultName, c);
resultNameTextField = new JTextField();
c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
panel.add(resultNameTextField, c);

代码示例来源:origin: FudanNLP/fnlp

void init(){		
  textIn=new JTextArea();
  textIn.setLineWrap(false);
  textIn.setWrapStyleWord(true);
  textOut=new JTextArea();
  textOut.setLineWrap(false);
  textOut.setWrapStyleWord(true);
  textOut.setEditable(false);
  textOut.setText("");
  jspOut=new JScrollPane(textOut);
  jspOut.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

代码示例来源:origin: apache/felix

public LogPanel() {
  super(new BorderLayout());
  logArea.setText("");
  //add(new JScrollPane(new JTextArea(4,80)));
  add(scroll);
  statusBar.add(statusText,BorderLayout.EAST);
  add(statusBar,BorderLayout.SOUTH);
  }

代码示例来源:origin: kiegroup/optaplanner

buttonPanel.add(new JButton(okAction));
if (!solutionBusiness.isConstraintMatchEnabled()) {
  JPanel unsupportedPanel = new JPanel(new BorderLayout());
  JLabel unsupportedLabel = new JLabel("Constraint matches are not supported with this ScoreDirector.");
  unsupportedPanel.add(unsupportedLabel, BorderLayout.CENTER);
  unsupportedPanel.add(buttonPanel, BorderLayout.SOUTH);
  setContentPane(unsupportedPanel);
} else {
  detailLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
  bottomPanel.add(detailLabel, BorderLayout.NORTH);
  final JTextArea detailTextArea = new JTextArea(10, 80);
  JScrollPane detailScrollPane = new JScrollPane(detailTextArea);
  bottomPanel.add(detailScrollPane, BorderLayout.CENTER);
        int selectedRow = table.getSelectedRow();
        if (selectedRow < 0) {
          detailTextArea.setText("");
        } else {
          ConstraintMatchTotal constraintMatchTotal
              = constraintMatchTotalList.get(selectedRow);
          detailTextArea.setText(buildConstraintMatchSetText(constraintMatchTotal));
          detailTextArea.setCaretPosition(0);

代码示例来源:origin: marytts/marytts

lSizeValue = new javax.swing.JLabel();
spDescription = new javax.swing.JScrollPane();
taDescription = new javax.swing.JTextArea();
lStatus = new javax.swing.JLabel();
lStatusValue = new javax.swing.JLabel();
taDescription.setLineWrap(true);
taDescription.setRows(2);
taDescription.setText(desc.getDescription());
spDescription.setViewportView(taDescription);

代码示例来源:origin: stackoverflow.com

l = new JLabel("icon"); // <-- this will be an icon instead of a
iconPanel.add(l, BorderLayout.NORTH);
p.add(iconPanel, BorderLayout.WEST);
ta = new JTextArea();
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
p.add(ta, BorderLayout.CENTER);
  final boolean hasFocus) {
ta.setText((String) value);
int width = list.getWidth();

代码示例来源:origin: marytts/marytts

lSizeValue = new javax.swing.JLabel();
spDescription = new javax.swing.JScrollPane();
taDescription = new javax.swing.JTextArea();
lStatus = new javax.swing.JLabel();
lStatusValue = new javax.swing.JLabel();
taDescription.setLineWrap(true);
taDescription.setRows(2);
taDescription.setText(desc.getDescription());
spDescription.setViewportView(taDescription);

代码示例来源:origin: nodebox/nodebox

innerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JLabel messageLabel = new JLabel("<html><b>Error: </b>" + exception.getMessage() + " " + extraMessage + "</html>");
JTextArea textArea = new JTextArea();
textArea.setFont(Theme.EDITOR_FONT);
StringWriter sw = new StringWriter();
exception.printStackTrace(pw);
log = sw.toString();
textArea.setText(log);
textArea.setEditable(false);
textArea.setCaretPosition(0);
JScrollPane scrollPane = new JScrollPane(textArea);
innerPanel.add(messageLabel, BorderLayout.NORTH);
innerPanel.add(scrollPane, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10, 10));
if (showQuitButton) {
  buttonPanel.add(quitButton);

相关文章

JTextArea类方法