-4

We are developing a java Swing application .I want to add a table in a JTextPane, the table can be resized and shoude be support multi-span (row and column).It seems java Swing table view support this, but I cant find any example of this. Can someone help me?

I am not familiar with the java swing View structure,I just don't understand how to calculate the view's spans and offsets. After debuging again and again , I make some progress. I will spend more time on it.Thank you ,everybody.

husanhong
  • 15
  • 6
  • First please show your work!!!! – Nidhish Krishnan Feb 27 '13 at 08:41
  • To support multi-span(row and column) use custom your own class instead of table... – Surendra Jnawali Feb 27 '13 at 08:41
  • This is a problem solving portal. Please show first what you have done. For resurces search on google. –  Feb 27 '13 at 08:48
  • Thank you for you attention.Nearly nothing has been done, I just want to realize it by using tableview, but I dont know how to make it, especially, I cant understand its algorithm of offsets and spans. Can you supply any link for reference? I cant find any on google. – husanhong Feb 27 '13 at 08:54

1 Answers1

2

You can see this as example http://java-sl.com/JEditorPaneTables.html

It could be extended to support multi-span and resize feature.

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • Thank you. I've seen this before, but I've no idea how to extend it , can you give some ideas?My main problem is, it seems too complex to calculate the width and heighth of each cell when resize, I am just helpless ,ah.. – husanhong Feb 27 '13 at 08:59
  • 1
    @husanhong If it's too complex there are two way. Understand this step by step OR hire somebody who can do it for you. There are no simple solutions for complex requirements. – StanislavL Feb 27 '13 at 09:01
  • @StanislavL Thank you. -_-! .I am reading the table view class ,and hope to understand more about it . I will appreciate it if there's any ideas about the algorithm . – husanhong Feb 27 '13 at 09:10
  • @husanhong algorithm of what? of resizing? register a listener and listen D&D events, detect what is changed (e.g. mouse pressed above table border and dragged right) calculate difference and then new widthor height for the cell/column/row. Set the value to table and fire model changed to relayout views. – StanislavL Feb 27 '13 at 09:28
  • @StanislavL Thank you. I mean that ,eg, a 2X2 table, when first row occupy two spans, then how to get the left views' position(offset,span).I will spend more time on this , Thank you all the same.Any idea will be appreciated,thank you ! – husanhong Feb 27 '13 at 09:53