COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

JTable Column with Multiple Types

• Email
• Follow

I'm very new to Java Swing and I'm trying to create a JTable.  I need a
column of the table to display multiple types, such as a String in row
1, a JComboBox in row2, and a JRadioButton in row 3 for example.

I'm working on an editor of sorts and I need to create a table to
display the properties of a selected component.  Something like a 2
column Property/Value Table where the value may be any object such as a
string, a list of possible values in a comboBox, etc.

Any help or code snipets would be greatly appreciated!


 0

See related articles to this posting

see
http://www.projectcool.com/tips/Tip/15851

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200604/1

 0

MikeSmith813@gmail.com wrote:
> I'm very new to Java Swing and I'm trying to create a JTable.  I need a
> column of the table to display multiple types, such as a String in row
> 1, a JComboBox in row2, and a JRadioButton in row 3 for example.
>
> I'm working on an editor of sorts and I need to create a table to
> display the properties of a selected component.  Something like a 2
> column Property/Value Table where the value may be any object such as a
> string, a list of possible values in a comboBox, etc.
>
> Any help or code snipets would be greatly appreciated!
>

I see here 2 ways:
1. May be you want to change table structure -
instead of having table with 2 columns (property name - value)
you may have table with 2 rows (name - value) or even with one row
and column header as "names" part.
2. Override
JTable:public Component prepareRenderer(TableCellRenderer renderer, int
row, int column)

where you may return component you want.

If you want your table to be editable see prepareEditor.

 0

2 Replies
975 Views

Similar Articles

12/11/2013 9:48:11 PM
page loaded in 173598 ms. (0)

Similar Artilces:

Storing multiple character set types (or a representation of em) in a table column
Hi, I'm currently building an online tool designed to help users learn a foreign language. It's aim is to allow the user to enter their own vocabulary and they can quiz themselves. This involved entrering their native word and then the foriend language equivelent. Kind of a flashcard system but restricted to the words that the user has previously entered - perhaps specific to the textbook they're currently learning. One of the things I want to allow is to support multiple character sets though (e.g. alphanumeric, japanese, chinese...). I don't want the system to b...

Aesthetics when spanning multiple columns and multiple rows in a table
I can make the cell of a table span multiple columns and multiple rows, but I end up with a yucky mess, like this: http://homepage.mac.com/andrew_j_stewart/table_yuk.jpg Here is the code that created that table: \documentclass[10pt,letterpaper]{article} \usepackage{multirow} \begin{document} \begin{tabular}{| c | c | c |} \hline 1 & 2 & 3 \\ \hline \multicolumn{2}{|c|}{\multirow{2}{*}{4,5,7,8}} & 6 \\ \hline & & 9 \\ \hline 10 & 11 & 12 \\ \hline \end{tabular} \end{document} I can trim the excess vertical lines by removing them from the tabular definitio...

