JTable won't resize

hi !
I'm having problems with a JTable
I can't find out how to resize its width
I just create it the classic way and insert it in a JPanel
DataModel dataModel = new MyCustomTableModel();
JTable table = new JTable(dataModel);
JScrollPane tablePane = new JScrollPane(table);
myPanel.add(JScrollPane, BorderLayout.SOUTH);all sizes are auto-manages (no such thing as setPreferredSize(...)), but no matter how many columns there are in the JTable, it is always the same size, and I can't seem to control this size in any way. I tried messing around with setSize(...) and setPreferredSize(...) of the table and JScrollPane instances, tried resizing the table columns, but only faced the frustration of seeing nothing happening all the time
is there a way I can effectively resize the table width ?

okay - nevermind
I don't know if it's the best way to do it, but I solved it by overriding update
public void update(Graphics g){
          super.update(g);
          if(!updated){
               tablePane.setPreferredSize(new Dimension(
                    tablePanel.getSize().width - 50,
                    tablePanel.getSize().height - 50));
               updated = true;
               tablePanel.revalidate();
               tablePanel.repaint();
               this.repaint();
          else
               updated = false;
     }

Similar Messages

  • My homescreen won't resize and I can't access anything because everything is too big to navigate.  Help.

    My homescreen won't resize and I can't access anything because everything is too big to navigate.  Help.

    Double-tap the screen with three fingers to disable Zoom.
    To turn off Zoom go to Settings > General > Accessibility > Zoom and turn this Off.

  • Disk Utility won't resize a partition

    Disk Utility won't resize (eliminate smaller partition from a 2-partitioned internal) Hard Drive. This is the message I get:
    "Partition failed
    Partition failed with the error:
    Filesystem resize support required, such as HFS+ with Journaling enabled."
    Help files offer no information on this error. I followed the Help instructions to do this operation, but the resize doesn't work. The older, smaller partition shows up in Disk Utility but is dimmed out. It will activate at highlight, but is not recognized on the desktop.
    Any suggestions as to how to fix this problem?

    Intel based Macs use a different partition scheme called GPL or GUID rather than what PowerPC used, APL.
    You could try reformatting, or get a new system, and run BootCamp and Windows even.
    Even if you've used Macs for years, there is always a place on my book shelf for this one, David Pogue's "Mac OS X: The Missing Manual (Leopard Edition)"
    http://books.slashdot.org/books/08/02/27/1551206.shtml

  • Adobe camera raw window won't resize and can't reach buttons

    When I open an image from bridge into adobe camera raw 6.1 (Photoshop CS5) on my laptop, the camera raw window fills all of the screen (top to bottom) and the buttons at the bottom of the window are below the task bar. Thus I can't open the image in photoshop except by hitting the enter key. I can't reach the open, etc buttons. The window won't resize and there are no icon/buttons in the right upper corner to go to/from full screen. When I hit the icon in the top right hand menu bar in ACR (to go to full screen size) the window then fills the whole width of the screen in addition to the height, but no matter what I do I can't get the height of the window to shrink, so that I can access the icons at the bottom of the screen. What am I missing? Thanks

    Don't worry about turning aero off just yet.
    There are two key first questions:
    What is your screen resolution (width in pixels x height in pixels)?  Right-click on desktop, choose Screen Resolution.
    What setting have you chosen for the display size (Smaller, Medium, Larger) in the Display dialog?  Right-click on desktop, choose Personalize, then Display.
    -Noel

  • Blogger (blogspot) mobile site won't resize images

    Blogger has supported mobile version webview. When using Firefox android browsing blogger, the images are not resize to smaller ones.
    As image below:
    http://imgur.com/WWdDFLE
    Firefox for android, the image won't resize to smaller one, but other browsers do.

    This is likely a problem with the data blogger sends to Firefox. You can log a bug report at https://webcompat.com/ and technical people will do some diagnosis of the issue.

  • JTable have no resize cursor under a JLayeredPane

    Hi,
    i have over my JScrollPane a JLayeredPane to show infotext.
    When the JLayeredPane is over the JScrollpane you can resize the column but the JTable show no resize Cursor.
    Does anybody know why?
    import java.awt.Component;
    import java.awt.Dimension;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JLayeredPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.WindowConstants;
    import javax.swing.table.DefaultTableModel;
    public class NoResizeCursorDemo extends JFrame
      public NoResizeCursorDemo()
        JTable table = new JTable( new DefaultTableModel( new String[]{ "aaa", "bbb" }, 10 ) );
        JScrollPane scrollPane = new JScrollPane( table );
        InfoLayer layer = new InfoLayer( scrollPane );
        add( layer );
      public static void main( String[] args )
        NoResizeCursorDemo frame = new NoResizeCursorDemo();
        frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
        frame.pack();
        frame.setVisible( true );
      class InfoLayer extends JLayeredPane
        private final JComponent wrappedComponent;
        public InfoLayer( JComponent wrappedComponent )
          this.wrappedComponent = wrappedComponent;
          setLayout( null );
          add( wrappedComponent, JLayeredPane.DEFAULT_LAYER );
          setInfoText();
        private void setInfoText()
          add( new JLabel( "Info......" ), JLayeredPane.POPUP_LAYER );
          revalidate();
        @Override
        public Dimension getPreferredSize()
          return wrappedComponent.getPreferredSize();
        @Override
        public void doLayout()
          Dimension size = getSize();
          Component layers[] = getComponents();
          for ( Component layer : layers )
            layer.setBounds( 0, 0, size.width, size.height );
    }Thanks

    Hi,
    I had almost the same problem with JTable and JSplitPane, the components worked fine, but cursor did not change when require.
    I already had in place mouse events dispatching in my top layer. It passed all events to the components underneath (see example in [Glass Pane Demo Project|http://java.sun.com/docs/books/tutorial/uiswing/examples/components/GlassPaneDemoProject/src/components/GlassPaneDemo.java]; in my case the listener was the content panel of the top layer).
    And now here is the trick around the cursor. Within the custom dispatch method I've called the following:
    this.setCursor(comp.getCursor());
    where "this" is the content panel of the layer and comp is the component where mouse event passed to.
    Hope that helps!
    Regards,
    Sergey

  • GarageBand window won't resize

    Garage Band window won't resize...I can see the bottom but not the top..if I do anything to it, I lose the bottom completely and have to start from scratch.

    something quick to try; assuming you are already at your highest resolution, toggle it to a lower rez and then back to the higher rez.

  • IMessage photos won't resize...

    Correct me if I'm wrong, but it seems prior to ios 7 when I would copy and paste a photo from somewhere on the internet, iMessage would always resize the photo so you could see the full picture.....but now it seems in ios 7, that most of the times when I copy and paste a picture into a message, it tries to use the full resolution, and won't resize to fit the little message window.  Anyone else notice this?  It's very annoying and I hope it can be addressed in a patch at some point. 

    no one else is having this issue or concern?

  • JInternalFrame won't resize

    Hi ;
    I have a JInternalFrame's that won't resize (and won't deiconify) .
    Actualy it's my own JInternalFrames ; but in the constructor I call "super(title,true,true,true,true)" . the strange thing is that using :
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    [or UIManager.getSystemLookAndFeelClassName() or getCrossPlatformLookAndFeelClassName() ]
    the resize doesn't work but using the "com.sun.java.swing.plaf.motif.MotifLookAndFeel" it will resize and deiconify .
    Does anyone have an idea what causes it ?
    thanks;
    Adaya .

    It has something to do with the BorderLayout (that worked with the jdk1.2 version ... now I am working with jdk1.4) , because when I removed the setLayout from the contentpane it worked - but now I am facing another problem , using the BorderLayout I had order in my frame , that contains not only JInternalFrames , but also a menu toolbar and an textfield that desplays output to the user .
    Any idea?
    thanks ;
    Adaya .

  • GIF Files Won't Resize

    I have a few gif files that I inherited that were very poor quality.  I've spent a lot of time cleaning them up.  I need to resize them to about half their current size without resampling because I need to retain the quality.  I go to Image > Resize > Image Size and enter the correct size.  I then save the file, but when I reopen the file, it reverts back to the original size.  I need to resize them before I can complete the project and turn it over.
    I've also tried saving them as jpg and resizing, and that works.  BUT when I further convert them back to a gif I'm back to the same problem.  Does anyone have idea of what I could try next or what the problem is?
    Thanks...

    Thanks you so much for your response.  I did go into RGB, and it didn't
    make any difference.  These files are not for the web.  They will be used
    inside a program currently under development.  Depending on selection
    criteria, a graphic may be selected and inserted into a template to be
    printed along with other nongraphical elements.  Since they will be
    printed, the quality is important.  In addition to the requirement that
    they be in gif format, they must be the exact size.  I was instructed
    scalable files are not acceptable.
    Any additional thoughts will be greatly appreciated.
    Liz
    Barbara Brundage <[email protected]>
    07/20/2009 11:51 AM
    Please respond to
    [email protected]
    To
    Elizabeth A Kaminski/AE/DuPont@DuPont
    cc
    Subject
    GIF Files Won't Resize
    Try going to Image>Mode>RGB first. However, you do realize that if you
    want gifs for web use, you MUST resample to resize them? (I'd use save for
    web for this, myself, rather than the PSE image size dialog.). If these
    aren't for the web, are you sure you need to keep them as gif files rather
    than another format?

  • JTable in JLayeredPane - resize table header cursor

    Hey everybody, I have searched all over this forum and the net for an answer to this problem. I have a class that adds a JComponent to a JLayeredPane in the default layer. In another layer above the default layer is a JComponent that exists only to provide a 'pretty' image border with round corners that overlap the component below it. It works and looks very good. The only problem I have found is that if the JComponent that is added (in the default layer) is a JTable the cursor no longer changes to the resize cursor (<->) when mousing over the table header column edges. I can still resize the columns but I need to have the cursor change to indicate that the colums can be resized for user friendliness. I assume that the mouse events are getting trapped by the upper layer in the JLayeredPane and aren't reaching the JTable in the lower layer as they need to.
    I have tried swapping the two layers but when I do that the corners of the component that I want to add the border to overlap over the nice round corners of the border which defeats the purpose.
    If anyone has any suggestions, or even better a solution, that would be great!
    Thanks,
    Erik

    table.getTableHeader().setVisible(false); will
    help.This is necessary, but probably not quite sufficient for picky users. You may also want to set the min, max, and preferred dimensions of the table header to 0,0, otherwise you get what looks like a top-only border.
    Michael Bushe

  • JTable rows self resize

    hi guys, i�ve notice that the jtable allows an automatic resize of the columns width like an excel�s sheet, its there a way to do the same thing with the the rows heigth or i should program it with mouse events. Thanks in advance.

    Hi
    Yes it is possible to control JTable either by mouse or button click
    view JTable api to control layout of table and call those functions on mouse events as you are desiring. Drag,or released etc

  • JTable Won't Allow Editing Despite isCellUpdatable is Set to Return True

    Mass apologies if I somehow sent this to the wrong forum by mistake. However, aid from the local Java gurus would be much appreciated since I'm the only Java programmer at this company, so I don't have anyone to really ask for advice or anything.
    I've been trying to enter an updatable ResultSet into a JTable for about a week now, but the issue I ended up running into was that if you click on a cell with the intention to edit the contents, it won't even highlight the cell, much less let you edit it.
    I've searched Google and this forum along with tried to hunt down more complex books on Java rather than your standard "So you want to learn Java" cookbooks, but I've come up with null. I've also created about five different variations of TableModels for the purposes of handling this, including one that used an array of Objects instead of the ResultSet, but the problem persists.
    Here is the latest version of the TableModel that I've come up with
    package EventCalGUI;
    import javax.swing.table.AbstractTableModel;
    import EventCalSQL.TableData;
    @SuppressWarnings("serial")
    public class UpdateRSModel extends AbstractTableModel
         /** <code>TableData</code> from database */
         private TableData data;
         public UpdateRSModel(TableData tdata)
              data = tdata;
         @Override
         public int getColumnCount()
              return data.getColCount();
         @Override
         public int getRowCount()
              return data.getRowCount();
         @Override
         public Object getValueAt(int row, int col)
              return data.getValue(row, col);
         @Override
         public boolean isCellEditable(int row, int col)
              return true;
         @SuppressWarnings("unchecked")
         @Override
         public Class getColumnClass(int col)
              return data.getColClass(col);
         @Override
         public String getColumnName(int col)
              return data.getHeader(col);
         @Override
         public void setValueAt(Object value, int row, int col)
              data.setValue(value, row, col);
    }The reason for suppressing the warnings is because Eclipse attempts to be too helpful with its cautions and I was sick of seeing a long list of unnecessary yellow caution signs.
    This is the TableData class that the above TableModel derives from. I hadn't added in the actual ResultSet updating capabilities until I was sure I could get the JTable to work.
    package EventCalSQL;
    import java.sql.*;
    public class TableData
         Object[][] data = null;
         String[] headers = null;
         int rows = 0;
         int cols = 0;
         @SuppressWarnings("unchecked")
         Class[] colclass = null;
         public TableData (ResultSet rs)
              try
                   ResultSetMetaData metadata = rs.getMetaData();
                   // -------------- SET COLUMN DATA ---------------
                   cols = metadata.getColumnCount();
                   headers = new String[cols];
                   colclass = new Class[cols];
                   String classname = "";
                   for (int b = 0; b < cols; b++)
                        headers[b] = metadata.getColumnName(b + 1);
                        classname = metadata.getColumnClassName(b + 1);
                        colclass[b] = Class.forName(classname);
                   // ------------ SET ROW DATA --------------
                   if (rs.last())
                        rows = rs.getRow();
                        rs.beforeFirst();
                   if (rows != 0)
                        data = new Object[rows][cols];
                        for (int i = 0; i < rows; i++)
                             rs.absolute(i + 1);
                             for (int a = 0; a < cols; a++)
                                  data[i][a] = rs.getObject(a + 1);
              catch (SQLException sql)
                   // I'M UNINTERESTING!
              catch (ClassNotFoundException cnf)
                   // BE BORED!
              catch (NullPointerException np)
                   // I'M BORING!
         public Object getValue(int row, int col)
              return data[row][col];
         public String getHeader(int col)
              return headers[col];
         public void setValue(Object value, int row, int col)
              data[row][col] = value;
         public int getRowCount()
              return rows;
         public int getColCount()
              return cols;
         @SuppressWarnings("unchecked")
         public Class getColClass(int col)
              return colclass[col];
    }I've checked the exceptions, and they work. I just added into the comments since nothing's really supposed to happen there if it's an empty set. I just have a weird sense of humor after twenty-plus hours of coding variations of the same thing over and over.
    Thank you very much for any and all help ahead of time!

    Hidralisk: Thank you for the suggestion, but that's not the problem I'm running into. I really appreciate you trying to help though.
    camickr: I'll double-check my code to see where I might've unintentionally strayed from your suggestion. I deeply appreciate the help.
    Edited by: wsizemore on Dec 6, 2007 6:51 AM
    Haven't had the time to double-check my code since I've been re-assigned to other projects (the joys of being the solo Java programmer here), but I awarded you the points, camickr, since your suggestion seems to be the one that could've put me on the right track. Thanks so much for your help.

  • Trim Edit window won't resize

    This is odd.
    When I double click an edit point to open the trim edit window, it opens up about 50% smaller than it should to cover the viewer and canvas. Even more strange, it won't let me resize the trim edit window. I go to the corner and try to pull it around, but it won't move.
    Any ideas?

    something quick to try; assuming you are already at your highest resolution, toggle it to a lower rez and then back to the higher rez.

  • Finder window won't resize after switching spaces

    I've got my mbp set up with 12 spaces and designate apps to particular spaces.
    When I open a new finder window in space 2, I can move it and resize it no problem.
    If I then switch to another space and then switch back to space 2, I can't resize the finder window. I can still move it, but just can't resize it.
    Does anyone know a way around this bug?
    Thanks!

    I can also confirm this bug.  Finder windows seem to "forget" where they are on the screen.  This is very clear when renaming a file: the highlighted, editable filename text shows up some seemingly random distance from the filename displayed in the Finder window.
    This can also be seen when using Quick Look.  The file zooms to the full Quick Look preview not from the file icon, but from some random point on the screen.
    Same goes for dragging and dropping.  For example, if you want to drag a file into an existing folder, you have to hover some distance from the actual folder, the same distance you see when you rename a file or use Quick Look.  The Finder window doesn't know its position on the screen after using Spaces or Expose.

Maybe you are looking for

  • Mozilla does not pass correctly greek letters from mailto command to email program while IE passes them correctly

    I am using windows xp greek with greek regional seetings and when I run a javascript using mailto command (either with utf-8 or iso 8859-7 encoding) , the subject and body of the message which were in Greek do not pass correctly to my email program w

  • Inverter Card question

    I have an iBook G4 with a bad inverter card. The machine works fine but the monitor is black. I have no trouble connecting to an external monitor. I also have an iBook G3 700Mhz with a bad cd drive and a fried hard drive, but the monitor works great.

  • EEWB: Insert New Table with more than one key field  for BP object

    Hi Gurus, I want to enhance Business Partner object with a new table with two key fields, one the address number and another a sequence number, because I need to save several entries for each address belonging to a determined business partner. Someth

  • Plan Driven Procurement in Classic scenario

    Dear SAP gurus, We are in SRM 7 EHP 1 with backend ECC 6 EHP 5. We are considering to use classic scenario, but we want to make sure that all the components are working fine. We have a scenario where MRP will be used in backend thus crearting a PR. W

  • Can not export JPG in Lightroom 3

    Sorry for this question but since I have upgraded from LR2 to LR3 when I choose to export a picture as a JPG it starting preparing a disc to burn and then asks me to insert Disc. Is there a new preference? Is this a bug? Has anyone else had this prob