Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Help in netbeans

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Help in netbeans

    Hi guys well, i don't know how to call an option of a bottomgroup and put it on a textfield in another jframe, i'm making a program in Netbeans using jframes so, i'm a begginer and i don't know it all, i hope you can help me, i can't put the code lines cause i've said i made many jframes, i will put an example about what i wanna do:

    For example here's a list of phone brands in the first jframe in a bottomgroup:
    Sony
    Samsung
    Nokia

    so, if I select Sony, I want the text i've selected appears in a textfield in another jframe of this way:

    You have selected Sony.

    I hope you can understand what im trying to do, thank you and regards.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Help in netbeans

    Can you make a small, complete program that compiles, executes and shows the problem? It should have the minimum code needed to show the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Re: Help in netbeans

    Quote Originally Posted by Norm View Post
    Can you make a small, complete program that compiles, executes and shows the problem? It should have the minimum code needed to show the problem.
    this is a small code i made, this is where i put a combobox with brands to select:
    public class prueba2 extends javax.swing.JFrame {
     
     
        public prueba2() {
            initComponents();
        }
     
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            select = new javax.swing.JComboBox();
            jLabel1 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(null);
     
            select.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select", "Sony", "Samsung", "Acer" }));
            getContentPane().add(select);
            select.setBounds(87, 67, 94, 20);
     
            jLabel1.setText("Select your brand");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(80, 30, 110, 20);
     
            pack();
        }// </editor-fold>                        
     
        public static void main(String args[]) {
     
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new prueba2().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JLabel jLabel1;
        private javax.swing.JComboBox select;
        // End of variables declaration                   
    }
     
    and this is the second jframe, where i want to put what i've selected before in a textfield
     
     
    public class prueba1 extends javax.swing.JFrame {
     
        public prueba1() {
            initComponents();
        }
     
     
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            receive1 = new javax.swing.JTextField();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(null);
            getContentPane().add(receive1);
            receive1.setBounds(103, 87, 146, 31);
     
            pack();
        }// </editor-fold>                        
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
     
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new prueba1().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JTextField receive1;
        // End of variables declaration                   
    }
    and i don't know how to make it
    Last edited by Norm; June 23rd, 2014 at 05:32 PM. Reason: added code tags

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Help in netbeans

    You have posted two separate, independent classes which would be executed as separate programs.
    Where is there supposed to be any connection between these two classes?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help in netbeans

    It's the same project but in two differents Jframes, which connection are you talking about? i don't know how to make those connections, it's a homwork for vacations, i will explain how i made it when im at school again, i hope dont bother, but i really need help, It's my 1st semester at System Computer Enginnering on a Technologic Institute

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Help in netbeans

    One confusing part is that both classes have main() methods indicating that they are intended to be executed as the MAIN program. One of the classes must be subordinate to the other. One class is the main class that starts the execution for the program. That class will then create an instance of the second program as needed using the new statement. When that instance is created in the first class, the reference to the instance of the second class should be saved so that the two classes are connected so that methods in the first class can call methods in the second class. For example to pass the selected item from the combobox to go in the textfield.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jun 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help in netbeans

    oh, so, I have to create a new project with a class as main and then the Jframes?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Help in netbeans

    Sorry, I don't know anything about netbeans's projects.

    One of the classes needs to have a main() method where the program's execution starts. The code in that class can create instances of all the other classes that are needed for the program to do what its going to do.
    For example a method in preuba2 has this statement that creates an instance of a combo box:
    select = new javax.swing.JComboBox();
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Jun 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help in netbeans

    Ok, don't worry but you help me a lot with that information, thank you, i got an idea about what you are saying, thank you very much

Similar Threads

  1. NetBeans help please!
    By JuLiAnc in forum AWT / Java Swing
    Replies: 4
    Last Post: January 9th, 2012, 05:16 AM
  2. Netbeans 6.8
    By selmaky in forum Java IDEs
    Replies: 1
    Last Post: May 14th, 2011, 03:08 PM
  3. New to NetBeans
    By _lithium_ in forum Java IDEs
    Replies: 0
    Last Post: March 1st, 2011, 07:48 PM
  4. netbeans project
    By wrmaina in forum Java Theory & Questions
    Replies: 1
    Last Post: July 14th, 2010, 02:39 AM
  5. Netbeans help
    By [Kyle] in forum Java IDEs
    Replies: 2
    Last Post: September 20th, 2009, 06:32 PM