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

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

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

JTextArea.setEditable介绍

暂无

代码示例

代码示例来源: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: 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: 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.netbeans.api/org-openide-dialogs

JTextArea area = new JTextArea((String) newMessage);
area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
area.setBackground(UIManager.getColor("Label.background")); // NOI18N
area.setBorder(BorderFactory.createEmptyBorder());
area.setLineWrap(true);
area.setWrapStyleWord(true);
area.setEditable(false);
area.setFocusable(true);
area.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NotifyDescriptor.class, "ACN_NotifyDescriptor_MessageJTextArea")); // NOI18N

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

private Component text() {
  license = new JTextArea();
  license.setFont(getFont());
  license.setBackground(getBackground());
  license.setEditable(false);
  license.setBorder(BorderFactory.createCompoundBorder(
      BorderFactory.createLineBorder(Color.GRAY), 
      emptyBorder()));
  return license;
}

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

/** Create content of this MainFrame. */
private void createContent() {
  setLayout(new BorderLayout());
  textArea = new JTextArea(20, 15);
  textArea.setEditable(false);
  final JScrollPane textAreaScrollPane = new JScrollPane(textArea);
  treeTable = new TreeTable(model.getParseTreeTableModel());
  treeTable.setEditor(textArea);
  treeTable.setLinePositionMap(model.getLinesToPosition());
  final JScrollPane treeTableScrollPane = new JScrollPane(treeTable);
  final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treeTableScrollPane,
    textAreaScrollPane);
  add(splitPane, BorderLayout.CENTER);
  splitPane.setResizeWeight(0.7);
  add(createButtonsPanel(), BorderLayout.PAGE_END);
  pack();
}

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

/**
 * Retourne une étiquette pour la composante spécifiée. Le texte de l'étiquette pourra
 * éventuellement être distribué sur plusieurs lignes.
 *
 * @param owner Composante pour laquelle on construit une étiquette. L'étiquette aura la même
 *     largeur que {@code owner}.
 * @param text Texte à placer dans l'étiquette.
 */
public static JComponent getMultilineLabelFor(final JComponent owner, final String text) {
  final JTextArea label = new JTextArea(text);
  final Dimension size = owner.getPreferredSize();
  size.height = label.getMaximumSize().height;
  label.setMaximumSize(size);
  label.setWrapStyleWord(true);
  label.setLineWrap(true);
  label.setEditable(false);
  label.setFocusable(false);
  label.setOpaque(false);
  label.setBorder(null); // Certains L&F placent une bordure.
  LookAndFeel.installColorsAndFont(
      label, "Label.background", "Label.foreground", "Label.font");
  return label;
}

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

private void addAdhocPacketPanel() {
  final JTextArea adhocMessages = new JTextArea();
  adhocMessages.setEditable(true);
  adhocMessages.setForeground(new Color(1, 94, 35));
  tabbedPane.add("Ad-hoc message", new JScrollPane(adhocMessages));
  tabbedPane.setToolTipTextAt(3, "Panel that allows you to send adhoc packets");

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

private JPanel makeResultsPanel() {
  JPanel resultsPanel = new JPanel();
  resultsPanel.setLayout(new BorderLayout());
  JScrollPane areaScrollPane = new JScrollPane(resultsTextArea);
  resultsTextArea.setEditable(false);
  areaScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  areaScrollPane.setPreferredSize(new Dimension(600, 300));
  resultsPanel.add(makeMatchList(), BorderLayout.WEST);
  resultsPanel.add(areaScrollPane, BorderLayout.CENTER);
  return resultsPanel;
}

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

/**
 * Creates new form NewJFrame
 */
public BroadcastHistoryFrame() {
  BroadcastHistoryArea = new javax.swing.JTextArea();
  BroadcastHistoryArea.setEditable(false);
  BroadcastHistoryArea.setLineWrap(true);
  BroadcastHistoryArea.setWrapStyleWord(true);
  initComponents();
}

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

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

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

public static void main ( String[] args )
{
  JPanel middlePanel = new JPanel ();
  middlePanel.setBorder ( new TitledBorder ( new EtchedBorder (), "Display Area" ) );

  // create the middle panel components

  JTextArea display = new JTextArea ( 16, 58 );
  display.setEditable ( false ); // set textArea non-editable
  JScrollPane scroll = new JScrollPane ( display );
  scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );

  //Add Textarea in to middle panel
  middlePanel.add ( scroll );

  // My code
  JFrame frame = new JFrame ();
  frame.add ( middlePanel );
  frame.pack ();
  frame.setLocationRelativeTo ( null );
  frame.setVisible ( true );
}

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

void init(){		
  textIn=new JTextArea();
  textIn.setLineWrap(false);
  textIn.setWrapStyleWord(true);
  jspIn=new JScrollPane(textIn);
  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: Exslims/MercuryTrade

public JTextArea getSimpleTextArea(String text) {
  JTextArea area = new JTextArea(text);
  area.setEditable(false);
  area.setWrapStyleWord(true);
  area.setLineWrap(true);
  area.setBackground(AppThemeColor.TRANSPARENT);
  area.setBorder(null);
  area.setFont(REGULAR_FONT.deriveFont(scale * 16f));
  area.setForeground(AppThemeColor.TEXT_DEFAULT);
  return area;
}

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

lSize = new javax.swing.JLabel();
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.setEditable(false);
taDescription.setFont(new java.awt.Font("Courier New", 0, 10));
taDescription.setLineWrap(true);
taDescription.setRows(2);
taDescription.setText(desc.getDescription());

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

JTextArea ta = new JTextArea();
ta.setEditable(false);
ta.setLineWrap(true);
ta.setOpaque(false);
ta.setWrapStyleWord(false); // This makes wrapping on char boundaries, and I think is the default value

相关文章

JTextArea类方法