Can't resize JTable

In my code I display in a Panel a JScrollPane containing a table.
When I resize the panel, the table is always the same height. I want the table to fill all the panel.
Here is my code:
public HistComm() {
super(new GridLayout(1,0));
table = new JTable(model);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
model = (DefaultTableModel)table.getModel();
model.addColumn("Name");
model.addColumn("Method");
// table.setPreferredScrollableViewportSize(new Dimension(500,70));
scroll_pane = new JScrollPane(table);
add(scroll_pane);
}

Result won't be the same if you say super(new BorderLayout);
but later when you add your ScrollPane to Panel you should try with:
add(scrollPane, BroderLayout.CENTER);
This will do the trick!!
Zorro (javagod)

Similar Messages

  • Dynamically resize JTable cell to fit a JList

    Hi!
    I've been banging my head trying to add some dynamic behavior to a TableCellEditor. In short I'm trying trying to make it resize the height of the current row (the one it is in) to reflect the changes made to the JList used to let the user edit the cells value (which is a list of items).
    I've come across some threads dealing with the problem of resizing a cell to fit its content. This however is usually only done once (in the 'getTableCellEditorComponent' function) and so only provides half the answer. Also, since the editor is only active during cell editing I've been trying to make it revert to the old cell height after the editing is done.
    So far I have not come up with any decent solution to this problem and was hoping someone out there might have an idea or have read something similar and can point me to something helpful... anyone?
    Cheers!
    Teo

    The Swing tutorial on[url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables shows how to dynamically change the size to Table Columns.
    If you need help calculating the acutal size then try searching the forum. Using keywords "resize jtable column" (keywords I took directly from your topic title) I found some promising postings.

  • Want to resize JTable after run programe by mouse

    I want to resize JTable by mouse after run programe.
    (want to resize Jtable anytime)
    please help me. thank you

    You cannot do that directly, you can only cause the container which holds the JTable to change size. As long as that container has a LayoutManager like BorderLayout then the JTable will resize with the container (Like a JFrame)

  • How to resizea JTable column to fit to text programatically?

    hi evreyone,
    i'm trying to resize a JTable column width to fit to the contained text programatically.my approach was that i made a comparison between the length of String objects contained in my column and got the biggest String length value but i want to know how can i resize the column to fit to this biggest String object

    You're going the wrong way about it - don't go calculating string lengths. Get the TableCellRenderer, query it for the renderer component for each cell in the column, obtain its preferred size and keep a record of the greatest width value.

  • How can I resize a photo in iPhoto without cropping it?

    I am taking pictures on my iphone 4s and using iphoto to edit them on macbook pro.  I need to upload these photos at a size much smaller than what i am able to take with my phone.  The only way I see to adjust the size of a photo in iphoto is to crop it.  How can I resize without cropping?
    Thank you

    It's an option in the Export menu.
    File -> Export and under the Size option you can choose the maximum you prefer. Export that and upload from the desktop.

  • Can't resize list view in 10.9

    While using list view in the finder, I can't resize the various categories (name, size, type, etc). This is very annoying, as my "name" category is expanded so wide you can't see any of the others! For some reason, it's impossible to double click between the categories to have it automatically resize, and you can't click and drag to resize. The double arrows just don't show up. Even more confusing, this only happens while looking at certain folders (desktop and documents), but other folders in the same view work fine. I've tried trashing finder preferences and that didn't solve the problem. How do I fix this? Thank you.
    -A

    While using list view in the finder, I can't resize the various categories (name, size, type, etc). This is very annoying, as my "name" category is expanded so wide you can't see any of the others! For some reason, it's impossible to double click between the categories to have it automatically resize, and you can't click and drag to resize. The double arrows just don't show up. Even more confusing, this only happens while looking at certain folders (desktop and documents), but other folders in the same view work fine. I've tried trashing finder preferences and that didn't solve the problem. How do I fix this? Thank you.
    -A

  • How can I resize partition? - New larger hard drive installed

    Hello,
    The hard drive on my MacBook Pro recently died on me (just past my Apple Care warranty - lucky me).  I sent it to an authorised reseller/repair place and they installed a new hard drive for me - replacing my old 250GB with a nice new 500GB.  The problem is when they copied over the disk image from my previous hard drive they did not scale up the image (yeah, not so happy bout that).  Now I find myself with a 500GB hard drive with a 250GB partition called Macintosh HD and 250GB of unused/unusable space.  On top of that I'm just starting to get messages saying boot disk nearly full.  How can I resize the "Macintosh HD" partition to use the entire disk?  I've tried using disk utility, clicking on the main drive, going to the partition tab and dragging the Macintosh HD partition to use the entire disk but after a few seconds of a message saying "waiting for disk to reappear" it returns to the same 250GB size.  Running OSX 10.9.3.  Any suggestions?
    Thanks all!

    See the tips in pounding's section on using Disk Utility:http://pondini.org/OSX/Home.html and you could also take the route of buying an external hard drive (a great idea of maintaining a backup), format that drive for Mac OS X Extended (Journaled), clone the startup disk to that drive, then boot from the external, erase and format the internal, then clone the external back to the internal partitioned as you want.

  • Adobe Acrobat Pro 9.4.6 Sticky Note Icons are huge and can not resize

    My coworker is having a problem with the size of the Sticky Note (comments) Icon.  It is huge and we can not resize.
    When you open the icon, it takes up the whole page.  We can change the Font size, but the actual icon will not resize.
    The same document opened up from someone else, the icon views normal. We all have Adobe Acrobat Pro V9.4.6.  Any suggestions on a fix?
    Thank You.

    JimJSC,
    Your reply also helped fix a problem I had with not being able to resize sticky notes. My original display resolution meant that the resize symbols in the lower corners of the sticky note weren't accessible. In Acrobat X, the setting is under Acrobat, Preferences, Page Display, Resolution.

  • How can I resize a pdf page content with annotations and highlights in Acrobat Pro?

    How can I resize a pdf page content with annotations and highlights in Acrobat Pro while maintaining page size and annotation/highlight interactivity? I've tried to use the crop tool in Acrobat Pro (9) and the page does resize, but the highlights and annotations go all over the place. I specifically need to scale the page content smaller (83%) but maintain page size and annotation/highlight to content connection and interactivity.

    An old trick (not recommended) would be to print to a new PDF with the page size selected but a scaling of the content. Only print the document, not the markup, to a new PDF. Close that PDF when done and reopen the old one (or maybe a copy of the old one for safety) and use Document Replace pages and select the new document to replace your current pages. You will then have to go back through the markup to locate it all correctly. There may be a more elegant way, but this may be the fastest.

  • When I open a file in Photoshop CS4, how can I resize My Open Window File?it is stuck on full screen

    When I Open a File in Photoshop CS4, How can I Resize My Open Window File? It is stuck on Full Screen?

    Which operating system are you using?
    On a windows os, usually one can just double click on the title bar in the open dialog.

  • I have Adobe Photoshop 9.  I am a novice.  How can I resize photos in my files using batch resize?

    I have Adobe Photoshop 9.  I am a novice.  How can I resize photos in my files using batch resize?

    In the Editor, use File...Process Multiple Files.  See the Help for more info.
    Ken

  • Can I resize pages in Acrobat?

    Hi,
    I'm in a rush to get my graphic design portfolio requirments done for my portfolio class at VCU.  Please help if I don't finish it I don't graduate with my BFA!!!  Ok I am over exaggerating but if I can resize this in Acrobat Pro it will save lots of time and I'm going insane from all the stress.
    I have to resize all my portfolio pieces so they are within an 8 1/2 x 11 page format.  My current pdf portfolio has all my pieces at all random sizes. I have about 39 pages some are horizontal magazine layouts and some are vertical posters.  So when I resize everything will be on a page with some white space depending on the page.  I can go into indesign and do this but that will take hours cause of importing large files.  If I could just resize in Acrobat Pro (I have 9.1) I could be done soon.  If it can't be done then I'll just have to do it the hard way, but I need an answer asap.  I can't find anything that helps on the net.
    Or if I can't resize my pages in this program does anyone have any suggestions as to how I may do so quickly?  Anything to avoid importing page by page into indesign...  I have the full adobe CS4 suite so I can work in any of those programs or if there is some free program that will work too.
    Thank you!

    Apparently,  you can't do it in Acrobat 9 .2 anyway. (Make /Print a Pdf from a Pdf or re-fry)
    The to do it, use to be, was you make your correction, (example to make a permanent crop) was that you desire the either go to apple's Print to PDF or use AdobePDF printer.

  • Can we resize and change the background image in a 2 page layout?

    I am a two page layout report in RTF. Can I use different background image on page 1 and page 2? The first page background will not be repeated but the second page will. Also, it seems when we insert a background image by going "Format -> Background -> Fill effect -> Picture", after we finished the whole process we can't get the background image to fit with the page, can we resize it to be fit with the page? Thanks for your help!

    Yes.  Select the image and go to the Inspector/Hyperlink/Link pane and use the Link to One of my Pages option.
    Remember: the photo must be added to the page by dragging it onto the page and then be selected.  It can't be added as a background image with the Inspector/Page/Layout pane.
    OT

  • Can't resize elements in InDesign CC using selection tool

    I recently switched to InDesign CC and can't resize text boxes or image boxes and their contents using the usual shift/command, drag. Is there a new preference in CC?

    I am having the same issue. Also, the option/drag to duplicate an item is not working.

  • How can I resize and reposition the Date Created window for All windows?

    When setting view options for a finder window set to list view, I cannot get column resizing or positioning to hold. When making those changes, the option for "All Windows" automatically shifts to "This window only" and it then does not hold.
    How can I resize and reposition the Date Created column for All WIndows?

    Hi Harmz,
    Try dragging this file to the Îesktop & reboot...
    /Users/YourUserName/Library/Preferences/com.apple.finder.plist

Maybe you are looking for