JTable with custom column model and model table does not display the table header

Hello

I create a JTable with a custom table model and a custom column template. However the table header is not displayed (Yes, it's in a get). I have narrowed the problem down in one compilable example:

Thanks for your help.
import javax.swing.*;
import javax.swing.table.*;

public class Test1 extends JFrame
{
     public static void main(String args[])
     {
          JTable table;
          TableColumnModel colModel=createTestColumnModel();
          TestTableModel tableModel=new TestTableModel();
          Test1 frame=new Test1();

          table=new JTable(tableModel, colModel);
          frame.getContentPane().add(new JScrollPane(table));

          frame.setSize(200,200);
          frame.setVisible(true);
     }

     private static DefaultTableColumnModel createTestColumnModel()
     {
          DefaultTableColumnModel columnModel=new DefaultTableColumnModel();
          columnModel.addColumn(new TableColumn(0));

          return columnModel;
     }

     static class TestTableModel extends AbstractTableModel
     {
          public int getColumnCount()
          {
               return 1;
          }

          public Class<?> getColumnClass(int columnIndex)
          {
               return String.class;
          }

          public String getColumnName(int column)
          {
               return "col";
          }

          public int getRowCount()
          {
               return 1;
          }

          public Object getValueAt(int row, int col)
          {
               return "test";
          }

          public void setValueAt(Object aValue, int rowIndex, int columnIndex)
          {
          }
     }
}
Published by: 802416 on October 14, 2010 04:29
added
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

See http://download.oracle.com/javase/6/docs/api/javax/swing/table/TableColumn.html#setHeaderValue (java.lang.Object)
When the TableColumn is created, the default headerValue is null
So the header ends up rendered empty label (probably of size 0 if the JTable calculates its size of header based on the size of the default rendering tool).

It worked:

     private static DefaultTableColumnModel createTestColumnModel()
     {
          DefaultTableColumnModel columnModel=new DefaultTableColumnModel();
                TableColumn col = new TableColumn(0);
                col.setHeaderValue("Header Title");
          columnModel.addColumn(col);
                return columnModel;
     }

Published by: jduprez on October 14, 2010 14:09
Beaten by a fraction of a second!

Published by: jduprez on October 14, 2010 14:10
OK, by a split of 17 minutes, specifically: o)

Tags: Java

Similar Questions

  • menu of hyperlink is displayed when text is selected, not when the Menu item is selected. And of course does not display the available links. Where I'm wrong?

    Try to make hyperlinks in a menu item. If I select the menu item, the menu of hyperlinks is not displayed in the menu bar. If I click on new and then the tex in the link is selected, the hyperlink menu appears but the drop down menu does not offer the available links. Where I'm wrong?

    I think you use a menu by default on the page?

    It's design of menu by default, because they are already linked with the respective pages that you can't change.

    You can try to create the menu manual.

    Thank you

    Sanjit

  • adding programitically column in flex series graphic does not display the graph

    <? XML version = "1.0"? >
    <! - example showing using mx:LineSeries vs using as to create graphic series by program - >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' creationComplete = "drawChart ()" layout = "absolute" > "
    < mx:Script >
    <! [CDATA]
    Import mx.controls.Alert;
    Import mx.charts.series.ColumnSeries;
    Import mx.charts.series.LineSeries;
    Import mx.collections.ArrayCollection;

    [Bindable]
    public var categoryArray:ArrayCollection = new ArrayCollection();
    [Bindable]
    public var sArray:ArrayCollection = new ArrayCollection();
    public function drawChart (): void
    {
    var histMax:int = 25;
    var histMin:int = 5;
    var countMax:int = 6;
    var tmpArr:Array = new Array();
    categoryArray.removeAll ();
    for (var n: int = 0; n < 10; n ++)
    {
    tmpArr [n] = histMin + Math.round ((2 * n) / 20 * (histMax - histMin));
    categoryArray.addItem({data:tmpArr[n]});)
    }

    Add a series to the map with the values x and y
    Since the berries and the whole series type on a column chart
    for (var chartSeries:int = 0; chartSeries < countMax; chartSeries ++)
    {
    var tmpseries:Array = new array (10);
    for (var i: int = 1; i < 10; i ++)
    {
    tmpseries = 3 * Math.Random ();
    }
    CS: ColumnSeries var = new ColumnSeries();
    columnchart1. Series.Join (= [cs];
    sArray.addItem({data:tmpseries});)
    columnchart1. DataProvider = sArray;
    CS = new ColumnSeries();
    cs.dataProvider = sArray;
    cs.displayName = "series."
    cs.yField = "data";
    columnchart1. Series [chartSeries] = cs;
    }
    }
    []] >
    < / mx:Script >
    < mx:Panel title = "Dynamic series adding Sample" width = "195%" height = "90%" layout = "absolute" >
    < mx:ColumnChart id = "columnchart1" height = "338" width = "396" showDataTips = "true" type = "stacked" x = "10" y = "0" >
    < mx:horizontalAxis >
    < mx:CategoryAxis dataProvider = "{categoryArray}" categoryField = "data" / >
    < / mx:horizontalAxis >
    < mx:verticalAxis >
    < mx:LinearAxis baseAtZero = "true" maximum = "3" autoAdjust = "true" / >
    < / mx:verticalAxis >
    < / mx:ColumnChart >
    < / mx:Panel >
    < / mx:Application >



    http://www.Adobe.com/2006/mxml"creationComplete =" drawChart () "layout ="absolute">"

    Import mx.graphics.SolidColor;
    Import mx.charts.HitData;
    Import mx.controls.Alert;
    Import mx.charts.series.ColumnSeries;
    Import mx.charts.series.LineSeries;
    Import mx.collections.ArrayCollection;

    [Bindable]
    public var categoryArray:ArrayCollection = new ArrayCollection();

    public function drawChart (): void
    {
    var histMax:int = 25;
    var histMin:int = 5;
    var countMax:int = 3;
    var tmpArr:Array = new Array();
    categoryArray.removeAll ();
    for (var n: int = 0; n< 10;="">
    {
    tmpArr [n] = histMin + Math.round ((2 * n) / 20 * (histMax - histMin));
    categoryArray.addItem({data:tmpArr[n]});)
    }

    CS: ColumnSeries var = new ColumnSeries();
    columnchart1. Series = [cs];
    Add a series to the map with the values x and y
    Since the berries and the whole series type on a column chart
    for (var chartSeries:int = 0; chartSeries< countmax;="">
    {
    var tmpseries:Array = new array (10);
    for (var i: int = 0; i< 10;="">
    {
    tmpseries = 1 * Math.Random ();
    If (tmpseries
    > 0.5)
    {
    tmpseries = 1;
    }
    on the other
    {
    tmpseries
    = 0;
    }
    }

    var testArrCol:ArrayCollection = new ArrayCollection();
    for (var j: int = 0; j< 10;="">
    {
    var m:Number = tmpArr [j];
    var m1:Number = tmpseries [j];
    testArrCol.addItem({mData:m.toString(),nData:m1.toString()});)
    }
    CS = new ColumnSeries();
    cs.dataProvider = testArrCol;
    cs.displayName = 'Series' + chartSeries.
    cs.xField = 'Montana ';
    cs.yField = 'nData ';
    columnchart1. Series [chartSeries] = cs;
    }
    }

    public void myTipFunction(hitData:HitData):String
    {
    return (p:System.NET.mail.MailAddress.DisplayName ColumnSeries (hitData.element) +"-" + hitData.item.mData + "\n" + "value:"+ hitData.item.nData "');
    }
    ]]>











  • [Solved] GL: Opening and closing periods does not display the LOV book

    Hello

    I created a new book and associated with the profile option ' GL: Data Access set 'and' GL: name of the book ' at the level of responsibility.

    1.JPG

    I created a new responsibility to access my book.

    2.JPG

    When I tried to open a period for the first time since the new responsibility, I'm not able to see all the values in the LOV Leder.

    3.JPG

    Am I missing any installation?

    Thank you

    Saida

    Hello

    Try running the following question with your access_set_id in parameter:

    SELECT DISTINCT lgr.name, lgr.ledger_id, acc.access_privilege_code, lgr.latest_opened_period_name, lgr.first_ledger_period_name, lgr.short_name, lgr.chart_of_accounts_id

    OF acc, gl_ledgers lgr gl_access_set_ledgers

    WHERE acc.access_set_id =: PARAMETER.access_set_id

    AND lgr.ledger_id = acc.ledger_id

    AND lgr.object_type_code = 'L '.

    ORDER BY lgr.name

    If this script returns no rows check your request competitor status "General Scriptures accounting installation program". It seems that gl_access_set_ledgers materialized view was not refreshed successfully. Submit the program accounting General Ledger Setup again and check that the program has completed successfully.

    Kind regards

    Dmitry

  • Error 1074395241: The model descriptor does not contain the data required for the corresponding rotation invariant.

    Hi all

    I use the model Match 4 IMAQ to detect the angle of rotation of an image of model. However, it displays the error: "error 1074395241: the model descriptor does not contain the data required for the corresponding rotation invariant." What exactly is the problem? How to solve this problem? The details are explained below.

    My project is a bit complicated. Part of the block diagram containing the IMAQ Match model 4 is illustrated below:

    The source image is a series of images of images read from an AVI video (I used a loop for to process the images frame by frame). The image of the model is an area of the first selected image. So, this means, the user selected the ineterst object in the first frame of the video, and each of the following images to find the object corresponding interest & determine its rotation angle. When I run the above diagram, there no error. However, it shows the angle of rotation zero no matter what it is 'really '. Therefore, I changed the schema by adding parameters, listed below:

    But in this case, when I run it, it shows the error I mentioned in the subject line.

    If you need more information about my project to identify the problem, please let me know.

    Thanks in advance.

    S ' Please example from model that comes with labview First
    Go to labview Help > find examples and you can search for example.
    -You create model with angle range and what kind of special criteria you want to use.
    -To do this you must use IMAQ learn pattern before using IMAQ model Match 4
    Reference:http://zone.ni.com/reference/en-XX/help/370281U-01/imaqvision/imaq_match_pattern_4/

  • LG C500-G. AEE5GE1 with Windows 7 home prem OA MEA have been formatted. But despite giving the product key and Windows registry does not recognize the activation. Help, please

    LG C500-G. AEE5GE1 with Windows 7 home prem OA MEA have been formatted. But despite giving the product key and Windows registry does not recognize the activation. Help, please

    Name of the operating system Microsoft Windows 7 Home Premium

    Version 6.1.7601 Service Pack 1 Build 7601

    Manufacturer of operating system Microsoft Corporation

    System name HANDSOME-PC

    System manufacturer LG Electronics

    System model C500.-g. AEE5GE1

    System Type X 86-based PC

    Processor Intel (r) Core i3 CPU M 390 @ 2.67 GHz, 2666 Mhz, 2 Lossnay, 4 logical processors

    H46YSF00 Version/Date of BIOS American Megatrends Inc., July 2, 10

    Product key:

    X 16-96084

    CONCERNING

    TUESDAY BIOJY

    Have you tried to restart by phone?

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • my iphone 5 s has been disabled. I'm trying to restore my iphone with itunes and itunes asks me to put the password for my iphone. but my iphone does not display the unlock screen. What should I do now?

    my iphone 5 s has been disabled. I'm trying to restore my iphone with itunes and itunes asks me to put the password for my iphone. but my iphone does not display the unlock screen. What should I do now?

    Hello

    Follow the instructions here:

    If you have forgotten the password for your iPhone, iPad or iPod touch, or your device is disabled - Apple supports

  • After installation or upgrade to Firefox 31, starting Firefox does not display the home page, personalize displays a blank page and the radio button does not work

    I am the admin of Windows for a University Department and install PC with Firefox all the time. This problem does not occur with every PC I would maintain, only a selection bit (model different laptops with Windows and update 1 8.1.) Until today, it has happened with the new user (with admin rights) accounts that I place on laptops for our staff. Today, this happened with the account administrator while setting up a new laptop. In all cases so far, I have install Windows from a registered image that was created by using sysprep.

    I tried many suggestions to reset Firefox, removing the profile of Firefox users, removing the Windows profile users, uninstalling/reinstalling Firefox, uninstall/reinstall of Firefox and the latest Java, but nothing helped. After uninstalling, I run an application to delete the caches and temporary files and even remove manually the keys to register HKLM\SOFTWARE\Mozilla and HKCU\SOFTWARE\Mozilla. I restart and make sure that the installation folder is deleted after uninstalling.

    Results are the same: after installing Firefox 31, the initial settings for migration, IE or Chrome pop up and after having clicked on the button finish, Firefox starts but does not display the home page of the new user, only a blank page. By clicking on the Options (3 bars) button does nothing. Right click in the appropriate box, the shortcut menu appears, so I can choose to customize, but which opens another tab with subject: Customize the URL and the page is blank. In the right click context menu, I can activate the menu bar and get options from that.

    My last attempt helped a little. I uninstalled Firefox 31, cleaned, removed the profile user Firefox, rebooted and then installed Firefox 30. Initial start-up runs and tells me that I'm not up-to-date and the works of button Options. But I can't always customize.

    Then I upgraded to Firefox 31, but then it's back to no start page, no options button and no customization. I can go down to 30 and get customize practically works again.

    Addon only is for McAfee Scriptscan to Firefox 15.1.0, just after installation is disabled.

    Any help would be appreciated. Thank you.

    You can try a different theme of Windows?

    Have you tried to start the computer using Windows safe?

    Start the computer in Mode safe mode with network support Windows (on the startup screen, press F8) as a test.

  • ADF table selected displayRow does not display the selected line

    Hello

    JDev 11.1.2.4

    I have a table with selection enabled and displayRow property the value selected. In the workflow, I have an ExecuteWithParams activity, and then a method activity that restores the current iterator of the line. Finally the activity view that displays the table.

    Restore the current line with key

    Iterator DCIteratorBinding = ADFUtils.findIterator ("MyIterator");

    iterator.setCurrentRowWithKey (currentKey); currentKey is a string

    The question I have is that the current line is properly restored, but the table does not display the page of "range" of the current line while the displayRow is the selected value. My table has 500 rows, the table displays the top 25 while the current line is the 500th line. I expect the table to display the line 475 to 500 line.

    What I am doing wrong?

    Thank you

    You can save the index lines before executing your method and then set the iterator to this index.

    The technique is described in this blog https://tompeez.wordpress.com/2016/02/12/naviagting-an-aftable-in-pagination-mode-from-a-bean/

    Timo

  • my pc does not display the sound icon and I have no sound of my speakesrs are pluged

    sound works when last used. PC does not display the icon of audio and have no sound

    Hello jeffreysarver,

    Thanks for choosing Windows and thank you for providing an opportunity to help you.

    According to the description, it seems that you are having problems with the sound. As I understand well you can't listen to audio.

    I need to ask you some questions to help you better.

    1. were there any changes (hardware or software) to the computer before the show?

    2. the problem when you play system sounds?

    Perform the steps suggested by Sebastian M from the link below and check.

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-pictures/no-sound-in-my-Windows-XP-computer/b2ad45d8-3242-4837-A728-b233ffd3f73c

    Answer to us if you are having problems with the sound or any other problem of Windows, and I'd be happy to help you.

    Good day!

    Hope this information helps.

  • The Task Manager does not display the process and tabs, even if the menu can be seen.

    Dear community, I had a serious problem on my task manager. It does not display the process and tabs, although the menu is visible. Also, any time I open a program or system of adjustment, some and especially no option can be seen since there is no specified words.

    Here is a link that you can see a screenshot on my problem.

    http://kepfeltoltes.Hu/121231/592911021Untitled_www.kepfeltoltes.hu_.PNG

    Thanks in advance for your help

    Original title: Task Manager problem

    I managed to solve the problem by looking for alternatives. Apparently, the problem was caused by a dat file (C:\windows\system32 folder called FNTCACHE.) (DAT) I deleted and it worked like a magic. Everything was normal again.
    Deleted it and the work of all the graphical interfaces as it should.

    Thanks for your answer, in any case. I just post the solution here if someone ever faced with such a question in the future.

    Kind regards
    Laszlo

  • Account Internet preferences system does not recognize the password for my AOL account... and so mail does not read the email in my AOL account

    Account preferences Internet system does not recognize the password for my AOL (Internet) account... and so Mail does not read the email in my AOL account

    Mail asking me to "Enter your password for [my AOL account] in Internet accounts."

    When I enter my password Internet accounts says it is "Impossible to verify the account name or password."

    iMac (24 inch, early 2009)

    Processor clocked at 2.66 GHz Intel Core 2 Duo

    Memory 8 GB 1067 MHz DDR3

    OS X 10.11.1 (B 15, 42) El Capitan

    Remove the password in Keychain Access (Applications/Utilities). While there, menu Keychain Access of relief.

    The problems of Keychain - see post of khati

  • a pc that is sharing the printer and another pc does not accept the same network printer on xp pro sp3

    a pc that is sharing the printer and another pc does not accept the same network printer on xp pro sp3
    What is the solution?

    Check out these links

    http://TechNet.Microsoft.com/en-us/library/bb457001.aspx

    http://UIs.Georgetown.edu/software/documentation/WinXP/WinXP.network.printer.html

  • Search programs and files does not work: when I try to look for things in windows 7 slot search files and program it does not display anything

    When I try to look for things in windows 7 slot search files and program it does not display anything

    Help

    Hi girls NMS.

    Try to run the next Fixit:

    Fix Windows Search when it crashes or shows no results

  • I use a database program in a number of previous versions of windows and windows 7 does not allow the program to launch denial of service.

    Application of program compatibility does not start

    I use a database program in a number of previous versions of windows and windows 7 does not allow the program to launch denial of service.  What gives?

    If you have Windows 7 64 bit without BACK program can run because there is no 16-bit subsystem to run it.

    Try dosbox http://www.dosbox.com/. If that won't work your program, you'll need either a new database or run the BACK or on a 32-bit version of Windows in a virtual machine like VirtualBox https://www.virtualbox.org/.

Maybe you are looking for