Why table getWidth and setWidth is not working when resize column the table

hi all,
i want to know why the setWidth is not working in the following code,
try to uncomment the code in columnMarginChanged method and run it wont resize the table.
i cont set width(using setWidth) of the other table column using getWidth of the main table column.
and i want to resize the right side columns only (you can check when you resize the any column the left and right side columns also resizing)
any suggestions could be helpful.
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableColumnModel;
public class SynTableResize extends JFrame implements TableColumnModelListener, ActionListener
    JTable  table1       = new JTable(5, 5);
    JTable  table2       = new JTable(5, 5);
    JTable  table3       = new JTable(5, 5);
    JButton btn          = new JButton("refresh");
    JPanel  pnlcontainer = new JPanel();
    public SynTableResize()
        setLayout(new BorderLayout());
        pnlcontainer.setLayout(new BoxLayout(pnlcontainer, BoxLayout.Y_AXIS));
        pnlcontainer.add(table1.getTableHeader());
        pnlcontainer.add(Box.createVerticalStrut(5));
        pnlcontainer.add(table2);
        pnlcontainer.add(Box.createVerticalStrut(5));
        pnlcontainer.add(table3);
        table2.setTableHeader(null);
        table3.setTableHeader(null);
        table1.getColumnModel().addColumnModelListener(this);
        table3.setColumnModel(table1.getColumnModel());
        table2.setColumnModel(table1.getColumnModel());
        table2.getColumnModel().addColumnModelListener(table1);
        table3.getColumnModel().addColumnModelListener(table1);
        btn.addActionListener(this);
        getContentPane().add(pnlcontainer, BorderLayout.CENTER);
        getContentPane().add(btn, BorderLayout.SOUTH);
        setSize(new Dimension(400, 400));
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    public static void main(String[] args)
        new SynTableResize();
    public void columnAdded(TableColumnModelEvent e)
    public void columnMarginChanged(ChangeEvent e)
        TableColumnModel tcm = table1.getColumnModel();
        int columns = tcm.getColumnCount();
        for (int i = 0; i < columns; i++)
            table2.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getWidth());
            table3.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getWidth());
            // the following commented code wont work.
//            table2.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth());
//            table3.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth());
//            table2.getColumnModel().getColumn(i).setWidth(tcm.getColumn(i).getWidth());
//            table3.getColumnModel().getColumn(i).setWidth(tcm.getColumn(i).getWidth());
        SwingUtilities.invokeLater(new Runnable()
            public void run()
                table2.revalidate();
                table3.revalidate();
    public void columnMoved(TableColumnModelEvent e)
    public void columnRemoved(TableColumnModelEvent e)
    public void columnSelectionChanged(ListSelectionEvent e)
    public void actionPerformed(ActionEvent e)
        JTable table = new JTable(5, 5);
        table.setColumnModel(table1.getColumnModel());
        table.getColumnModel().addColumnModelListener(table1);
        pnlcontainer.add(Box.createVerticalStrut(5));
        pnlcontainer.add(table);
        pnlcontainer.validate();
        pnlcontainer.repaint();
}thanks
dayananda b v

hi,
thanks for your replay,
yes i know that, you can check the following code it works fine.
actually what i want is, when i resize table column it shold not automaticaly reszie when table resized and i dont want horizontal scroll bar, meaning that all table columns should resize with in the table size(say width 300)
if i make table autoresize off than horizontal scroll bar will appear and the other columns moved and i want scroll to view other columns.
please suggest me some way doing it, i tried with doLayout() no help,
doLayout() method only can be used when table resizes. first off all i want to restrict table resizing with in the limited size
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.table.TableColumnModel;
public class TempSycnTable extends JFrame
    JTable  table1       = new JTable(5, 5);
    MyTable table2       = new MyTable(5, 5);
    MyTable table3       = new MyTable(5, 5);
    JPanel  pnlcontainer = new JPanel();
    public TempSycnTable()
        JScrollPane src2 = new JScrollPane(table2);
        JScrollPane src3 = new JScrollPane(table3);
