How do I programatically add a component to my GUI?

Posted on 2008-11-04
Last Modified: 2013-12-14
  I create a standard Java Desktop Application in NetBeans 6.1.  I'm trying to add a JButton via code to a JPannel with no success.  How do I add a component to a JPanel?

Question by:pbenito
    LVL 59

    Expert Comment

    by:Kevin Cross
    What code have you tried so far?

    hint: JPanel has an add method.

    Post your code attempt and will assist you will refining.
    LVL 59

    Accepted Solution

    This may be helpful.

    Java Tutorial on Swing/UI Development:

    Example of JPanel with components:

    As I said above, I will be glad to assist with any questions you have in getting this functioning for you.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now