Organize items within JTexArea [closed]

-1

How do I get items from a combobox and put it in a jTextArea, one below the other?

Follow my code:

public class PW_XML extends javax.swing.JFrame {

    int Grade;
    int Frequencia;
    int AttackRN;
    int DistanciaFrag;
    int PHAttackMin;
    int PHAttackMax;
    int MGAttackMin;
    int MGAttackMax;
    int DurabilidadeMin;
    int DurabilidadeMax;
    int LVLReq;
    int STRReq;
    int CONReq;
    int AGIReq;
    int INTReq;
    int Ref12;
    int Ref;
    int BonusList;
    int Bonus;
    int Sockets;
    int Multiply;
    int ItemID;
    int Prof;
    String Maker;
    String SubType;
    String ItemName;

    public PW_XML() {
        initComponents();
    }

    private void btnDelGenerateActionPerformed(java.awt.event.ActionEvent evt) {                                               
        //JPCodigoGerado.setText("");
    }                                              

    private void btnResetAllActionPerformed(java.awt.event.ActionEvent evt) {                                            
        JtfSubType.setText("");
        JtfItemName.setText("");
        JtfGrade.setText("");
        JtfFrequencia.setText("");
        JtfAttackRN.setText("");
        JtfDistanciaFrag.setText("");
        JtfPHAttackMin.setText("");
        JtfPHAttackMax.setText("");
        JtfMGAttackMin.setText("");
        JtfMGAttackMax.setText("");
        JtfDurabilidadeMin.setText("");
        JtfDurabilidadeMax.setText("");
        JtfLVLReq.setText("");
        JtfSTRReq.setText("");
        JtfCONReq.setText("");
        JtfAGIReq.setText("");
        JtfINTReq.setText("");
        JtfReff.setText("");
        JtfRef.setText("");
        JtfSockets.setText("");
        JtfMultiply.setText("");
        JtfBonus.setText("");
        JtaBonusList.setText("");
        JtfItemID.setText("");
        JtfProf.setText("");
        JtfMaker.setText("");
    }                                           

    private void btnDelActionPerformed(java.awt.event.ActionEvent evt) {                                       
        JtaBonusList.setText("");
    }                                      

    private void btnUPActionPerformed(java.awt.event.ActionEvent evt) {                                      

    }                                     

    private void btnDownActionPerformed(java.awt.event.ActionEvent evt) {                                        

    }                                       

    private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {                                            

    }                                           

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                       

        JtaBonusList.setText (Jcb2AddItens.getSelectedItem().toString());
        JtaBonusList.setText (Jcb2AddItens.getSelectedItem() + JtfBonus.getText());        
        JtfSubType.setText (Jcb4SubType.getSelectedItem().toString());
        JtfItemName.setText (Jcb5ItemName.getSelectedItem().toString());        
    }                                      

    private void btnDelBonusActionPerformed(java.awt.event.ActionEvent evt) {                                            
        JtfBonus.setText("");
    }                                           

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PW_XML.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PW_XML.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PW_XML.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PW_XML.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PW_XML().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JComboBox<String> Jcb2AddItens;
    private javax.swing.JComboBox<String> Jcb3Type;
    private javax.swing.JComboBox<String> Jcb4SubType;
    private javax.swing.JComboBox<String> Jcb5ItemName;
    private javax.swing.JPanel JpCodigoGerado;
    private javax.swing.JTextArea JtaBonusList;
    private javax.swing.JTextField JtfAGIReq;
    private javax.swing.JTextField JtfAttackRN;
    private javax.swing.JTextField JtfBonus;
    private javax.swing.JTextField JtfCONReq;
    private javax.swing.JTextField JtfDistanciaFrag;
    private javax.swing.JTextField JtfDurabilidadeMax;
    private javax.swing.JTextField JtfDurabilidadeMin;
    private javax.swing.JTextField JtfFrequencia;
    private javax.swing.JTextField JtfGrade;
    private javax.swing.JTextField JtfINTReq;
    private javax.swing.JTextField JtfItemID;
    private javax.swing.JTextField JtfItemName;
    private javax.swing.JTextField JtfLVLReq;
    private javax.swing.JTextField JtfMGAttackMax;
    private javax.swing.JTextField JtfMGAttackMin;
    private javax.swing.JTextField JtfMaker;
    private javax.swing.JTextField JtfMultiply;
    private javax.swing.JTextField JtfPHAttackMax;
    private javax.swing.JTextField JtfPHAttackMin;
    private javax.swing.JTextField JtfProf;
    private javax.swing.JTextField JtfRef;
    private javax.swing.JTextField JtfReff;
    private javax.swing.JTextField JtfSTRReq;
    private javax.swing.JTextField JtfSockets;
    private javax.swing.JTextField JtfSubType;
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnDel;
    private javax.swing.JButton btnDelBonus;
    private javax.swing.JButton btnDelGenerate;
    private javax.swing.JButton btnDown;
    private javax.swing.JButton btnGenerate;
    private javax.swing.JButton btnResetAll;
    private javax.swing.JButton btnUP;
    private javax.swing.JComboBox<String> cb1Connect;
    private java.awt.Checkbox cbMultiply;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lbl1;
    private javax.swing.JLabel lbl2;
    private javax.swing.JLabel lblAGIReq;
    private javax.swing.JLabel lblAttackRN;
    private javax.swing.JLabel lblBonus;
    private javax.swing.JLabel lblBonusList;
    private javax.swing.JLabel lblCONReq;
    private javax.swing.JLabel lblConnect;
    private javax.swing.JLabel lblDesenvolvidopor;
    private javax.swing.JLabel lblDistanciaFrag;
    private javax.swing.JLabel lblDurabilidade;
    private javax.swing.JLabel lblFrequencia;
    private javax.swing.JLabel lblGiovaniVChaves;
    private javax.swing.JLabel lblGrade;
    private javax.swing.JLabel lblINTReq;
    private javax.swing.JLabel lblItemID;
    private javax.swing.JLabel lblItemName;
    private javax.swing.JLabel lblLVLReq;
    private javax.swing.JLabel lblMGAttack;
    private javax.swing.JLabel lblMaker;
    private javax.swing.JLabel lblPHAttack;
    private javax.swing.JLabel lblProf;
    private javax.swing.JLabel lblProgramador;
    private javax.swing.JLabel lblSTRReq;
    private javax.swing.JLabel lblSockets;
    private javax.swing.JLabel lblSubType;
    private javax.swing.JLabel lblType;
    // End of variables declaration                   
}

    
asked by anonymous 13.11.2018 / 00:53

1 answer

0
  

You did not provide a Minimum, Full and Verifiable example , so I'll give you a generic answer, if you can not adapt, please provide an example as per the link above so you can review your specific issue.

To add text to JTextArea , you do not normally use the setText() method, and yes append() . Just by passing the text to this method, it will concatenate the texts sequentially, so you can add a line break between the items to be displayed to bypass this behavior, using the method System.getProperty("line.separator") :

suaTextArea.append("algum texto");
suaTextArea.append(System.getProperty("line.separator"));
suaTextArea.append("outro texto");

In this way, you will insert the text (as long as the width of your textarea supports the size of the strings) as follows:

    
13.11.2018 / 02:30