Solved

JTable and JTextArea

Posted on 2002-06-13
8
668 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

632 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