Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14353 > unrolled thread
| Started by | Hakan <H.L@softhome.net> |
|---|---|
| First post | 2012-05-07 09:41 +0200 |
| Last post | 2012-05-08 07:51 -0700 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
JTable size Hakan <H.L@softhome.net> - 2012-05-07 09:41 +0200
Re: JTable size "John B. Matthews" <nospam@nospam.invalid> - 2012-05-08 00:13 -0400
Re: JTable size Roedy Green <see_website@mindprod.com.invalid> - 2012-05-08 07:51 -0700
| From | Hakan <H.L@softhome.net> |
|---|---|
| Date | 2012-05-07 09:41 +0200 |
| Subject | JTable size |
| Message-ID | <1336376488.66@user.newsoffice.de> |
What do I need to add to control the size of a JTable? Nothing happens
when I run the code quoted below, it stays the same size.
Dimension tabledim=proTable.getSize();
tabledim.setSize(2*tabledim.getWidth(),
tabledim.getHeight());
proTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
proTable.setPreferredSize(tabledim);
Dimension newtdim=new Dimension();
newtdim.setSize(2*tabledim.getWidth(), tabledim.getHeight());
proTable.setPreferredScrollableViewportSize(newtdim);
--
Newsoffice.de - Die Onlinesoftware zum Lesen und Schreiben im Usenet
Die Signatur läßt sich nach Belieben anpassen ;-)
[toc] | [next] | [standalone]
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Date | 2012-05-08 00:13 -0400 |
| Message-ID | <nospam-A8F354.00131108052012@news.aioe.org> |
| In reply to | #14353 |
In article <1336376488.66@user.newsoffice.de>, Hakan <H.L@softhome.net> wrote: > What do I need to add to control the size of a JTable? Nothing > happens when I run the code quoted below, it stays the same size. > > Dimension tabledim=proTable.getSize(); > tabledim.setSize(2*tabledim.getWidth(), tabledim.getHeight()); > > proTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); > proTable.setPreferredSize(tabledim); > Dimension newtdim=new Dimension(); > newtdim.setSize(2*tabledim.getWidth(), tabledim.getHeight()); > proTable.setPreferredScrollableViewportSize(newtdim); Absent a complete example, it's hard to say with certainty. What is the goal? What is the expected value of getWidth() when you double it. Are you constructing GUI components on the event dispatch thread? What is the layout of the enclosing Container? At what point do you pack() the enclosing Window? For reference, you might compare what your doing with this working example: <http://stackoverflow.com/a/8320681/230513> In general, you should not use setPreferredSize() in this way, and you cannot rely on a component's size until it has been validated. You may get some insight from the answers to this question: <http://stackoverflow.com/q/7229226/230513> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-05-08 07:51 -0700 |
| Message-ID | <pkciq7563poc29h9kmtpmq69e4bnnsdhkc@4ax.com> |
| In reply to | #14353 |
On Mon, 07 May 2012 09:41:28 +0200, Hakan <H.L@softhome.net> wrote, quoted or indirectly quoted someone who said : > What do I need to add to control the size of a JTable? Nothing happens >when I run the code quoted below, it stays the same size. You put the JTable in a JScroller and control the size of the JScroller with your layout. Logically the size of the JTable is the size of all the data in it. see http://mindprod.com/products1.html#VERCHECK for sample code. -- Roedy Green Canadian Mind Products http://mindprod.com Programmers love to create simplified replacements for HTML. They forget that the simplest language is the one you already know. They also forget that their simple little markup language will bit by bit become even more convoluted and complicated than HTML because of the unplanned way it grows. .
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web