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

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

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

JTextArea.<init>介绍

暂无

代码示例

代码示例来源:origin: bonnyfone/vectalign

private String showInputDialog(String title, String defaultText){
  JTextArea msg = new JTextArea(defaultText);
  msg.setLineWrap(true);
  msg.setWrapStyleWord(true);
  JScrollPane scrollPane = new JScrollPane(msg);
  scrollPane.setPreferredSize(new Dimension(600, 250));
  scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  int ris = JOptionPane.showConfirmDialog(null, scrollPane, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
  if(ris == JOptionPane.OK_OPTION)
    return msg.getText();
  else
    return defaultText;
}

代码示例来源:origin: alibaba/druid

/**
 * 将各个界面添加到JFrame中
 * 
 * @param pane JFrame内部的Container对象
 */
private void addComponentsToPane(Container pane) {
  JScrollPane scrollPane = new JScrollPane();
  JPanel contentPanel = new JPanel();
  contentPanel.setLayout(new GridLayout(0, 1));
  final JTextArea sqlField = new JTextArea(formatSql, 8, 20);
  final JScrollPane content1 = new JScrollPane(sqlField);
  content1.setBorder((TitledBorder) BorderFactory.createTitledBorder("SQL语句"));
  contentPanel.add(content1);
  addTable(contentPanel, "解析信息", parseData);
  addTable(contentPanel, "上次慢查询信息", lastSlowData);
  addTable(contentPanel, "上次错误查询信息", lastErrorData);
  addTable(contentPanel, "其他信息", otherData);
  scrollPane.setViewportView(contentPanel);
  pane.add(scrollPane, BorderLayout.CENTER);
}

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

JFrame f = new JFrame("Frame " + ii);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
String s =
  "os.name: " + System.getProperty("os.name") +
  "\nos.version: " + System.getProperty("os.version");
f.add(new JTextArea(s,3,28));  // suggest a size
f.pack();
f.setVisible(true);

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

JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new FindTextPane());
findButton = new JButton("Next");
findField = new JTextField("Java", 10);
textArea = new JTextArea();
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);

代码示例来源:origin: igniterealtime/Smack

frame = new JFrame("Smack Debug Window -- " + connection.getXMPPServiceDomain() + ":" +
    connection.getPort());
final JTextArea sentText1 = new JTextArea();
final JTextArea sentText2 = new JTextArea();
sentText1.setEditable(false);
sentText2.setEditable(false);
sentText1.setForeground(new Color(112, 3, 3));
sentText2.setForeground(new Color(112, 3, 3));
allPane.add(new JScrollPane(sentText1));
tabbedPane.add("Sent", new JScrollPane(sentText2));
final JTextArea receivedText1 = new JTextArea();
final JTextArea receivedText2 = new JTextArea();
receivedText1.setEditable(false);
receivedText2.setEditable(false);
receivedText1.setForeground(new Color(6, 76, 133));
receivedText2.setForeground(new Color(6, 76, 133));
allPane.add(new JScrollPane(receivedText1));
tabbedPane.add("Received", new JScrollPane(receivedText2));
menu.add(menuItem2);
frame.getContentPane().add(tabbedPane);

代码示例来源: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: IanDarwin/javasrc

public static void main(String[] args) {
    JFrame jf = new JFrame("whoo");
    Container cp = jf.getContentPane();
    cp.add(new JTextArea(10, 10));
    jf.pack();
    jf.setVisible(true);
  }
}

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

