Witam,
od paru dni ucze sie swinga i tworze jakies tam ui. To co mam:

  • mam kilka paneli w tabbedPane
  • domyslnie kazdy taki panel zawiera dwa TextFieldy i TextArea
  • w menu jest InputDialog ktory posiada kilka wyborow
    To co chce zrobic to po wyborze ktorejs z opcji z InputDialogu chcialbym zeby do panelu w tabbedPane zostal dodany jakis komponent powiedzmy JLabel.
    fragmentu kod ktory jak na razie mam to:
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        NameSurname msg = new NameSurname();
        int n = JOptionPane.showConfirmDialog(
                this,
                msg,
                "Name",
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE);
        System.out.println(n);
        if (n == 0) {
            //check the values
            //pass the values to Tab
            //name the Tab
            String name = msg.getNam();
            String surname = msg.getSurname();
            JScrollPane jsp = new JScrollPane(new Tab(name, surname));
            if (name.length() > 0 && surname.length() > 0
                    && name != null && surname != null) {
                jTabbedPane1.addTab(name + " " + surname, jsp);
            }

        }
        //ustawia skrot alt+# jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_1);
    }                                          

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        System.out.println("selected pane: " + jTabbedPane1.getSelectedIndex());
        Object[] possibilities = {"Label", "button"};
        String s = (String) JOptionPane.showInputDialog(
                null,
                "Wybierz z listy ",
                "Dodaj...",
                JOptionPane.PLAIN_MESSAGE,
                null,
                possibilities,
                "Label");

        //If a string was returned, s.
        if ((s != null) && (s.length() > 0)) {
            System.out.println((jTabbedPane1.getSelectedComponent()).toString());
            return;
        }
    }     

Fragment Klasy Tab:

public class Tab extends javax.swing.JPanel {

    /** Creates new form Tab */
    public Tab() {
        initComponents();
    }

    public Tab(String name, String surname) {
        initComponents();
        jTextField1.setText(name + " " + surname);
    }

   
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        //jTextField1.setText("");
        jTextField2.setText("");
        jTextArea1.setText("");
    }

i tutaj wlasnie chcialbym jakos dodac np. JLabela. Jakies wskazowki? z gory dzieki!
pozdrawiam
RK