JTable fixed Row and Column in the same window

Hi
Could anyone tip me how to make fixed row and column in the same table(s).
I know how to make column fixed and row, tried to combine them but it didnt look pretty.
Can anyone give me a tip?
Thanks! :)

Got it to work!
heres the kod.. nothing beautiful, didnt clean it up.
* NewClass.java
* Created on den 29 november 2007, 12:51
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package tablevectortest;
* @author Sockan
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
public class FixedRowCol extends JFrame {
  Object[][] data;
  Object[] column;
  JTable fixedTable,table,fixedColTable,fixedTopmodelTable;
  private int FIXED_NUM = 16;
  public FixedRowCol() {
    super( "Fixed Row Example" );
    data =  new Object[][]{
        {      "","A","A","A","",""},
        {      "a","b","","","",""},
        {      "a","","c","","",""},
        {      "","","","d","",""},
        {      "","","","","e",""},
        {      "","","","","","f"},
        {      "","b","","","",""},
        {      "","","c","","",""},
        {      "","","","d","",""},
        {      "","","","","e",""},
        {      "","b","","","",""},
        {      "","","c","","",""},
        {      "","","","d","",""},
        {      "","","","","e",""},
        {      "","","","","","f"},
        {      "I","","W","G","A",""}};
    column = new Object[]{"A","B","C","D","E","F"};
    AbstractTableModel fixedColModel = new AbstractTableModel() {
      public int getColumnCount() {
        return 1;
      public int getRowCount() {
        return data.length;
      public String getColumnName(int col) {
        return (String) column[col];
      public Object getValueAt(int row, int col) {
        return data[row][col];
      public boolean CellEditable(int row, int col) {
        return true;
    AbstractTableModel    model = new AbstractTableModel() {
      public int getColumnCount() { return column.length-2; }
      public int getRowCount() { return data.length - FIXED_NUM; }
      public String getColumnName(int col) {
       return (String)column[col+1];
      public Object getValueAt(int row, int col) {
        return data[row][col+1];
      public void setValueAt(Object obj, int row, int col) {
        data[row][col+1] = obj;
      public boolean CellEditable(int row, int col) {
        return true;
    AbstractTableModel fixedTopModel = new AbstractTableModel() {
      public int getColumnCount() { return 1; }
      public int getRowCount() { return data.length - FIXED_NUM; }
      public String getColumnName(int col) {
       return (String)column[col];
      public Object getValueAt(int row, int col) {
        return data[row][col];
      public void setValueAt(Object obj, int row, int col) {
        data[row][col] = obj;
      public boolean CellEditable(int row, int col) {
        return true;
    AbstractTableModel fixedModel = new AbstractTableModel() {     
      public int getColumnCount() { return column.length-2; }
      public int getRowCount() { return FIXED_NUM; }
      public Object getValueAt(int row, int col) {
        return data[row + (data.length - FIXED_NUM)][col+1];
    table = new JTable( model );
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fixedTable = new JTable( fixedModel );
    fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fixedColTable= new JTable(fixedColModel);
    fixedColTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fixedColTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fixedTopmodelTable = new JTable(fixedTopModel);
    fixedTopmodelTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fixedTopmodelTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);   
    JScrollPane scroll      = new JScrollPane( table );
     scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JScrollPane fixedScroll = new JScrollPane( fixedTable ) {
      public void setColumnHeaderView(Component view) {}
    fixedScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    fixedScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JScrollBar bar = scroll.getVerticalScrollBar();
    JScrollBar dummyBar = new JScrollBar() {
      public void paint(Graphics g) {}
    dummyBar.setPreferredSize(bar.getPreferredSize());
    scroll.setVerticalScrollBar(dummyBar);
    final JScrollBar bar1 = scroll.getHorizontalScrollBar();
    JScrollBar bar2 = fixedScroll.getHorizontalScrollBar();
    bar2.addAdjustmentListener(new AdjustmentListener() {
      public void adjustmentValueChanged(AdjustmentEvent e) {
        bar1.setValue(e.getValue());
    JViewport viewport = new JViewport();
    viewport.setView(fixedColTable);
    viewport.setPreferredSize(fixedColTable.getPreferredSize());
    fixedScroll.setRowHeaderView(viewport);
    fixedScroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedColTable
        .getTableHeader());   
    JViewport viewport2 = new JViewport();
    viewport2.setView(fixedTopmodelTable);
    viewport2.setPreferredSize(fixedTopmodelTable.getPreferredSize());
    scroll.setRowHeaderView(viewport2);
    scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTopmodelTable
        .getTableHeader()); 
    scroll.setPreferredSize(new Dimension(600, 19));
    fixedScroll.setPreferredSize(new Dimension(600, 100)); 
    getContentPane().add(     scroll, BorderLayout.NORTH);
    getContentPane().add(fixedScroll, BorderLayout.CENTER);   
  public static void main(String[] args) {
    FixedRowCol frame = new FixedRowCol();
    frame.addWindowListener( new WindowAdapter() {
      public void windowClosing( WindowEvent e ) {
        System.exit(0);
    frame.pack();
    frame.setVisible(true);
}

Similar Messages

  • Can Bootcamp and Parallels share the same Windows applications and data?

    I'm looking at getting an Intel iMac which will let me throw away my old PC - Yeah!
    I will have a couple of Win apps that I will need to hang on to (Quicken - Quicken for Mac is horrible, but that's another tghread). Anyway, can Bootcamp and Parallels share the same Windows applications and data?
    My thought would be to allow my wife to access Quicken from Parallels and not have to reboot. She will only need lightweight access and the overhead of running virtualization wouldn't impact her. I, on the other hand, would want to occasionally boot natively into Windows and run the same application with the same datafile. Is this possible?
    Thanks and looking forward to joining the MacIntel world!

    Thanks for all of the freplies. I suspected that BootCamp and Parallels could not shar ethe same partition, but wanted to verify. To address some of the other posts:
    Re: Quicken vs MoneyDance - I looked at MoneyDance a while back and while it is comparable to Quicken for Mac, it isn't comparable to Quicken for Windows (ergo, Quicken for Mac isn't comparable to Quicken for Windows!). But, as I said, that is a topic for another thread!
    Re: Using Bootcamp/Parallels for only one app: I actually have several apps that I still need access to on Windows. I work with many business applications than only run/are supported on Windows as well as receive some complex Office documents which Office for Mac cannot handle. Quicken (for Windows 2007) was just the best example of a consumer app where I could see wanting access from both OS X and Windows.

  • Can we create graphic and text in the same window of smartform without using template?

    we create graphic and text in the same window of smartform without using template?

    Hi Kinjal,
    as far as i understand you are talking about a template which you can partitioned and in one part you wants to show your graphics and in other part you wants to print your text, the border of template shall remain invisible.
    If you wants to do it without using a template, you can do it as sujjested by Susmitha, but creating a template will provide you more flexibility that if you wants to change the attributes in future you can do it easily.

  • Can we install Oracle 8i and 10g on the same windows server?

    I would like to install the Oracle server 8i and 10g on the same windows server? Is this possible.
    Forgive me if this question is already asked.
    Thanks in advance!
    Jay.

    WHICH Windows version? (There's more than one). It would be useful to be a little bit more precise (NT,2000,XP,2003, 32/64 bit) .
    For NT and 2000 it is possible to have both 8i and 10g, for XP and 2003 there's no support for 8i at all.

  • Refreshing JTable contents (rows and columns) handling.

    Hi,
    I have a general question related to refreshing the contents of JTable and handling some application specific requirements.In our application we are planning to refresh the contents of JTable automatically after certain period of time by fetching data from database and update the JTable contents or user has clicked refresh button.
    But following scenarios we are planning to handle when refresh is called automatically or user has clicked refresh button.
    1) User is working with data of JTable. Like rows of JTable has checkBoxes and user selects them and doing operation like viewing the details of selected rows in new details dialog. So if refreshing is done then the selection will be lost if I update the whole data in JTable.
    a)Will it be possible to append the data at the end of JTable rows without disturbing the existing JTable contents.
    b) Is it feasible to compare the data of existing rows and newly fetched rows and update only the rows whose values are changed in database or update specifically updated columns. But this comparision for finding changed values will result in performance problems.So are there any other alternatives of doing this, ideas are most welcome.
    c) Simple way is to alert the user that data will be updated and everything will be refreshed will be the choice in worst case.
    I guess many may have encountered such problems and may have solved it depending on the product requirements.
    Ideas and suggestions are most welcome.
    Regards.

    Hi,
    Here are my views and my assumptions.
    Assumptions :
    1) Your JTable is populated with list of Objects.
    2) Your tables in database is having columns like created date, created time, updated date updated time
    3) Order by clause for all the time will remain same.
    If these assumptions are correct then I think you can achieve your goal.
    Here how it is.
    Your application session will maintain last db hit time and will maintain for every hit that applicate made to fetch data from db.
    When object is created on the server side once it fetch data from table it will compare the created date/time or update date/time with the session varibale that holds last visit date/time. Based on this flag need to be set to indicate if this item is added/updated/deleted since last visit.
    And when all these object is returned to your client, the table model will iterate through the list and based on object index in the list and and if object is changed will update only that perticular row.
    Hope this is what you want to achieve.
    Regards

  • How to create table with rows and columns in the layout mode?

    One of my friends advised me to develop my whole site on the
    layout mode as its better than the standard as he says
    but I couldnot make an ordinary table with rows and columns
    in th layout mode
    is there any one who can tell me how to?
    thanx alot

    Your friend is obviously not a reliable source of HTML
    information.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Mr.Ghost" <[email protected]> wrote in
    message
    news:f060vi$npp$[email protected]..
    > One of my friends advised me to develop my whole site on
    the layout mode
    > as its
    > better than the standard as he says
    > but I couldnot make an ordinary table with rows and
    columns in th layout
    > mode
    > is there any one who can tell me how to?
    > thanx alot
    >

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • Navigate from one iview to another and open in the same window

    Hi,
    I created two iviews with Visual Composer 7.0 SP8.
    In the first iview I create a button with hyperlink action, that call the URL of the second iview. The two iviews are in separates pages.
    The problem is that the second iview is open in a different window, and I want to open this iview in the same window. I changed the propertie start in new window with "show in the portal content", but It is still open in another window.
    How can I open the second iview in the same window?
    Thanks,
    Ivan

    Hi Marcus,
    I created two iviews, the property of the first iview is window type = primary window, the second iview is defined like window type = nested window.
    Now the problem is that I can not deploy the second iview in the portal.
    Do you know what is happening?
    Best regards,
    Iván.

  • HT4818 Can you use both Bootcamp and Parallels with the same Windows 7 installed

    I have Parallels installed with Windows 7.  Can I use both Bootcamp and Parallels on the same machine depending on whether I just want to work in Windows all day (Bootcamp) or alternate during the same session (Parallels)?

    You can, yes. But there is a complication: once you activate windows it will only be activated for one of the two methods you use. So, let's say you install into boot camp and activate windows. You can then install Parallels and it will find your boot camp installation, but when running in Parallels, Windows will report that it is not activated. Or, you can activate it in Parallels and when running in Boot Camp Windows will report that it is not activated. The reason for this is because Windows thinks it is running on different computers depending on how you boot it. This may not be an issue for you if you run Windows a lot one way and just occasionally the other way, so be sure to activate Windows in whichever method you use more often. Hope this helps!

  • Fix rows and column in WAD

    Hi,
    Somebody now if I can fix the columns and rows with any function or Item in WAD version 7.0 ?
    Is there any how to ?
    Thanks.

    Hi dear Kams,
       I'm speaking about a report in which I have a lot of columns and rows, and I don´t want to move the first column or the first row. I need to immobilize them. Is like a function "freeze pane" in Microsoft Excel.  With this functionality I could see the ended column without lost the first column.
       I trying to do it in WAD version 7.0 but I don´t find this function in the Items. I would like to know is there any "how to" or item for this action ?.
       For example I have a report with the characteristic ACCOUNT and many Key Figures, I would like to move my scroll until Key Figure 4 and don´t lost the Account Column.
      I
    Account            Key Figure 1     Key Figure 2     Key Figure 3     Key Figure 4    
    10513422
    32546812
    54879632
    21548777
    21547855
    84579615
    54687951
    Thanks for your help !!

  • I sent a matrix,its row and column to a child window. However "Acess violation" & 'Memory cannot be reference" error occurs when I try to plot the data in the child dialogue. Why?

    My OS is Win200 professional.
    I'm running a data acquisition program. I'd got this main dialog which the user selects the input channel.
    The child dialog should show the graph.
    I'd initialise all the NI_DAQ configuration in the main dialog class. After acquiring the data, I send the matrix to the child window for it to plot. There is no compilation error.
    However when I try to plot the data, Windows complained about Acess violation and Memory cannot be accessed error.
    I'd attached my program below.
    Attachments:
    DataAcqDlg.cpp ‏10 KB
    Ch1Dlg.cpp ‏7 KB

    Wynn:
    I believe this problem is occurring because you are using the index operator (brackets "[","]") instead of the functional call operator (parentheses "(",")") in your code to access the matrix.
    SigCh1Vect[i] = SigCh1Max[1,i];
    The index operator is not defined for the matrix, because the C++ language does not allow a two-argument overload of this operator. Instead you have to use the function call operator for matrices and remember to use the index operator for vectors.
    I believe that what is happening is that the compiler is using one of the defined cast operators on the matrix (operator DataType) to convert the symbol "SigCh1Max" into a double pointer. It then interprets the bracket as it would any array index operation. So the compile
    r effectively sees:
    SigCh1Vect[i] = *(((Real64*)SigCh1Max) + (1,i));
    In this case, I believe the comma operator is defined to return the rightmost operand, or "i". Changing your code to
    SigCh1Vect[i] = SigCh1Max(1,i);
    should fix the problem. Please let me know if any issues exist after this fix.
    In the next release of Measurement Studio, I will recommend that the index operator be defined on the matrix classes, even if it simply throws an exception. The existence of this operator will prevent problems like this from showing up.
    Hope this helps,
    -- Chris W.
    Measurement Studio R&D
    National Instruments

  • I am trying to use both DaqMx and DaqMxBase on the same (Windows) PC

    Context: I am seeking to build and test the EPICS driver for "National Instruments - Various DAQ cards" - see http://www.aps.anl.gov/epics/modules/manufacturer.php for Windows.
    This depends on NiDaqMxBase because it is built for Linux.
    Consequently, I have installed DaqMxBase 3.7 on my (Window 7 /x64) PC, which already held DaqMx 9.7.5.
    I cannot get DaqMxBase to recognise my pci-6601 counter/timer card.
    It it recognised by DaqMx.
    Should this card be recognised by DaqMxBase on Windows?
    Is it OK to have both driver versions installed on the same PC?

    Hey Peter,
    The USB-6008/9 has it's own article on this that I will link rather than typing it, it shows which operating systems support which drivers. Base and mx are both supported in some instances.
    http://digital.ni.com/public.nsf/allkb/2B1BB86D649297FB86256F96007AC55E
    Interestingly, in this case, Linux seems to only be supported by the Base driver.
    Thanks,
    Justin, Applications Engineer

  • Can i take both Receveing of audio and video on the same window.

    hi,
    i m using AVTransmit2 and AVReceive2 for Transmission and Receiving all is doing well but problem is that AVReceive2 show Transmission of audio and video in both different windows and it use different players for audio and video. Can u tell me can i merge both audio and video at the receiving end. i m already mergeing audio and video at transmission end ???. any one tell me how can i solve this problem ???
    thx in advance.

    Hi,
    I have the same situation - to use one window to show both rtp audio and video stream, but use the ControlPanelComponent of audio player to control both players.
    I want to use the audio player as the master player so that the video player could be synchronized with it. So: audioPlayer.addController(videoPlayer).
    In the only window frame for both players, I want to show the VisualComponent(VC) of video and the ControlPanelComponent(CC) of audio. So I add both components respectly to the window frame, after I got them from each player. Because the streams are coming from the network over RTP, and they do not become realized at the same time, I add the VC and CC of first realized player(no matter it is audio or video) to window frame at first, and then change them to the desired video VC and audio audio CC.
    Though I check both player are realized and not started before I call the addController() method, the application stucked in this method. Of course I call it in a try block but no exception was thrown out.
    when I use TimeBase to synchronize them, i.e., videoPlayer.setTimeBase(audioPlayer.getTimeBase()), everything goes fine. But, I can not control both players from one ControlPanelComponent in this way.
    Anybody having any idea to solve this problem please reply.
    By the way, in the example code such as AVReceiver, where audo and video streams are shown on two window seperately, user can use the ControlPanelComponent of audio to control both player, though it seems no relevant code to support that function. The ControlPanelComponent of video can not control the audio player anyway. Anyone having any explanation to this?

  • How to have OMS,Agent and OEM on the same windows machine?

    I have installed oracle 10g database with grid control.
    I have installed oracle 10g Agent fo Windows.
    I am getting the dbconsole for my database.
    I need to create an OMS in my machine and access other databases.
    Somebody please help me in setting up the OMS in my machine and configure it to work.
    Thanxs in advance,
    Maddy

    IN 10.2.0.1 GC ,yes 10104 database is part of instal for fisrt install type
    Install is easy just you need to stop the prior db listener before proceed the em with new database install.
    1 stop db listener
    2 invoke oui
    3 choose first option
    4 provide mandatory values during install to proceed the installation.

  • Suppressing  the total row and column in OLAP datagrid

    I have created an OLAPDatagrid and everything looks fine
    except that I don't want to show the '(All)' row and column in the
    grid. Is there a way to suppress them?
    Thanks,
    Fred

    Instead of using members() in the query use children() for
    the attribute/hierarchy.

Maybe you are looking for

  • Service apple mobile device failed to start privileges

    I tried to download the latest version of ITunes, and I received this message: Service Apple mobile device failed to start. Verify that you have sufficient privileges to start system services. How can i solve the problem? Thanks for your help. Ephrem

  • New gl concept

    hi frnds I need the concept of new gl. Can anyone tell me what is advantage in new gl in ECC 6.0 rather than 4.7 version? What is the purpose to configure SPECIAL PURPOSE LEDGER? Thanks Moderator: Please, search SDN

  • Display brakes up into small blocks

    start up grey screen with apple in background and thousands of small blocks, blue scren appears normal and then desktop comes up again broken up into thousands of small blocks and then after some time screen just goes black please help!

  • List of Auto PO's

    HI, Can I get the list of only auto PO's generated from the list of all purchase orders. How is it possible? Thanks & Regards, Kiran

  • SAP LVM 2.0 Provisioned/Cloned Virtual Hosts

    Hi All, Could you please let me know how to define a virtual host in SAP LVM 2.0. I have configured Virtualization Manager in SAP LVM 2.0 and added the virtual host to SAP LVM 2.0,  But I am not able to see configured virtual host cloning screen. Kin