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

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

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

JTextArea.append介绍

暂无

代码示例

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

final JTextArea area = new JTextArea();
    for (String line : chunks) area.append(line);

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

return;
final JFrame exceptionFrame = new JFrame("Uncaught exception: " + e.getMessage());
Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
BufferedImage errorImage = new BufferedImage(
errorIcon.paintIcon(null, errorImage.getGraphics(), 0, 0);
exceptionFrame.setIconImage(errorImage);
exceptionFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JPanel contentPanel = new JPanel(new BorderLayout(5, 5));
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
contentPanel.add(new JLabel("An uncaught exception has occurred: "), BorderLayout.NORTH);
JTextArea stackTraceTextArea = new JTextArea(30, 80);
stackTraceTextArea.setEditable(false);
stackTraceTextArea.setTabSize(4);
stackTraceTextArea.append(trace);
JScrollPane stackTraceScrollPane = new JScrollPane(stackTraceTextArea,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
contentPanel.add(stackTraceScrollPane, BorderLayout.CENTER);

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

@Override
 public void run() {
  JFrame testFrame = new JFrame( "FormattedTextFieldDemo" );
  integerFormattedTextField.setColumns( 20 );
  testFrame.add( createButtonPanel( integerFormattedTextField ), BorderLayout.NORTH );
  final JTextArea textArea = new JTextArea(50, 50);
  PropertyChangeListener updateTextAreaListener = new PropertyChangeListener() {
   @Override
   public void propertyChange( PropertyChangeEvent evt ) {
    textArea.append( "New value: " + evt.getNewValue() + "\n" );
  testFrame.add( new JScrollPane( textArea ), BorderLayout.CENTER );
  testFrame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
  testFrame.pack();
  testFrame.setVisible( true );
panel.add( aTextField, BorderLayout.WEST );

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

textArea = new JTextArea(5, 30);
button = new JButton();
add( new JScrollPane(textArea));
button.setPreferredSize(new Dimension(100, 100));
button.setText("Pause");
button.addActionListener(new ButtonListener());
add(button);
        textArea.append(Integer.toString(i) + ", ");

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

final JTextArea warningArea = new JTextArea();
  final JScrollPane scroll = new JScrollPane(warningArea);
  final JPanel namedArea = new JPanel(new BorderLayout());
  JProgressWindow.this.warningArea = warningArea;
warningArea.append((String) value);

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

JFrame jFrame = new JFrame();

JTextArea jTextArea = new JTextArea();
jTextArea.append( "Hello World." );

jFrame.add( jTextArea );

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

public class FrameGUI extends JFrame { // I'm not a fan of extending JFrames.
 // this variable is now visible throughout the class    
 private JTextArea textArea = new JTextArea(15, 40); // 15 rows, 40 columns
 public FrameGUI(String title) {
  super(title);
  setLayout(new BorderLayout());
  // final JTextArea textArea = new JTextArea();  //  *** commented out
  detailsPanel = new DetailsPanel();
  Container c = getContentPane();
  c.add(new JScrollPane(textArea), BorderLayout.CENTER); // put textarea into a scrollpane
  c.add(detailsPanel, BorderLayout.NORTH);
 }
 public void appendToTextArea(String text) {
  textArea.append(text);
 }

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

private final JFrame f = new JFrame();
private final JTextField tf = new JTextField(25);
private final JTextArea ta = new JTextArea(15, 25);
private final JButton send = new JButton("Send");
private volatile PrintWriter out;
  this.kind = kind;
  f.setTitle("Echo " + kind);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getRootPane().setDefaultButton(send);
  f.add(tf, BorderLayout.NORTH);
  f.add(new JScrollPane(ta), BorderLayout.CENTER);
  f.add(send, BorderLayout.SOUTH);
  f.setLocation(kind.offset, 300);
  f.pack();
  f.setVisible(true);
  thread.start();
      ta.append(s + "\u23CE\n");

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

JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(capturePane);
  output = new JTextArea();
  add(new JScrollPane(output));
public void appendText(final String text) {
  if (EventQueue.isDispatchThread()) {
    output.append(text);
    output.setCaretPosition(output.getText().length());
  } else {

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

mainPanel.add(textAreasPanel, BorderLayout.CENTER);
mainPanel.add(buttonsPanel, BorderLayout.PAGE_END);
  buttonsPanel.add(button);
   BoxLayout.PAGE_AXIS));
for (TextAreaDestination textDest : TextAreaDestination.values()) {
  JTextArea tArea = new JTextArea(TA_ROWS, TA_COLS);
  tArea.setName(textDest.getText());
  tArea.setWrapStyleWord(true);
  tArea.setLineWrap(true);
  impressionRecMap.put(textDest, tArea);
  JScrollPane scrollPane = new JScrollPane(tArea);
  JPanel outerPanel = new JPanel(new BorderLayout());
  outerPanel.setBorder(BorderFactory.createTitledBorder(textDest.getText()));
textArea.append(text);

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

@Override
protected Component getDetailsComponent() {
 if (this.detailsPanel == null) {
  final JTextArea textArea = new JTextArea();
  this.detailsPanel = new JScrollPane(textArea);
  textArea.setEditable(false);
  textArea.setLineWrap(false);
  textArea.setRows(15);
  textArea.setColumns(40);
  final StringWriter stringWriter = new StringWriter();
  ExceptionDialog.this.exceptionMessage.getThrowable().printStackTrace(new PrintWriter(stringWriter));
  textArea.append(stringWriter.getBuffer().toString());
 }
 return this.detailsPanel;
}

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

JTextArea textArea = new JTextArea();
textArea.setBounds(10, 11, 864, 540);
textArea.setWrapStyleWord(true);
getContentPane().add(textArea);
for (int i = 0; i < nodes.getLength();i++)
{
   Element element = (Element)nodes.item(i);

   textArea.append("Title: " + getElementValue(element,"title") + "\n");
   textArea.append("Link: " + getElementValue(element,"link") + "\n");
   textArea.append("Publish Date: " + getElementValue(element,"pubDate") + "\n"); 
}

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

class Sample { // no need to extend JFrame here

  public static void fn(int n) {
    JFrame f = new JFrame();
    JTextArea ta = new JTextArea();
    f.add(ta);
    f.setVisible(true);
    for(int i = 0; i < n; i++) {

      // ... *** don't create a new JFrame here ***

      ta.append(" step is done\n");

      // ... *** and don't create a new JFrame here ***

    }  
  }
}

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

JTextArea a = new JTextArea();

for (Shape ashape : a list)
{
  System.out.println(ashape.toString());
  a.append(ashape.toString() + "\n")
}

Container content = getContentPane(); 
content.add(display);

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

public class ComplexOptionPane extends JPanel {
  private PlayerEditorPanel playerEditorPanel = new PlayerEditorPanel();
  private JTextArea textArea = new JTextArea(20, 40);
   add(new JScrollPane(textArea));
   add(new JButton(new AbstractAction("Get Player Information") {
        for (PlayerEditorPanel.FieldTitle fieldTitle : 
         PlayerEditorPanel.FieldTitle.values()) {
         textArea.append(String.format("%10s: %s%n", fieldTitle.getTitle(),
            playerEditorPanel.getFieldText(fieldTitle)));
   ComplexOptionPane mainPanel = new ComplexOptionPane();
   JFrame frame = new JFrame("ComplexOptionPane");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.getContentPane().add(mainPanel);
   frame.pack();
   frame.setLocationByPlatform(true);
   frame.setVisible(true);

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

JFrame displayframe = new JFrame("All Details");
displayframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
displayframe.setLayout(new FlowLayout());

JTextArea text = new JTextArea(30,30);
text.setEditable(false);
text.append("22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs\n22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs\n22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs\n22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs22323sfasfs\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline123");

JScrollPane scroll = new JScrollPane(text);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

displayframe.getContentPane().add(scroll);
displayframe.setSize(400, 600);
displayframe.setVisible(true);

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

"The quick brown fox jumped over the lazy dog.  ";
final JTextArea textArea = new JTextArea(s,5,30);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
button.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae) {
      textArea.append(s);
panel.add(button, BorderLayout.NORTH);
panel.add(new JScrollPane(textArea), BorderLayout.CENTER);

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public ExceptionDialogTab(final ExceptionMessage message) {
 super(DialogMessages.ERROR, message, GuiIcons.EMPTY_ICON.getLargeIcon());
 final JTextArea textArea = new JTextArea();
 textArea.setEditable(false);
 textArea.setLineWrap(false);
 textArea.setRows(15);
 textArea.setColumns(25);
 final StringWriter stringWriter = new StringWriter();
 message.getThrowable().printStackTrace(new PrintWriter(stringWriter));
 textArea.append(stringWriter.getBuffer().toString());
 setComponent(new JScrollPane(textArea));
}

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

final JTextArea textDisplay = new JTextArea(10,48);
 ...
listButton.addActionListener(new ActionListener() 
  {
    public void actionPerformed(ActionEvent event) 
    {
    ...
    textDisplay.append("Student " + i);

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

public class JTextAreaTest {

  public static void main(String args[]){

    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    frame.add(panel);
    JTextArea textArea = new JTextArea(11,30);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setText("Hi how are you? Im testing this textarea and im seeing if it's wrapping words");
    textArea.append("SASASASASDASDASDASDASDASDADSASDASDASDASDAS");
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane);

    frame.pack();
    frame.setVisible(true);
  }

}

相关文章

JTextArea类方法