Solved

JTable and JTextArea

Posted on 2002-06-13
8
661 Views
Last Modified: 2008-02-01
Currently i have a JTextArea embedded in a table cell.  BUT i don't want the row height to be the height of the text area.  what i want to have happen is that when a user clicks into the given cell it expands (the text area, not the table row) similar to how combo box does.

what would be the best way to do this?
0
Comment
Question by:bobbit31
8 Comments
 
LVL 7

Accepted Solution

by:
tomboshell earned 300 total points
ID: 7077528
Oh, it sounds like you want to activate a pop-up when the cell is activated.  That would be my suggestion.  Let me try a talk-through first.  1. Create a new class (maybe a JDialog) that would handle the text entry (a get/set method, loose focus method for activating the close.), implement the TableCellEditor interface.  2. create an instance of that class and register it as a cell editor for that column.

public class MyTEdit extends JDialog implements TableCellEditor {...}
...
.
.
//in the table creation area
TableColumn textColumn = table.GetColumn("TextArea");
textColumn.setCellEditor(new MyTEdit());


That should roughly do it.  Gives you a little something to play with, but I hope that the idea is clear enough.

Tom

0
 
LVL 18

Author Comment

by:bobbit31
ID: 7078334
yeah, that's kind of how i was thinking i had to do it... i thought there might be a different way where i didn't have to use JDialog but rather just use JTextArea.

i'll leave this open for a while to see if anyone else has some input.
0
 
LVL 4

Expert Comment

by:kylar
ID: 7084510
JComboBox uses a popup as well to display it's list when you click it.. It's about the only way to do what you want (that I can think of.)

Cheers,
Kylar
0
 
LVL 18

Author Comment

by:bobbit31
ID: 7097392
ok, sorry for the delay, i was working on another issue.

Ok, i have it set up more or less as shown above...

is it possible to get rid of the "Java Applet Window" in the status bar of the JDialog? If not, are there any suggestions as to what I should do to work around it (i don't want it there)...
0
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!

 
LVL 92

Expert Comment

by:objects
ID: 7097485
You'll need to sign your applet.
0
 
LVL 18

Author Comment

by:bobbit31
ID: 7099047
can anyone tell me how to get the damn location of the current table cell relative to the screen!!!

ie:
in my table cell i'm storing a JTextArea.

so in my getTableCellEditorComponent(...)
i do something like this:

JTextArea jta = (JTextArea) value;

jta.getX() returns 0
jta.getY() returns 0

jta.getLocationOnScreen().getX() returns error
"Component must be showing on the screen ..."

same for jta.getLocationOnScreen().getY()

i'm sure this isn't as difficult as i'm making it... i'm not all there this morning!
0
 
LVL 18

Author Comment

by:bobbit31
ID: 7099162
forget that last comment... i needed to use table.getCellRect()

anyway, thanks to all!
0
 
LVL 7

Expert Comment

by:tomboshell
ID: 7099480
Thank you and glad to help,
Tom
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

705 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

19 Experts available now in Live!

Get 1:1 Help Now