Getting the ACTUAL size of a JTable

Hi all, I've been trying to get the actual size of a JTable for awhile now. I have tried just about every getSize or whatever other size method you can think of and nothing is working out for me. A lot of the times I'll get a value of 0 and other times I'll get a non-zero value. The variance is coming from which getSize method I use and where I'm using it. Whatever the value is though, they do not match up with the actual size that I'm seeing when everything is displayed.
My JTable is within a JScrollPane, which is within a JSplitPane. The JTable takes up the complete size of the JScrollPane and the JScrollPane takes up the complete size of JSplitPane (the top component at least). I have tried getting the sizes from each of these components that are used to contain the JTable, but each one of the values I get are incorrect too.
Anyone have any ideas to help me out?
Thanks, Bryan

Thanks for your help camickr.
I ended up writing a component listener for the frame since componentShown only listens for calls to the setVisible method. Also, I can now resize the table columns whenever the user resizes the frame.
    /*Add component listener to frame.  When frame is shown or
      resized, then set student table column widths*/
    this.addComponentListener(new ComponentListener() {
      public void componentShown(ComponentEvent e) {
        setStudentTableColumnWidths();
      public void componentResized(ComponentEvent e) {
        setStudentTableColumnWidths();
      public void componentMoved(ComponentEvent e) {}
      public void componentHidden(ComponentEvent e) {}
   * Sets the student table column widths.  The username column should take up
   * ~1/3 of the table and the student name column should take up ~2/3 of the
   * table.
  private void setStudentTableColumnWidths()
    TableColumnModel tableColumnModel = studentsTable.getColumnModel();
    Dimension scrollPaneViewportSize = studentsTableScrollPane.getViewport().getSize();
    int usernameColWidth = scrollPaneViewportSize.width/3;
    int studentNameColWidth = scrollPaneViewportSize.width - usernameColWidth;
    tableColumnModel.getColumn(0).setPreferredWidth(usernameColWidth);
    tableColumnModel.getColumn(1).setPreferredWidth(studentNameColWidth);
  }

Similar Messages

  • Getting the actual size of the result of a query

    Hi,
    I would like to ask if someone knows on how to get an estimate size of the result of a query on a table. To make it more specific, here is an example.
    Let us say I have this table called EMP and it has a column called DATE. I have issued a query like this:
    select * from EMP where DATE < to_date('01-AUG-08');
    I want to get the actual size of the result of the query in bytes or MB. How would i achieve this without creating another table and transferring the data on it.

    You can use SQL*Plus Autotrace to have the data size sent between client and database session:
    SQL> set autotrace traceonly statistics;
    SQL> select * from employees where hire_date < to_date('01/08/08');
    107 rows selected.
    Statistics
            430  recursive calls
              0  db block gets
            123  consistent gets
             11  physical reads
              0  redo size
           9405  bytes sent via SQL*Net to client
            457  bytes received via SQL*Net from client
              9  SQL*Net roundtrips to/from client
              3  sorts (memory)
              0  sorts (disk)
            107  rows processed
    SQL>Edited by: P. Forstmann on 25 janv. 2011 18:55

  • Way to get the actual size of a table in Timesten 70512

    hi gurus
    Is there a way to obtain the size of bytes actually occupied by a table in TT version 70512(not ttsize) or a
    corresponding view like DBA_SEGMENTS in ORACLE?
    Thanks

    Hi KevinMao,
    You can use SYS.MONITOR table (PERM_IN_USE_SIZE attribute). You should read note 956830.1 on oracle support about monitoring database and table size in TimesTen.

  • How to get the actual screen size

    Hi,
    I have to get the actual screen size of the cliend in an applet, if i use method
    Dimension dmx = Toolkit.getDefaultToolkit().getScreenSize();
    it does not gives the actual screen size, like the screen size will be different if the application bar ( where we have start button on windows ) is Auto hide, and will be different it is not Auto Hide, or some users ike to keep the application bar on right or left of screen or on top..
    So how do we get the actual display size of screen

    Hi,
    I got how to do if using applet
    in screen object of java script we have methods to get the available width and availabe size
    screen.availWidth
    screen.availHeight
    here is the link for more info
    http://developer.netscape.com/docs/manuals/js/client/jsref/screen.htm
    http://forum.java.sun.com/thread.jsp?thread=275329&forum=57&message=1063410

  • Is there any way to get true "actual size"?

    The "actual size" view on my new 20" Apple cinema display is only 75% of actual size in all of my layout/image programs. Is there any way to fix this?
    I posted a similar topic earlier, but no one has responded.
    Your help would be greatly appreciated.

    I assume you are referring to the 72 point-per-inch legacy standard. The only way I know to get there today is to use an old 21" CRT monitor and set it to 1024 x 768. But I am not really sure you would like the end result. Pretty retro.
    Tiger has an undocumented facility to independently scale the UI to any screen DPI (dots-per-inch). There was supporting software for this on one of the developer's CDs. You can read about that here:
    http://appleinsider.com/article.php?id=610
    Even better is that 10.5 is rumored to have this feature fully implemented. That would be great. It will clear the way for monitor resolution to climb higher without further damaging WYSIWYG, or "actual size" as you call it.
    http://tinyurl.com/ogut7

  • How to get the default selection color from JTable

    Hi, there,
    I have a question for how to get the default selection color from JTable. I am currently implementing the customized table cell renderer, but I do want to set the selection color in the table exactly the same of default table cell renderer. The JTable.getSelectionBackgroup() did not works for me, it returned dark blue which made the text in the table unreadable. Anyone know how to get the window's default selection color?
    Thanks,
    -Jenny

    The windows default selection color is dark blue. Try selecting any text on this page. The difference is that the text gets changed to a white font so you can actually see the text.
    If you don't like the default colors that Java uses then use the UIManager to change the defaults. The following program shows all the properties controlled by the UIManager:
    http://www.discoverteenergy.com/files/ShowUIDefaults.java
    Any of the properties can be changed for the entire application by using:
    UIManager.put( "propertyName", value );

  • How to get the actual height of JEditorPane?

    I have a basic question on the JEditorPane. Do I have to show the JEditorPane on a temporary Frame in order to get the actual height? My work around is to show the JEditorPane on a frame, get the JEditorPane height, then dispose the frame. It would be nice if I can get the actual height of JEditorPane without showing the frame.
    This is test my code.
    import java.awt.*;
    import java.lang.*;
    import java.net.*;
    import javax.swing.*;
    public class Test {
    public static void main (String [] args) {
    double w = 0;
    double h = 0;
    JEditorPane editorPane = null;
    try {
    URL url = new URL("file:test.html");
    editorPane = new JEditorPane(url);
    } catch (Exception e) {}
    editorPane.setPreferredSize(new Dimension(400, 700));
    w = editorPane.getWidth();
    h = editorPane.getHeight();
    // output "width: 0 height: 0"
    System.out.println("width: " + w + " height: " + h);
    // This my work around the get the actual height
    JScrollPane scrollPane = new JScrollPane(editorPane);
    JFrame frame = new JFrame("TESTING");
    frame.getContentPane().add(scrollPane);
    frame.pack();
    frame.show();
    // wait for loading data
    try {
    Thread.sleep(20000);
    } catch (Exception e) {}
    w = editorPane.getWidth();
    // actual height based on the width and the size of test.html
    h = editorPane.getHeight();
    // output "width: 597 height: 24320"
    // 24320 is the actual height that i want
    System.out.println("width: " + w + " height: " + h);
    frame.dispose();

    This thread uses a PropertyChangeListener to notify you when the page is finished loading.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=333171

  • Dual library question (iTunes gets the library size and bitrate wrong)

    I have two libraries, one ripped in Lossless, and the other in AAC at 256 kbps. I use one for streaming, and the other for syncing to our iPods. I just switched from the Lossless library to the AAC library (kept on separate drives). iTunes now sees the AAC files, but incorrectly lists all the bitrates as their higher Lossless numbers. However, when I click on an individual song to play it, the bitrate appropriately is recognized as 256 kbps. When I do this, the total library size (listed at the bottom) also incrementally "shrinks."
    The problem is that I just purchased a new 80 GB iPod capable of holding the entire library (nearly 8000 songs@25 kbps, ~60 GB total size). Unfortunately, iTunes still thinks the library is much larger (using the incorrect lossless bitrates to calculate file size). This results in it telling me (erroneously) that the library is too large to sync.
    Is there an easy way to get iTunes to realize the new file sizes? I could obviously double-click on each and every song in the library until iTunes "gets" the real size, but I assume there's a better way. I also assume that this will be an issue every time I switch between the two libraries.
    Help, anyone? Thanks in advance.
    KK
    iMac G5, Mini, PB G4   Mac OS X (10.4.6)  

    Thanks for the tip, but this didn't work, unfortunately. Following your lead a bit further, I even created a new playlist and dragged the whole library there, but the wrong bitrates (and thus, playlist size) still appeared.
    One more curious update regarding this situation. iTunes automatically populated my iPod with what it believed was a subset of my tunes that would fit on the iPod. The real size of this subset was ~20GB, but iTunes thought (using the Lossless size) that it was nearly 60 GB. In categorizing the contents of my iPod, it listed ~60GB of songs, ~1 MB of photos, 1 GB of video and still listed the space available as ~50 GB (for a grand total of ~112 GB of space on my 80 GB iPod). Clearly, iTunes used the calculated size to estimate the music content, but used the actual space remaining based on a query of the iPod drive. Strange, huh?
    I'm still looking for advice--any other suggestions would be welcome.
    KK

  • How to get  the actual data in ALV report

    I am doing some upgradation work   in that i am using Submit  & And return and  also i am using some function modules like LIST FROM MEMORY , LIST TO TXT wnd WRITE LIST , it gives output in normal list format , But i need to print in ALV report .
    With the use of set table for 1st display i got the  ALV report   but not with actual data, (some junk value is showing) , So can any 1 suggest me how to get  the  actual data in ALV report, With the use of  Any Function Module or with Coding,
    with regards,

    Hi Saravana
    I am sure you must be getting the values in tables of table parameters from every FM.
    consolidate the values from tables of all FMs in one table and built ALV for that table only.
    I hope this way you can show the actual data in ALV.
    thanks
    Lalit

  • How can I print a pdf in the actual size with a page border?

    How can I print a pdf in the actual size with a page border? (2 pages per sheet preferred)
    I usually print pdfs of books at a copy shop and they turn out fine.
    The problem comes when I try to print the same books at home.
    I use Adobe Acrobat X with the same settings: "multiple pages per sheet" (2x1) and page border. But the pages are slightly shrunken when printed. I think this is because my printer can't print as closely to the margins. Still, two pages should be able to fit on one sheet in actual size. Are there any layout settings that I can play with to find a better fit, besides portrait and landscape?
    If I select page scaling "none," I'm able to print the pdf in actual size, one page per sheet. But there's no option to add a page border.

    I have a test with some questions (multiple choice, FIB, matching, etc). I have just one button to submit all the answers, and after submiting the student can see his score and review the test to know where he failed. He can't answer again. However, he can change the answer multiple times before submiting.
    "if i turn on success/failure captions the student will see them while answering" - before submitting
    "if i turn them off he wont know what's the right answer" - after submitting
    My results page is the default. I didn't use any variable. When i go to the results page after reviewing the test all the entry boxes are "wrong".

  • Help ...how to get the file size on a server

    Hi.I use this code to parse a file that is on a server.
    The question is: how can i get the file size (bytes size)?
    Thanks.
    //Open the file for reading:
    URL u = new URL(entry);
    InputStream inputXML = u.openStream();
    //Build document:
    DocumentBuilder builder = factory.newDocumentBuilder();
    doc = builder.parse(inputXML);

    Try this instead:
    URL u = new URL(entry);
    URLConnection conn = u.openConnection();
    // get the file size
    int size = conn.getContentLength();
    // open the input stream from the URLConnection (which is functionally the same as opening it directly from the URL)
    InputStream inputXML = conn.getInputStream();
    Shaun

  • How do I get the byte size of a server file before sending output via HTTP?

    I need to get the byte size of the file prior to streaming it. I can't seem to find a class/method I need. Basically, I have the path c:\\tomcat\\webapps\\documents\\sample.pdf in the servlet, I was hoping I could just use something from the File class but I couldn't find anything that seems to do the trick?
    thanks, in advance,
    Chuck

    maybe the source of the problem will help...I am trying to stream a PDF to IE and a blank page is being generated although all other file type work.
    I have found a lot of answers in the forum but no specific code examples. Here's what I have so far from picking through threads in here (can someone please show me how to get the byte size of the file so that I can assign it to the method response.setContentLength();?):
    String CONTENT_TYPE = " ";
         String target = " ";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         StringBuffer buf = new StringBuffer();
         HttpSession session = request.getSession();
         String file = request.getParameter("filename");
         target = file;
         int end = file.length();
    int beg = end-2;
         String type = file.substring(beg, end);
         if (type.equals("DOC")){
              CONTENT_TYPE = "application//vnd.msword";
         }else if (type.equals("XLS")){
              CONTENT_TYPE = "application//vnd.x-excel";
         }else if (type.equals("PPT")){
              CONTENT_TYPE = "application//vnd.ms-powerpoint";
         }else if (type.equals("PDF")){
              CONTENT_TYPE = "application//vnd.x-pdf";
         }else if (type.equals("MPP")){
              CONTENT_TYPE = "application//vnd.ms-project";
         }else if (type.equals("ZIP")){
              CONTENT_TYPE = "application//ZIP";
         }else if (type.equals("TXT")){
              CONTENT_TYPE = "text//plain";
         }else {
              CONTENT_TYPE = "text//html";
         //File f = new File(file);
         //int l = f.length();
         response.setContentLength(l); <----- supposedly this fixes my problem but I don't know how to get the byte szie of the file in an integer??
         // reset the response
         response.reset();
         response.setContentType(CONTENT_TYPE);
         try{
         // Get streams
         FileInputStream fileInputStream = new FileInputStream(target);
         ServletOutputStream servletOutputStream = response.getOutputStream();
         // Init byte count and array
         int bytesRead = 0;
         byte byteArray[] = new byte[4096];
         // Read in bytes through file stream, and write out through servlet stream
         while((bytesRead = fileInputStream.read(byteArray)) != -1) {
         servletOutputStream.write(byteArray, 0, bytesRead);
              servletOutputStream.flush();
         // Flush and close streams
         servletOutputStream.flush();
         servletOutputStream.close();
         fileInputStream.close();
         } catch (Exception e) {
         System.out.println(e.toString());

  • How do I find the actual size of an app? Example: a wallpaper app claims the size of 4.4 MB, but the size on my iPhone is 4.9 GB!

    Some of the apps on my iPhone are much larger size-wise than claimed on their app page. Example: Wallpapers HD claims 4.4 MB, but the actual size on my phone is 4.9 GB! Pinterest &amp; Facebook also end up being huge real estate hogs. How do I really know the size of an app? The apps don't represent themselves accurately in the app store.
    I figured out that 2 of my podcast apps allow me to remove content after listening. Others don't, though.
    I'm hoping some of you younger people know the answer.
    Thanks,
    Nana Lybbr8

    The size of an app depends on two different things:
    1) the size of the App (as in the App Store)
    2) the size of the App Data
    The App Data can really inflate the size.
    If you want to see how much space an app is actually taking up, got to the Settings app under General and then tap "usage."
    Unfortunately some apps don't let you delete the content. Others do.
    Hope this answers your question.

  • Hello.  How do I keep the actual size of a photo when adding to a Keepsake?  Used to do this but have forgotten how!

    Hello.  How do I keep the actual size of a photo when adding to a Keepsake?  Used to do this but have forgotten how!  Need help please!
    T.

    Here is my suggestion:
    Open a blank, new file (File>new>blank file) size 8.5x11"
    Open the collage
    Go to Select>all
    Go to Edit>copy
    Go back to the blank file created in step #1
    Go to Edit>paste. The collage will be on its own layer
    Access the move tool, and with the corner handles resize the collage. Using the corner handles should preserve the aspect ratio. If you open the rulers, you will have a point of reference as you go along.
    Print a draft copy to see if it will be suitable in the frame..
    Please report back with your progress.

  • What is the actual size of an (empty) varray in a record?

    what is the actual size occupied by an (empty) varray in a record?
    For example, if I create my table defined as:
    create or replace type XXX as object (
    myRefs VARRAY(10) of REF(yyy)
    create table YYY as XXX;
    what is the actual size of the record of type XXX when 'myRefs' is empty? For some reason, select data_length from all_tab_cols where table_name = YYY seems always to return 3K as the length of column myrefs.... is that correct? If not, what is the correct size?

    A tad late here...
    Storage sizes of REF attributes are described here:
    [Design Considerations for REFs - Storage Size of REFs|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11822/adobjdes.htm#i452226]
    The size of your REF attribute (or element, in your case) will depend on whether it is primary key-based or system-generated, whether it is scoped or not, and whether it carries with it a rowid hint. The overall size of your VARRAY attribute as it grows will also depend on whether you allow null REF values or not, but essentially will be the size of your REF multiplied times the number of elements in your VARRAY (plus a small, constant amount of storage for internal housekeeping, both for the attribute and for each element).
    You could try the VSIZE function as an appromixation...
    [Oracle® Database SQL Language Reference - VSIZE|http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions233.htm#SQLRF06162]
    Hope it helps...
    Gerard

Maybe you are looking for

  • Single click in alv grid

    Hi friends, below statement is for double clicking, WHEN '&IC1'. " SAP standard code for double-clicking, but i need single click because when i select field(not doubble click only single click) in alv grid it has to trigger and perform some action 

  • Help required on Datetime string conversion

    Hello Experts, I have a string with value '2010-07-16T07:30:00+03:00' which came from a webservice string data.Please advice how to declare variable in abap to get the correct date and time from this string? From my previous exp, if I had the xml str

  • NullPointer exception while calling PrintOutputController.export()

    Hi Ted, I have a Web application running on tomcat 6.0.18. We use jrc 12.2.200 to call JAVA API for generating reports in PDF format and Cystal Report 2008 for report design. I am getting following exception intermittently. 2009-05-01 16:47:45.859 GM

  • Error in NW2004S / EP7 installation (AIX & Oracle)

    Hi, I'm getting an error when installing EP7 / NW2004S on AIX 5.3, Oracle 10.2.0.2.... the installation is failing at step "Install software units" when it tries to deploy the online SDAs. The error in the log is:     Caught exception while checking

  • How can I sort my email by read/unread?

    Is it possible to sort the email list by read/unread?