Solved

How to add a class as row-element in a table cell?

Posted on 2004-10-26
150 Views
Last Modified: 2010-03-31
I asked a similar question yesterday. Now what I want is to add a class as element into the table cell. This class is a DesktopPane and has some components such as button on it. It looks as follow:

public class AddToken extends JDesktopPane implements ComponentListener{

private JButton jButtonAddButton = null;
      
AddToken(){
  initialize();
}
      

private void initialize() {
 // TODO Automatisch erstellter Methoden-Stub
 addComponents();
}

private void addComponents() {
 // TODO Automatisch erstellter Methoden-Stub
 this.add(getJButtonAddButton(), null);
}

private Component getJButtonAddButton() {
// TODO Automatisch erstellter Methoden-Stub
 if(jButtonAddButton == null){
  jButtonAddButton = new JButton();
  jButtonAddButton.setText("Set");
  jButtonAddButton.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12));
                    jButtonAddButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  jButtonAddButton.setSize(60,23);
  jButtonAddButton.setLocation(5,5);
 
  return jButtonAddButton;
}

}
0
Question by:chenwei
    4 Comments
     
    LVL 92

    Expert Comment

    by:objects
    you can add whatever object you want as a table cell value.
    0
     
    LVL 92

    Expert Comment

    by:objects
    use a cell renderer to define how you want it displayed.
    0
     
    LVL 92

    Accepted Solution

    by:
    Lots of examples of cell renderers at:

    http://www.objects.com.au/java/examples.do
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    Well, you can let your table cell renderer return whatever component you want.
    Don't know hows that going to look however ;°)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    Using Tomcat as raspberry pi java app server 13 55
    scores100 challenge 3 49
    Fibonacci challenge 11 45
    json format text only 4 14
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    The viewer will learn how to implement Singleton Design Pattern in Java.

    931 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

    22 Experts available now in Live!

    Get 1:1 Help Now