//        table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//        table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//        table3.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//        src2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//        src3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        table2.setTableHeader(null);
        table3.setTableHeader(null);
        table3.setColumnModel(table1.getColumnModel());
        table2.setColumnModel(table1.getColumnModel());
        table2.getColumnModel().addColumnModelListener(table1);
        table3.getColumnModel().addColumnModelListener(table1);
        table2.setTableHeader(null);
        table3.setTableHeader(null);
        setLayout(new BorderLayout());
        pnlcontainer.setLayout(new BoxLayout(pnlcontainer, BoxLayout.Y_AXIS));
        pnlcontainer.add(table1.getTableHeader());
        pnlcontainer.add(Box.createVerticalStrut(5));
        pnlcontainer.add(src2);
        pnlcontainer.add(Box.createVerticalStrut(5));
        pnlcontainer.add(src3);
        getContentPane().add(pnlcontainer, BorderLayout.CENTER);
        setSize(new Dimension(300, 300));
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    public static void main(String[] args)
        new TempSycnTable();
    class MyTable extends JTable
        public MyTable()
            super();
        public MyTable(int numRows, int numColumns)
            super(numRows, numColumns);
        public void columnMarginChanged(ChangeEvent event)
            final TableColumnModel eventModel = table1.getColumnModel();
            final TableColumnModel thisModel = getColumnModel();
            final int columnCount = eventModel.getColumnCount();
            for (int i = 0; i < columnCount; i++)
                thisModel.getColumn(i).setWidth(eventModel.getColumn(i).getWidth());
            repaint();
}thanks
daya

