⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demojtextareaframe.java

📁 精通NetBeans光盘源代码,很好很好的资料
💻 JAVA
字号:
/*
 * DemoJTextAreaFrame.java
 *
 * Created on 2006年3月17日, 下午1:03
 */

package org.netbeans.swing.container;

/**
 *
 * @author  boyingking
 */
public class DemoJTextAreaFrame extends javax.swing.JFrame {
    
    /** Creates new form DemoJTextAreaFrame */
    public DemoJTextAreaFrame() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaTest = new javax.swing.JTextArea();
        jButtonWrap = new javax.swing.JButton();
        jButtonNoWrap = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JTextArea\u5e94\u7528\u793a\u4f8b");
        jTextAreaTest.setColumns(20);
        jTextAreaTest.setLineWrap(true);
        jTextAreaTest.setRows(5);
        jTextAreaTest.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTextAreaTest);

        jButtonWrap.setText(" \u6362\u884c");
        jButtonWrap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonWrapActionPerformed(evt);
            }
        });

        jButtonNoWrap.setText("\u4e0d\u6362\u884c");
        jButtonNoWrap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNoWrapActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(32, 32, 32)
                .add(jButtonWrap)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 48, Short.MAX_VALUE)
                .add(jButtonNoWrap)
                .add(42, 42, 42))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
                .add(23, 23, 23))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(20, 20, 20)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 114, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(14, 14, 14)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonWrap)
                    .add(jButtonNoWrap))
                .add(30, 30, 30))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonNoWrapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNoWrapActionPerformed
// TODO add your handling code here:
        this.jTextAreaTest.setLineWrap(false);
    }//GEN-LAST:event_jButtonNoWrapActionPerformed

    private void jButtonWrapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWrapActionPerformed
// TODO add your handling code here:
        this.jTextAreaTest.setLineWrap(true);
    }//GEN-LAST:event_jButtonWrapActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DemoJTextAreaFrame().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonNoWrap;
    private javax.swing.JButton jButtonWrap;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextAreaTest;
    // End of variables declaration//GEN-END:variables
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -