Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24193 > unrolled thread

Code Included: Freeze column

Started byHaircuts Are Important <clusardi2k@aol.com>
First post2013-05-29 12:55 -0700
Last post2013-05-31 12:30 -0700
Articles 13 on this page of 33 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-29 12:55 -0700
    Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-29 16:29 -0400
      Re: Code Included: Freeze column clusardi2k@aol.com - 2013-05-29 23:53 -0700
        Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-30 21:40 -0400
          Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:19 -0700
            Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-31 23:59 -0400
              Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-03 10:18 -0700
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-03 12:48 -0700
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-03 23:03 -0400
                  Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-04 05:05 -0700
                    Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-04 23:04 -0400
                      Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-05 11:53 -0700
                        Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-05 16:02 -0400
                          Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-05 13:09 -0700
                          Re: Code Included: Freeze column clusardi2k@aol.com - 2013-06-05 16:27 -0700
                            Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-05 17:35 -0700
                            Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-06 21:42 -0400
                              Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-10 09:34 -0700
                                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-10 13:49 -0400
                  Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 12:17 -0700
                    Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-04 12:54 -0700
                      Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 14:17 -0700
                        Re: Code Included: Freeze column Joerg Meier <joergmmeier@arcor.de> - 2013-06-05 00:12 +0200
                          Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-04 21:39 -0400
                          Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 19:48 -0700
                            Re: Code Included: Freeze column Joerg Meier <joergmmeier@arcor.de> - 2013-06-05 07:36 +0200
                              Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 22:46 -0700
          Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:35 -0700
            Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-05-31 11:43 -0700
              Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:50 -0700
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-05-31 12:37 -0700
                  Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 12:44 -0700
            Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 12:30 -0700

Page 2 of 2 — ← Prev page 1 [2]


#24287

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-06-04 12:54 -0700
Message-ID<e013e82b-8811-4bf7-a76d-c65ebd1e4cb9@l1g2000yqf.googlegroups.com>
In reply to#24286
On Jun 4, 3:17 pm, Lew <lewbl...@gmail.com> wrote:
> >  Haircuts Are Important wrote:
> > > > For improved visual coherence, the tables can share a selection
> > > > model, much as you have done with the scrollbars'
> > > > BoundedRangeModel:
>
> ...
>
> What happened to all your posts?

I'm still listening.

Thanks,

[toc] | [prev] | [next] | [standalone]


#24288

FromLew <lewbloch@gmail.com>
Date2013-06-04 14:17 -0700
Message-ID<63681290-d7bc-48d9-a919-4209f454f9fe@googlegroups.com>
In reply to#24287
Haircuts Are Important wrote:
> Lew wrote:
> > >  Haircuts Are Important wrote:
> > > > > For improved visual coherence, the tables can share a selection
> > > > > model, much as you have done with the scrollbars'
> > > > > BoundedRangeModel:
> 
> > ...
> 
> > What happened to all your posts?
> 
> I'm still listening.

That's nice.

What happened to all your posts?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#24290

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-06-05 00:12 +0200
Message-ID<1l4u82e78abn0$.1pqqndsg2e5m4$.dlg@40tude.net>
In reply to#24288
On Tue, 4 Jun 2013 14:17:29 -0700 (PDT), Lew wrote:

> Haircuts Are Important wrote:
>> Lew wrote:
>>> >  Haircuts Are Important wrote:
>>> > > > For improved visual coherence, the tables can share a selection
>>> > > > model, much as you have done with the scrollbars'
>>> > > > BoundedRangeModel:
>>> ...
>>> What happened to all your posts?
>> I'm still listening.
> That's nice.

> What happened to all your posts?

If you have issues with the posts of multiple people, the issue might not
be on their eind.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#24294

From"John B. Matthews" <nospam@nospam.invalid>
Date2013-06-04 21:39 -0400
Message-ID<nospam-F8082D.21390604062013@news.aioe.org>
In reply to#24290
In article <1l4u82e78abn0$.1pqqndsg2e5m4$.dlg@40tude.net>,
 Joerg Meier <joergmmeier@arcor.de> wrote:

> On Tue, 4 Jun 2013 14:17:29 -0700 (PDT), Lew wrote:
> 
> > Haircuts Are Important wrote:
> >> Lew wrote:
> >>> >  Haircuts Are Important wrote:
> >>> > > > For improved visual coherence, the tables can share a 
> >>> > > > selection model, much as you have done with the 
> >>> > > > scrollbars' BoundedRangeModel:
> >>> ...
> >>> What happened to all your posts?
> >> I'm still listening.
> > That's nice.
> 
> > What happened to all your posts?
> 
> If you have issues with the posts of multiple people, the issue 
> might not be on their end.

With so many of clusardi2k's posts deleted, I am unable to follow 
the thread:

<https://groups.google.com/forum/?fromgroups&hl=en#!topic/comp.lang.java.programmer/ze39FiJ8IDI>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#24296

FromLew <lewbloch@gmail.com>
Date2013-06-04 19:48 -0700
Message-ID<8f6ed992-729c-4d36-83d4-cbbc4c563623@googlegroups.com>
In reply to#24290
Joerg Meier wrote:
> Lew wrote:
> > Haircuts Are Important wrote:
> >> Lew wrote:
> >>> >  Haircuts Are Important wrote:
> >>> > > > For improved visual coherence, the tables can share a selection
> >>> > > > model, much as you have done with the scrollbars'
> >>> > > > BoundedRangeModel:
> >>> ...
> 
> >>> What happened to all your posts?
> 
> >> I'm still listening.
> 
> > That's nice.
> > What happened to all your posts?
> 
> If you have issues with the posts of multiple people, the issue might not
> be on their eind.

I'm sure that is true, but what does it have to do with this thread?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#24298

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-06-05 07:36 +0200
Message-ID<1l7t3r90bjqsl.l97h5dnieag5.dlg@40tude.net>
In reply to#24296
On Tue, 4 Jun 2013 19:48:57 -0700 (PDT), Lew wrote:

> Joerg Meier wrote:
>> Lew wrote:
>>> Haircuts Are Important wrote:
>>>> Lew wrote:
>>>>> >  Haircuts Are Important wrote:
>>>>> > > > For improved visual coherence, the tables can share a selection
>>>>> > > > model, much as you have done with the scrollbars'
>>>>> > > > BoundedRangeModel:
>>>>> ...

>>>>> What happened to all your posts?
>>>> I'm still listening.
>>> That's nice.
>>> What happened to all your posts?
>> If you have issues with the posts of multiple people, the issue might not
>> be on their eind.
> I'm sure that is true, but what does it have to do with this thread?

On this thread, you have addressed two different people and asked about
their posts, Haircuts and John Matthews. From the context, I'm now guessing
the first one was due to not having a post of Haircuts left to reply to ?

Either way, it does seem to be on 'your' end (Google) - the posts are still
visible on my news server, and nothing about them seems special or unusual.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#24299

FromLew <lewbloch@gmail.com>
Date2013-06-04 22:46 -0700
Message-ID<22824519-7544-4447-b379-06dad74ae882@googlegroups.com>
In reply to#24298
Joerg Meier wrote:
> Lew wrote:
> > Joerg Meier wrote:
> >> Lew wrote:
> >>> Haircuts Are Important wrote:
> >>>> Lew wrote:
> >>>>> > �Haircuts Are Important wrote:
> >>>>> > > > For improved visual coherence, the tables can share a selection
> >>>>> > > > model, much as you have done with the scrollbars'
> >>>>> > > > BoundedRangeModel:
> >>>>> ...
> 
> >>>>> What happened to all your posts?
> 
> >>>> I'm still listening.
> 
> >>> That's nice.
> 
> >>> What happened to all your posts?
> 
> >> If you have issues with the posts of multiple people, the issue might not
> >> be on their eind.
> 
> > I'm sure that is true, but what does it have to do with this thread?
> 
> On this thread, you have addressed two different people and asked about
> their posts, Haircuts and John Matthews. From the context, I'm now guessing

Looking at the attributions, which your posts preserved, you can see that 
both questions were addressed to the same person.

> the first one was due to not having a post of Haircuts left to reply to ?

It was due to every post of Haircuts' being marked "This message has been deleted."

Something to which John Matthews also alluded in response to your post.

> Either way, it does seem to be on 'your' end (Google) - the posts are still
> visible on my news server, and nothing about them seems special or unusual.

Thank you. That is helpful to know.

Still, for even GG to report that the messages have been deleted, someone 
took an affirmative action to delete them. So I took the reasonable action 
of asking the poster what happened, under the hypothesis that they initiated
the deletion. The answer I got was tangential at best, and completely 
devoid of useful content, so I repeated the question - to the same person.

So I ask Haircut this: Did you in some fashion "delete" your posts?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#24208

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-05-31 11:35 -0700
Message-ID<18504f7e-143d-4366-a1fd-c16744135b08@j7g2000vbj.googlegroups.com>
In reply to#24200
I have modified the code at the below link. Everything seems to work
except horizontal scrolling across the two tables:
http://www.java2s.com/Code/Java/Swing-Components/FixedTableColumnExam....

Again, at run-time (via the routine attached to the timer) the
project
will add different data to the bottom of each table. The bottom row
is
highlighted in each table. The frozen columns are doing what they're
suppose to.


But, when I use the scrollbar on the right table, the left table does
not move.


Here is a non-compilable summary of the resulting code. (The timer
class is not there) Can you get the left table to match the scrolling
on the right table?


Thanks


package test;

class Test extends JFrame{
  public static FixedModel fixedModel;//FixedModel extends
AbstractTableModel see below
  public static ModelWithScrollbar mainModel;//ModelWithScrollbar
extends AbstractTableModel see below
  public static JTable fixedTable;  //Has the frozen columns
  public static JTable scrollTable; //Has a visible scrollbar


  public Test (){

    t.startTimer();

    this.setVisible(true);
    this.setTitle ("An example");

    fixedModel = new FixedModel ();

    fixedTable = new JTable (fixedModel){
    @Override
    public void valueChanged(ListSelectionEvent e){
      super.valueChanged(e);
      checkSelection(true);
    }
   };

   mainModel = new ModelWithScrollbar();

   scrollTable = new JTable (mainModel){
   @Override
   public void valueChanged(ListSelectionEvent e){
     super.valueChanged(e);
     checkSelection(false);
   }
  };


   Dimension dimension = new Dimension(0,0);
   fixedTable.getTableHeader().setPreferredSize(dimension);
   scrollTable.getTableHeader().setPreferredSize(dimension);

   fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   scrollTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

   fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   scrollTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

   scrollTable.setFocusable(false);

   JScrollPane jScrollPane1 = new JScrollPane(scrollTable);

   JViewport viewport = new JViewport();
   viewport.setView(fixedTable);
   viewport.setPreferredSize(fixedTable,getPreferredSize());
   jScrollPane1.setRowHeaderView(viewport);

 
jScrollPane1.setCorner(JScrollPane.UPPER_LEFT_CORNER,fixedTable.getTableHea­
der());
   getContentPane().add(jScrollPane1,BorderLayout.CENTER);


}


//Indirectly called via Timer t
public static void add_Rows_To_Tables (){

   String[] tmp1 = new String [3];
   String[] tmp2 = new String [90];

   //...
   fixedModel.addRow(Arrays.asList(tmp1));
   mainModel.addRow(Arrays.asList(tmp2));

   fixedTable.getSelectionMode().setSelectionInterval(
      fixedTable.getRowCount () - 1,
      fixedTable.getRowCount () - 1);

   scrollTable.getSelectionMode().setSelectionInterval(
      scrollTable.getRowCount () - 1,
      scrollTable.getRowCount () - 1);

   fixedTable.scrollRectToVisible(
      new Rectangle (
        fixedTable.getCellRect(
           fixedTable.getRowCount() - 1,
           0,
           true)));


   scrollTable.scrollRectToVisible(
      new Rectangle (
        scrollTable.getCellRect(
           scrollTable.getRowCount() - 1,
           0,
           true)));
}


private void checkSelection(boolean isFixedTable){
   int fixedSelectedIndex = fixedTable.geSelectedRow();
   int selectedIndex = scrollTable.getSelectedRow();

   if (fixedSelectedIndex != selectedIndex){
      if (isFixedTable){
 
scrollTable.setRowSelectionInterval(fixedSelectedIndex,fixedSelectedIndex);
      } else {
 
fixedTable.setRowSelectionInterval(selectedIndex,selectedIndex);
      }
    }
}


public static main (String[] args){
   Test frame = new Test ();

   frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e){
         System.exit(0);
      }
    });
    frame.setVisible (true);
   }
}


public class FixedModel extends AbstractTableModel{
   static public List<String> columnNames = new ArrayList();
   static public List<List> data = new ArrayList();

   {//annonymous class
       for (int i = 0;i < 3; i++){
          columnNames.add(" ");
       }
   }


   public void addRow(List rowData){
      data.add(rowData);
      fireTableRowsInserted(data.size() - 1,data.size() - 1);
   }


   public int getColumnCount() {
        return columnNames.size();
      }

      public int getRowCount() {
        return data.size();
      }

      @Override
      public String getColumnName(int col) {
         try {
            return columnNames.get(col);
         } catch (Exception exception) {
            return null;
         }
      }

      public Object getValueAt(int row, int col) {
        return data.get(row).get(col);
      }


      public boolean isCellEditable(int row, int col) {
        return false;
      }

      public Class getColumnClass(int c) {
         return getValueAt(0,c).getClass();
      }
};


public class ModelWithScrollbar extends AbstractTableModel{
   static public List<String> columnNames = new ArrayList();
   static public List<List> data = new ArrayList();

   {//annonymous class
       for (int i = 0;i < 90; i++){
          columnNames.add(" ");
       }
   }


   public void addRow(List rowData){
      data.add(rowData);
      fireTableRowsInserted(data.size() - 1,data.size() - 1);
   }

   public int getColumnCount() {
        return columnNames.size();
      }

      public int getRowCount() {
        return data.size();
      }

      @Override
      public String getColumnName(int col) {
         try {
            return columnNames.get(col);
         } catch (Exception exception) {
            return null;
         }
      }

      public Object getValueAt(int row, int col) {
        return data.get(row).get(col);
      }

      public boolean isCellEditable(int row, int col) {
        return false;
      }

      public Class getColumnClass(int c) {
         try {
            return getValueAt(0,c).getClass();
         }
         catch (Exception exception) {// MAY LEAD TO ERROR
            return this.getClass();
         }
      }
};

[toc] | [prev] | [next] | [standalone]


#24209

FromLew <lewbloch@gmail.com>
Date2013-05-31 11:43 -0700
Message-ID<581639b5-3d24-436f-9f72-f44b4a260aae@googlegroups.com>
In reply to#24208
Haircuts Are Important wrote:
> public class ModelWithScrollbar extends AbstractTableModel{
>    static public List<String> columnNames = new ArrayList();
>    static public List<List> data = new ArrayList();
> 
>    {//annonymous [sic] class

There is no anonymous class here. Why the comment?

>        for (int i = 0;i < 90; i++){
>           columnNames.add(" ");
>        }
>    }
> 
>    public void addRow(List rowData){
>       data.add(rowData);
>       fireTableRowsInserted(data.size() - 1,data.size() - 1);
>    }
...
> };

[toc] | [prev] | [next] | [standalone]