Similar Messages

  • New Mac: Why are CC and Photoshop Elements not working when Lightroom and Reader are fine

    Last week I changed computers (swapping an old Mac for a 13-in MacBook Pro Retina running OSX Yosemite 10.10.3. I copied all my data over to the new machine using Migration Assistant.
    All programs work fine (including my copy of Lightroom 3 and Reader XI). But my CC and Photoshop Elements 10 do not. I have tried uninstalling both, but whenever I try to reinstall PE10 from its disk or download it just stops almost at the end. I then I get an "initiation failed" message, along with a request to download the now defunct "Support Advisor" app!
    I cannot download Adobe Application Manager, or the CC desktop app either - for the former I get an "initiation failed" message, along with the "download Support Advisor" app" message again! For the latter I get a message saying "Adobe Creative Cloud Is Needed to Resolve this problem - however it is missing or damaged." Then I get a message and a link to download Creative Cloud. Then when I've downloaded it and I click on the installer... it runs for a bit and then I get the message again: "Adobe Creative Cloud Is Needed to Resolve this problem - however it is missing or damaged." And I get a prompt and link to download the CC app. Guess what happens next? And so it goes on. And on and on, in a tedious circle.
    This is incredibly annoying and frustrating as I have work to do! Anyone have any ideas what's happening?
    Cheers
    K

    do not use migration to install adobe programs.
    you should uninstall and clean whatever you've done, Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    then dl the cc desktop app to your new computer and use it to install your adobe cc programs, Download Adobe Creative Cloud apps | Free Adobe CC trial
    if you have non-subscription adobe programs, use the installation files for them:
    Downloadable installation files available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 | 12 | 11, 10 | 9, 8, 7 win | 8 mac | 7 mac
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7 win | 8 mac | 7 mac
    Lightroom:  5.7.1| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5.5, 5 | 1
    Contribute:  CS5 | CS4, CS3 | 3,2
    FrameMaker:  12, 11, 10, 9, 8, 7.2
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • I bought Iproxify throught app store and it does not work. I contacted the creator but I have not had any answer. What can I do to get my money back? and please take him down.

    I bought IPROXIFY throught APP STORE and it does not work. I contacted the creator and he has not answered.
    How can I get my money back? and please take him down of your page as we (users) think that we are buying products that worked backed up by MAC.
    Looking forward for an answer in order to keep buying in APP Store

    This article may clear up some confusion you may have regarding third party developers and Apple.
    The Mac App Store Discussion, what is it for?

  • My i4s wifi button is not working. when i opened the setting and then wifi the button is greyed out. then i opened general and then about. in the bar of wifi address it is written N/A. what does its mean. i have done all other things like setting general

    my i4s wifi button is not working. when i opened the setting and then wifi the button is greyed out. then i opened general and then about. in the bar of wifi address it is written N/A. what does its mean. i have done all other things like setting >general<reset<reset network setting. but all in vain. tell me the solution

    restore your phone as new through itunes. if the issue persists after a factory restore via itunes, it means you've got a hardware issue and the phone needs to be repaired

  • Why is my touch screen function not working when using facetime

    Why is my touch screen function not working when using facetime

    Hello megascones,
    After reviewing your post, it sounds like the screen is not responding to touch in one app. I would recommend that you read this article, it may be able to help the issue.
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Restart your device. If you can't restart, reset your device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • The Horizontal & vertical scroll is not visible or not working when i run the form in Forms 6i.

    Hi all,
    The Horizontal & vertical scroll is not visible or not working when i run the form.
    In this form , there are 5 canvas namely
    CANVAS2 - Stacked Canvas
    PASS - Content Canvas
    MAT_RATES - Content Canvas
    DATE - Content Canvas
    PREVIOUS - Content Canvas
    I have set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the WINDOW Property.
    I have  set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the STACKED CANVAS Property .
    But still the Horizontal and Vertical Scroll Bar is not working when i run the Form.
    Help me with this please. How do i make it visible??
    Oracle Forms 6i..
    Thank You.

    Vijetha wrote:
    Hi all,
    The Horizontal & vertical scroll is not visible or not working when i run the form.
    I have set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the WINDOW Property.
    I have  set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the STACKED CANVAS Property .
    But still the Horizontal and Vertical Scroll Bar is not working when i run the Form.
    Help me with this please. How do i make it visible??
    Oracle Forms 6i..
    Thank You.
    hello vijetha,
    window and canvas show scroll bar when it need.
    You should show block property
    and set block scroll bar
    hope this helps..
    Hamid

  • I have an apple iphone4 im facing the problem that my phone senser is not working when i rotate the phone in videos or music play there is working from the senser can u tell me what can i do for this....

    i have an apple iphone4 im facing the problem that my phone senser is not working when i rotate the phone in videos or music play there is working from the senser can u tell me what can i do for this....

    If you double tap the home button, and then swipe your finger to the right, make sure you DO NOT have the Lock Orientation button enabled.
    You know it is disabled if there is no padlock in the middle of the icon.

  • Flash catalyst cs5.5 not working when i run the project

    when i ran prodjects in flash catalyst cs5 it came up as a webpage that could scroll, now in cs5.5 when i run the prodject it cannot scroll and it doesn't scroll when you export for web servers, help much apreciated.

    Vijetha wrote:
    Hi all,
    The Horizontal & vertical scroll is not visible or not working when i run the form.
    I have set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the WINDOW Property.
    I have  set "Show Horizontal Scroll Bar" to "Yes" and  "Show Vertical Scroll Bar" to "Yes" in the STACKED CANVAS Property .
    But still the Horizontal and Vertical Scroll Bar is not working when i run the Form.
    Help me with this please. How do i make it visible??
    Oracle Forms 6i..
    Thank You.
    hello vijetha,
    window and canvas show scroll bar when it need.
    You should show block property
    and set block scroll bar
    hope this helps..
    Hamid

  • Why are some of my keys not working when I put a bit of pressure on it?

    Hi there, since 4 months ago I've noticed that my a, q, 1, backspace, and volume buttons do not work when theres a little bit of pressure on or under it. It kind of bothers me because I cant lay in bed and do my things, I have to put it on a table. So my question is, why is this and how can I fix this?
    5 or more weeks ago, I can't remember, my keys did suddenly work when there was a bit of pressure on / under it, but I don't know how..
    I'm running OS X Mavericks 10.9.4
    Processor: 1.3 GHz Intel Core i5
    Memore: 4 GB 1600 MHz DDR3

    What is your operating system?  Reader version?  How do you convert to PDF?
    You write that "some" of the links don't open; what's the difference with links that do open?

  • MAC Mouse and Keyboard Do Not Work, when I am trying to re-install the OS using "Command R" option

    I am trying to re-install MAC OS 10.8.2, but when I hold "command R" I am asked for the firmware password, but the keyboard and mouse do not work.
    If I only select "option" during the boot up process it will ask me for the firmware password, keyboard and mouse work, but I can only select the HD option.
    Can someone advise what is the problem here, and your resolution.
    I have tried different commands "option + command + R' with no luck.

    I tried what was provided on the link, but it is not working.
    I hold it down, before the gray screen and the chime, but it only prompts but the firmware password.
    I tried based on the specific order in the support document and at a random press and hold.
    No go any other thoughts?

  • HT4972 2nd generation ipod touch is pretty much no good anymore?  It is not able to upgrade to iOS5.1 and so will not work with many of the Apps now available in the App store.  Is there any way to find out which apps will work with 2nd generat

    2nd generation ipod touch is pretty much no good anymore?  It is not able to upgrade to iOS5.1 and so will not work with many Apps in the iTunes store?  Is there a way to find out if the App will work before you download?

    Look to the app developer to provide that information when browsing the iTunes Store.
    The iPod Touch still works, so what's your problem with it? It still works with older apps, it still does what it's intended to do.
    If you aren't happy then sell it and buy a new one.

  • Hello sir i purchased second hand iphone4s with ios 7 beta version after 2 month on 6 oct my iphone ask for a uers id that is unknown by me my new id and password also not work when i contavt with previous owner and use his id and password which he use on

    plz help me by mail me on   [email protected]

    the previos owner id and password also not work there what i do all do everything downdrade , upgrade but everytime ask for previous id and password...........i also erase find my phone from previous user id

  • Excel function and ev function not working in static column key

    I have created a evdre report and I notice that  when I tried to use any excel function and ev functions in the static column key cell to get the value for that cell, it's not working.
    e.g I have Col key define as:
    ColKeyRange  Sheet!&$J$12:$N$14
    In K13 which is key id for time. I define is as = $K$10 where K10 is the time value from current view, it not working,the value is still K13 = $K$10. then I tried to use EVCVW function to replace K10, it also not working, but I use the same function in the description of the ID underneath, both of the are working, Any thought?
    Edited by: DFW on Feb 9, 2010 7:33 PM

    Hi,
    That was exactly what I meant. They just dont work on the green ID areas or the yellow data region. Few days back even I tried that, but didnt work. So, I followed the different approach. I dont remember about the dynamic templates. Are you sure that the functions were written in the green ID region?
    I remember this used to work fine in the MS version. However, in the NW version, even I am not able to make them work.
    Edited by: nilanjan chatterjee on Feb 9, 2010 9:38 PM

  • The remote does not work, when i turn the tv on I see the apple tv and the itune icon on the screen

    the remote on apple tv does not work,when i turn on the tv Isee the appletv and the itune icon on the screen.

    Did you do a software update?
    AppleTV is unable to start properly.  You need to connect to a computer running iTunes as detailed here:
    Apple TV (2nd and 3rd generation): Restoring your Apple TV

  • I bought an iphone of my friend and used my blackberry sim in it, it say i have signal on 3g but imessage and twitter does not work when not connected to wifi, and i dont know how to get it to work out of the house?

    The phone is not stolen but it does not work out side of the house

    if it doesnt match that means your iPhone is not provisioned for the carrier you are trying to use. Your iPhone would need to be unlocked in order to use on other carriers. You will need to contact your carrier to see if this iPhone is unlocked py providing them the IMEI. If the iPhone is not unlocked you will need to contact the carrier that the iPhone is locked to to see if they will unlock the device to use on another carrier.

Maybe you are looking for

  • Airport Card no longer recognized by PowerBook

    I always take my PowerBook G4 to class with me for the purpose of taking notes during class. I was connected to the internet there, over the wireless network (on campus) with no problem. When I got back home, my PowerBook wasn't seeing the wireless n

  • Submitting only part of a Flash form's data - possible?

    So, in this app that I'm building, it would be REALLY handy to be able to process select portions of the Flash form. It's essentially an app with a couple of smaller sub-apps contained within; think of something like a CRM app. Is it possible to only

  • Metadata keeps wanting to be saved on assets.

    Greetings, My location has a FCS installation as well as a FileMaker Server installation. We are pushing metadata from FMS via XML to FCS. This process works fine. However, when users are manipulating assets in FCS that have had metadata pushed into

  • FF does NOT remember tabs

    In the past FF has always saved my tabs so that when I brought FF up all of my tabs would reopen. I do have Tools\Options\General set to remember all tabs and reopen them on FF startup. I'm running FF 3.6.13, OS = Vista

  • Syncing of photos and safe deletion

    Hi All, My household currently has a iPhone 4S and a iPad 4 both with different account and both are set up to download photos via my home wifi network to my PC (windows 7) I think this is set up through iCloud?  My worry is if I delete photos from e