Solved

JTable and JTextArea

Posted on 2002-06-13
8
666 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
varialbe initialization 11 37
servlet example issue 6 46
jsp login check 12 43
spring maven example issues 3 13
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

821 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