#24211

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-05-31 11:50 -0700
Message-ID<1beef50f-c077-4af0-b2c6-a122040eeda4@g7g2000vbv.googlegroups.com>
In reply to#24209
On May 31, 2:43 pm, Lew <lewbl...@gmail.com> wrote:
> Haircuts Are Important wrote:
> > public class ModelWithScrollbar extends AbstractTableModel{
> >    static public List<String> columnNames = new ArrayList();
> >    static public List<List> data = new ArrayList();
>
> >    {//annonymous [sic] class
>
> There is no anonymous class here. Why the comment?
> >        for (int i = 0;i < 90; i++){
> >           columnNames.add(" ");
> >        }
> >    }

If it's not an annonymous class what is it called.

Thanks,

[toc] | [prev] | [next] | [standalone]


#24213

FromLew <lewbloch@gmail.com>
Date2013-05-31 12:37 -0700
Message-ID<d45301ee-8f68-47b7-9a47-e8a1123ed33e@googlegroups.com>
In reply to#24211
Haircuts Are Important wrote:
>Lew wrote:
>> Haircuts Are Important wrote:
>>> public class ModelWithScrollbar extends AbstractTableModel{
> > >    static public List<String> columnNames = new ArrayList();
> > >    static public List<List> data = new ArrayList();
> >
> > >    {//annonymous [sic] class
> >
> > There is no anonymous class here. Why the comment?
> 
> > >        for (int i = 0;i < 90; i++){
> > >           columnNames.add(" ");
> > >        }
> > >    }
> 
> If it's not an annonymous [sic] class what is it called.

If by "it" you mean the block with the 'for' loop in it, that is an initializer. 
It is not any kind of class, let alone an anonymous one.

It is also a bug. You are using an instance initializer to initialize a static 
construct.

That means that every instance of that class, should there ever be more 
than one, will add another 90 items to the 'columnNames' collection, resulting 
in a total size in excess of 90.

It is usually a bad idea to initialize a static structure in an instance context.

Study the following terms to be clear on these matters: "initializer" (both "static initializer" 
and "instance initializer"), "class", "anonymous class", "static member".

-- 
LEw

[toc] | [prev] | [next] | [standalone]


#24214

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-05-31 12:44 -0700
Message-ID<06affbf4-4e18-4929-ac63-2612d4f12d74@i4g2000vbl.googlegroups.com>
In reply to#24213
On May 31, 3:37 pm, Lew <lewbl...@gmail.com> wrote:
> Haircuts Are Important wrote:
> >Lew wrote:
> >> Haircuts Are Important wrote:
> >>> public class ModelWithScrollbar extends AbstractTableModel{
> > > >    static public List<String> columnNames = new ArrayList();
> > > >    static public List<List> data = new ArrayList();
>
> > > >    {//annonymous [sic] class
>
> > > There is no anonymous class here. Why the comment?
>
> > > >        for (int i = 0;i < 90; i++){
> > > >           columnNames.add(" ");
> > > >        }
> > > >    }
>
> > If it's not an annonymous [sic] class what is it called.
>
> If by "it" you mean the block with the 'for' loop in it, that is an initializer.
> It is not any kind of class, let alone an anonymous one.
>
> It is also a bug. You are using an instance initializer to initialize a static
> construct.
>
> That means that every instance of that class, should there ever be more
> than one, will add another 90 items to the 'columnNames' collection, resulting
> in a total size in excess of 90.
>
> It is usually a bad idea to initialize a static structure in an instance context.
>
> Study the following terms to be clear on these matters: "initializer" (both "static initializer"
> and "instance initializer"), "class", "anonymous class", "static member".
>

Thanks,

[toc] | [prev] | [next] | [standalone]


#24212

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-05-31 12:30 -0700
Message-ID<da8a7828-7e3f-4909-9ef1-0d4736f25995@w15g2000vbn.googlegroups.com>
In reply to#24208
On May 31, 2:35 pm, Haircuts Are Important <clusard...@aol.com> wrote:
> I have modified the code at the below link. Everything seems to work

Let me try to clarify the problem, when I use the vertical
scrollbar on the right table, the left table does not move.

Any assistance would be greatly appreciated!

Thanks,

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.java.programmer


csiph-web