getContentPane().add(
  descriptionPanel,
  new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0,
descriptionPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black));
  JTextArea descriptionText = new JTextArea(description);
  descriptionPanel.add(descriptionText, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
getContentPane().add(
  panel,
  new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0,
getContentPane().add(
  buttonPanel,
  new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,

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

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class Main{
  public static void main( String [] args ) throws InterruptedException  {
    JFrame frame = new JFrame();
    frame.add( new JLabel(" Outout" ), BorderLayout.NORTH );

    JTextArea ta = new JTextArea();
    TextAreaOutputStream taos = new TextAreaOutputStream( ta, 60 );
    PrintStream ps = new PrintStream( taos );
    System.setOut( ps );
    System.setErr( ps );

    frame.add( new JScrollPane( ta )  );

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

    for( int i = 0 ; i < 100 ; i++ ) {
      System.out.println( i );
      Thread.sleep( 500 );
    }
  }
}

代码示例来源: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: kiegroup/optaplanner

private JComponent createDetailTextArea() {
  JPanel detailPanel = new JPanel(new BorderLayout());
  JLabel detailLabel = new JLabel("Details");
  detailPanel.add(detailLabel, BorderLayout.NORTH);
  detailTextArea = new JTextArea(5, 80);
  detailTextArea.setEditable(false);
  JScrollPane detailScrollPane = new JScrollPane(detailTextArea,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  detailPanel.add(detailScrollPane, BorderLayout.SOUTH);
  return detailPanel;
}

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

public static void main(String[] args) {
    //Create GUI on EDT Thread
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {

         JFrame frame = new JFrame("JScroll Pane Test");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  

         JTextArea txtNotes = new JTextArea();
         txtNotes.setText("Hello World");
         JScrollPane scrollPane = new JScrollPane(txtNotes);
         frame.add(scrollPane);//add components

         frame.pack();
         frame.setVisible(true);//show (after adding components)
      }
    });
}

代码示例来源:origin: iTransformers/netTransformer

protected void showmessage (String message){
  if(message == null || message.equals("")) {
    return;
  }
  JFrame frame = new JFrame("IPsec Neighbours");
  JTextArea text;
  frame.setSize(300, 200);
  frame.getContentPane().setLayout(new BorderLayout());
  text = new JTextArea();
  text.setEditable(false);
  JScrollPane scrollPane = new JScrollPane(text);
  frame.getContentPane().add("Center", scrollPane);
  text.setText(message.toString());
  frame.setVisible(true);
}

代码示例来源:origin: fossasia/neurolab-desktop

content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
frame = new JFrame();
frame.setSize(400, 600);
frame.setLocationRelativeTo(null);
listenerTextList = new JTextArea();
listenerTextList.setEditable(false);
JScrollPane lPane = new JScrollPane(listenerTextList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
lPane.setPreferredSize(new Dimension(400, 200));
messageOutputTextList = new JTextArea();
messageOutputTextList.setPreferredSize(new Dimension(500, 360));
messageOutputTextList.setEditable(false);
JScrollPane mPane = new JScrollPane(messageOutputTextList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

JFrame frame = new JFrame();
Container cp = frame.getContentPane();
cp.add(new JTextArea());
frame.pack();
frame.setVisible(true);

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

getContentPane().add(
  descriptionPanel,
  new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0,
descriptionPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black));
  JTextArea descriptionText = new JTextArea(description);
  descriptionPanel.add(descriptionText, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
getContentPane().add(
  panel,
  new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0,
getContentPane().add(
  buttonPanel,
  new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,

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

JTabbedPane tb = new JTabbedPane();
tb.setUI(new CustomTabbedPaneUI());
tb.add("Tab1", new JTextArea(""));
tb.add("Tab2", new JTextArea(""));
tb.add("Tab3", new JTextArea(""));
tb.add("Tab4", new JTextArea(""));
tb.add("Tab5", new JTextArea(""));
jp.add(tb, BorderLayout.CENTER);
add(jp, BorderLayout.CENTER);
tb.setEnabledAt(1, false);
tb.setEnabledAt(3, false);
JFrame frame = new JFrame();
frame.getContentPane().add(new TabbedPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 200);
frame.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: kiegroup/optaplanner

private JPanel createDescriptionPanel() {
  JPanel descriptionPanel = new JPanel(new BorderLayout(2, 2));
  descriptionPanel.add(new JLabel("Description"), BorderLayout.NORTH);
  descriptionTextArea = new JTextArea(8, 65);
  descriptionTextArea.setEditable(false);
  descriptionTextArea.setLineWrap(true);
  descriptionTextArea.setWrapStyleWord(true);
  descriptionPanel.add(new JScrollPane(descriptionTextArea,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
  return descriptionPanel;
}

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

final JFrame frame = new JFrame("JTextArea Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextArea textArea = new JTextArea(
    "If there is anything the nonconformist hates worse " +
    "than a conformist, it's another nonconformist who " +

相关文章

JTextArea类方法