Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

JTable problem

Thread view: 
blabla - 04 Dec 2003 12:21 GMT
Hi,
if after entering a name in a cell unsing JTable,
you change the columnWidth:
then the name you entered disappears

Anybody knows how to avoid this?

i suppose its quite simple but i just started learning java
if you want to see the simplified code:

import java.awt.*;

public class DingoMain
{
   public DingoMain()
   {
     DingoMainFrame frame = new DingoMainFrame();
     frame.setVisible(true);
   }
 
   public static void main(String[] args)
   {      
     new DingoMain();
   }
}
------------------------------------------------------------------------------------------------
import java.awt.*;
import javax.swing.*;

public class DingoMainFrame extends JFrame
{
 JPanel contentPane;
 TablePanel aTPanel= new TablePanel();

 public DingoMainFrame()
 {
   contentPane = (JPanel) this.getContentPane();
   this.setSize(new Dimension(474, 343));
   contentPane.add(aTPanel);
 }   
}
------------------------------------------------------------------------------------------------
import java.awt.*;
import javax.swing.*;

public class TablePanel extends JPanel
{
 protected  JTable    table;
 private JScrollPane scrollPane;               
 public final String[]    columnNames = {"een", "twee", "drie", "vier",
"vijf"};
 String[][] data = new String[5][5];
 public TablePanel()

{
   table = new JTable(data,columnNames);
   scrollPane = new JScrollPane(table);
   this.add(scrollPane);
   table.setColumnSelectionAllowed(true);
   ListSelectionModel colSM =
table.getColumnModel().getSelectionModel();
}
}
ak - 05 Dec 2003 07:07 GMT
> if after entering a name in a cell unsing JTable,
> you change the columnWidth:
> then the name you entered disappears

you have wrong TableModel (immutable).
Try to use DefaultTableModel instead.

____________

http://reader.imagero.com the best java image reader.
Christian Kaufhold - 05 Dec 2003 13:12 GMT
Hello!

> if after entering a name in a cell unsing JTable,
> you change the columnWidth:
> then the name you entered disappears

This is an error in JTable.

See http://www.chka.de/swing/table/FTable.java, method columnMarginChanged
for a fix.

Christian
blabla - 08 Dec 2003 14:56 GMT
> Hello!
>
[quoted text clipped - 6 lines]
> See http://www.chka.de/swing/table/FTable.java, method columnMarginChanged
> for a fix.

It looks very impressing and professional, but being a newie to java i
cant figure out how to use it. i tried changing everywhere JTable into
FTable, but thus the same problem remains, and im afraid i dont know
how to call the specific method in the program.
Christian Kaufhold - 09 Dec 2003 18:28 GMT
>> Hello!
>>
[quoted text clipped - 11 lines]
> FTable, but thus the same problem remains, and im afraid i dont know
> how to call the specific method in the program.

You do not need to call any methods. Just using FTable suffices, in fact
using just the fixed columnMarginChanged implementation without the rest
of FTable suffices.

The example you posted initially works for me then.

Christian
Signature

And in short, I was afraid.

blabla - 15 Dec 2003 16:25 GMT
> You do not need to call any methods. Just using FTable suffices, in fact
> using just the fixed columnMarginChanged implementation without the rest
[quoted text clipped - 3 lines]
>
> Christian

strange things are happening
my comp doesnt want to read the data in FTable(data, columnNames)
i'll wait until a newer version af java overwrites the old bloody JTable

thanks anyway


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.