Elegant SQL placing multiple row columns in a single row column.
Dear All, wonder if anyone can help? A colleague constructed some SQL below and asked if there was a more elegant solution. As I'm an aged RPG programmer wasn't of much help I'm afraid. Anybody got a better solution? All input gratefully received. Best Regards Ian PS Apologies beforehand if this is simple and I'm being simple. *************************************************************************************************************** Hi Ian, Here was the messy solution... select distinct EAN, ADDNO, strip(r...

Data Integration Studio: Bug in SCD type 2 Loader when using Type 1 Columns?
I am using the SCD type 2 loader in Data Integration Studio. I have some type 2 columns but also some type 1. I marked this type 1 columns in the 'Type 1 Columns tab', but when I load a new row with a new value for this columns it only updates the last row for the matching Business Key and not for all rows of thet Business Key. This looks to me like incorrect behaviour. I could not find anything to change this. So I have currently the following row in the target dimension table ProductSkey=1; ProductName(BusinessKey)='Shoes'; ProductDescription(SCD type 1 and selec...

Lists of multiple types
Is there any way to create a List in C++ like a List in Lisp where the item at each index in the list could potentially be of a different type? In example of what could be in such a list: theListClass list = {2.0, 1, "Some String", 100000000}; so the types in the above imaginary list could be {double,int,const char*,long} Is there a way to do this? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] andy.canfield@gmail.com wrote: > Is there any way to create a List in C++ like a List in Lisp ...

Nasir Mahmood Sep 6, 8:20 pm show options Newsgroups: comp.unix.shell From: "Nasir Mahmood" <goooglegro...@yahoo.com> - Find messages by this author Date: 6 Sep 2005 08:20:28 -0700 Local: Tues, Sep 6 2005 8:20 pm Subject: Multiple columns to add up Reply | Reply to Author | Forward | Print | Individual Message | Show original | Remove | Report Abuse Hello all, I have three files ---------------- File1 ---------------- col1 col1 col1 col1 col1 ---------------- File2 ---------------- col2 col2 col2 col2 col2 ---------------- File3 ---------------- col3 col3 col3 col3...

mysql column type
hi,guys. I want ask a question, if i set a column type int(64), can it insert into a 64 bits number ? thanks john wrote: > hi,guys. I want ask a question, if i set a column type int(64), can > it insert into a 64 bits number ? thanks http://dev.mysql.com/doc/refman/5.1/en/integer-types.html tells you want you need to know. INT is a 64 bit entity. In article <b5e450c9-2f4f-45c4-b189-43a571766400@q30g2000yqj.googlegroups.com>, john <linxiuzhang2008@gmail.com> wrote: > hi,guys. I want ask a question, if i set a column type int(64), can > it insert into a 6...

Multiple columns in \listof ?
I am using the toclof to create customized \listof commands. What I would like is for the entries to the list (but not the list title) to be set in multiple columns. i.e. \begin{multicol}[2] \listoffoo \end{multicol} does not do what I want -- it places the list title in the first column, rather than spanning across both columns. Is there any reasonably simple way to do this? Nathan "Nathan Weston" <elbows@spamcop.net> wrote in message news:58ef839a.0401081432.df98be3@posting.google.com... > I am using the toclof to create customized \listof commands. What I > would l...

JTable column width autofit

colortbl and p type of columns
Hi, i wonder what i do wrong in the following mwe: \documentclass[border=5mm]{standalone} \usepackage{xcolor,colortbl} \begin{document} \begin{tabular}{% >{\columncolor{yellow!20}[0.8\tabcolsep]\raggedright}p{22mm}% >{\columncolor{yellow!20}[0.8\tabcolsep]\raggedright}p{22mm}% >{\columncolor{yellow!20}[0.8\tabcolsep]\raggedright}p{22mm}% } control: & data: & management: \\ A & B & C \end{tabular} \end{document} i receive error: ! extra alignment tab has been changed to...

Storing JTable columns configuration
Is there any source code online that implements storing all JTable columns(size, name etc.) info in a file on exit and loading on startup? Thanks! ...

Multiple JTables with headers in a JScrollPane
I'm trying to get multiple JTables each displayed entirely with their own headers to show up in one containing JScrollPane (through an intermediary JPanel container). Any ideas on how to do this, since by adding a JTable to a JPanel, avoids the headers showing up (something to do with JTable.addNotify() which calls the configureEnclosingScrollPane method, which states: "If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll ...

modify column of SET type
Suppose I add column to test_table, such as: ALTER TABLE test_table ADD COLUMN (cats SET('foo','bar')); Then I want to add 'woot' as a possible value of cats. It seems that I want to MODIFY COLUMN, and this would do it: ALTER TABLE test_table MODIFY COLUMN cats SET('foo','bar','woot'); (and indeed testing seems to indicate this works). But suppose I don't know 'foo' and 'bar' and just want to add 'woot' to the SET values. Can I do this with one query? -- Lars Eighner <http://larseighner.com/> ...

Sorting JTable with fixed column
I need to make a jtable with these requirements: - The first two columns fixed - It should sort the rows by clicking on the headers name By clicking on the column header both columns need to be sorted domenico.test@gmail.com wrote in news:1140368789.831896.67720 @g14g2000cwa.googlegroups.com: > I need to make a jtable with these requirements: > - The first two columns fixed > - It should sort the rows by clicking on the headers name > > By clicking on the column header both columns need to be sorted > > http://java.sun.com/docs/books/tutorial/uiswing/components/tab...

Hide column in SW2005-type BOM
Is there a trick to hide a column in a BOM table (not an Excel type)? The official way, as described in the help system, does not work (this is acknowledged by a SW tech). I need to hide the PartNo column, but since it is needed for the BOM to work, I can't just delete it. I get my "true" part number from a title block in a parts drawing version of the part. Nordtorp I have also verified this as an issue. However I think I had found a workaround from someone on this newsgroup. you can move the part number column to the beginning or the end (you might want to save your templa...

Add values of columns of multiples lines
Hi guys, i am really new to shell scripting and need some help. :-( I have the output from iptables and want to sum the byte values of the second column together in one variable. An fragment of iptables output i give below. How can i do this summing? Chain IN_FORWARD (83 references) pkts bytes target prot opt in out 33 456 ACCEPT tcp -- any spt:26 4430 5359 ACCEPT tcp -- any spt:www 0 0 ACCEPT tcp -- any spt:81 Thanks Ren� On 2005-07-14, Ren� Scheibe wrote: > Hi guys, > > i am really new to shell scripting and need some help....

Jtable with large columns scrolling issue
In one of my project, the jtable has 160 columns and 100 rows. I have vector as a data model. The problem is the jtable is very slow to scroll. Even if I switch applications and come back to this Jtable it grays out for few seconds as it is printing each cell again. How do i improve this performance. Which is the best data model to use for large tables. How do i restrict the painting to only the visible cells in the viewport rather than all the cells in jtable. I have the jtable.settooltiptext(null) already set but not much improvement please advise thanks Kamlesh njethwa@gmail.com ...

jTable column width and components size
Hi, I googled for this simple question wih no success... I use a JTable containing checkboxes, spinners, etc... How can I set the column width to closely match the size of a given components ? ( I have a clear idea of the longest content those components will receive, so I really do not need dynanmic- ou user-resizing ) I tried this : 1- computing the size of the component; eg. for the chechbox : <snippet> public class TableUtils { public static int getDefaultCheckboxSize() { int size; JCheckBox cb = new JCheckBox(); size = cb.getUI().getMinimumSize(cb).width; return size; ...

menu -tearoff appearance with multiple columns
The tearoff marker in menus shows only in the first column. This looks a bit ugly. Is the behaviour intentional, or would it be worth a change request? E.g. pack [menubutton .m -text menu -menu .m.m] menu .m.m .m.m add command -label "col 1" .m.m add command -label "col 2" -columnbreak 1 currently looks like this in tk 8.3 or 8.4.6 ----- col2 col 1 where I'd rather have it look like this ---------- col1 col2 R' ...