JTable multi line header behaves strangely

Hello,
I'm trying to use html-tags in my JTable headers. For some reasons only the first column-name has any effect on the header height. If the other columns have more lines than the first column, they are cut off.
Is there a solution to this problem?

I extended the JTable and overrode the addColumn method:
   @Override
   public void addColumn(TableColumn column) {
      super.addColumn(column);
      if (column!= null && getTableHeader() != null
            && getTableHeader().getDefaultRenderer() != null) {
         column.setHeaderRenderer(getTableHeader().getDefaultRenderer());
   }That seemed to work well, but perhaps there are more elegant solutions?

Similar Messages

  • Print JTable with multi line header

    I need to print a JTable with multi line header, I want to know if I can use the method jTable.print(int, MessajeFormat, MessageFormat) by manipulation of the MessageFormat. How I can manipulate it?
    Otherwise, How I can print this?

    hi again,
    To print pdf in a swing application you don't need servlet.jar.
    You'll only need itext.jar and a printer connected to your pc.
    Download the iText source code and unzip it. See the following classes:
    com.lowagie.tools.LPR and com.lowagie.tools.BuildTutorial. This latter is the main class of a swing tool that you can run.
    Silent Print:
    You have only to embed this javascript code in your pdf:
    writer.addJavaScript("this.print(false);", false);
                        document.add(new Chunk("Silent Auto Print"));Then, you have to send the document to the printer.
    Google : java print pdf
    http://forum.java.sun.com/thread.jspa?threadID=523898 or
    http://www.exampledepot.com/egs/javax.print/pkg.html for printing task.
    Under unix system, I used this:
                           String PRINTER = ...;
                   try {
                        String cmd = "lp -d " + PRINTER + " " + PDF_PATH;
                        Runtime.getRuntime().exec(new String[] { "sh", "-c", cmd });
                   } catch (Exception e) {
                                 //handle the exception
                                 e.printStackTrace();
                   }hth

  • How do I make a multi-line heading show up as a single line in the Table of Contents?

    I'm writing a document where the headings often have a line break in them for the sake of formatting. When I generate a Table of Contents, they show up as two entries on the same page instead of as a single heading.
    For example, if I have a section like:
    Oh My God
    You're Totally Not Going to Read This Section
    Section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, section text, etc.
    Then in the table of centents it shows up as something like:
    The Section Before That Section You're Not Going to Read ... 14
    Oh My God .................................................. 17
    You're Totally Not Going to Read This Section .............. 17
    The Section After That Section You're Not Going to Read .... 20
    When what I really want is a Table of Contents like this:
    The Section Before That Section You're Not Going to Read ... 14
    Oh My God You're Totally Not Going to Read This Section .... 17
    The Section After That Section You're Not Going to Read .... 20
    (Actually, I have a bunch of sections with titles like this all in a row, so it looks much worse than in the example.)
    How do I do this: Get the Table of Contents to ignore the carriage return in the middle of the section header?

    Try a Soft return, Shift + Return, instead of Paragraph break.

  • Multi-line JTable headers?

    Is there any way for a JTable column header to have 2 or more lines of text? I want narrow columns with fairly lengthy text descriptions.
    The only thing I could think of was to override AbstractTableModel.getColumnName to send String values with embedded "\n" or html "<br/>" constructs. Neither method works.

    I'm sorry, my earlier statement was not precise enough.
    The technique you show does produce multi-line header text; however the height of the header is unchanged, so only the center line is visible (or the bottom of line 1 and the top of line 2, if two lines are written).
    Do you know if the height of the header row can be changed?

  • Print Jtable with multiline header?

    i want to print jtable with multi-lines header and footer
    using the print function that takes MessageFormat as header and footer
    i used MessageFormat header = new MessageFormat("hello\r\nworld");and i used '\n' only
    but it was printed all in the same line
    thnx in advance

    You can try something on the below lines. Set your custom renderer for the tableheader.
    public class MultiLineHeaderRenderer extends DefaultTableCellRenderer{
            public Component getTableCellRendererComponent(JTable table, Object value,
                             boolean isSelected, boolean hasFocus, int row, int column) {
                         JLabel label = (JLabel) super.getTableCellRendererComponent( table,  value,
                              isSelected,  hasFocus,  row,  column);
                        label.setText("<html>a<br>b</html>");
                        return label;
        }Not the best way to do it. And might need to some modifications too to set the font position etc.

  • How to print jTable with custom header and footer....

    Hello all,
    I'm trying to print a jTable with custom header and footer.But
    jTable1.print(PrintMode,headerFormat,footerFormat,showPrintDialog,attr,interactive)
    does not allow multi line header and footer. I read in a chat that we can make custom header and footer and wrap the printable with that of the jTable. How can we do that..
    Here's the instruction on the chat...
    Shannon Hickey: While the default Header and Footer support in the JTable printing won't do exactly what you're looking for, there is a straight-forward approach. You can turn off the default header/footer and then wrap JTable's printable inside another Printable. This wrapper printable would then render your custom data, and then adjust the size given to the wrapped printable
    But how can i wrap the jTable's Printable with the custom header and footer.
    Thanks in advance,

    I also once hoped for an easy way to modify a table's header and footer, but found no way.
    Yet it is possible.

  • How to display multi line headings in procedural alv report

    Hi experts,
    How to display multi line heading in alv( procedural alv report) report.
    some columns single line and some columns multi line in the same report.
    ex: 
                  solvent consumed          solvent recovered
                   fresh |   recovery             recovery | spent                            batch no                         storage
    I am using procedural alv .pls give me idea.

    Hi Ram,
    Check the sample report [how to display multi line headings in procedural alv report|http://sample-code-abap.blogspot.com/2008/01/printing-multiple-line-header-and.html]
    Thanks,
    Duy

  • Multi line column JTable

    Hi,
    I am working on JTable and I am using DefaultTableModel.
    I have a requirement that in one of the cells I need to show a multi line text which may contain 10 to 50 lines of text.I need to show all the text even on resizing the table.
    Can anyone give me suggessions regarding this.
    Thanks,
    Bussa.

    Hi,
    Write your custom JTableCellEditor and Renderer to install a JTextArea on the cell you want.
    You can set the size of the larger row separately via
    JTable.setRowHeight(int row, int value); To display the full text you should set
    JTextArea.setLineWrap(true);
    JTextArea.setWrapStyleWord(true);and set the width of the JTextArea static.
    after this calculate the height of the JTextArea and set it to the table.
    Olek

  • Colum header multi line

    hello ,
    i use BI publisher 11.1.1.5 and the embedded builder .
    I create a data table with several columns
    i look for a way to put the text of a column header in multi lines.
    best regards
    jean marc

    hi
    what is u r question

  • Multi line custom field badly saved to database

    Hello community,
    we're fighting currently against a strange issue.
    All projects has some multi line custom fields to fill every week for project status.
    During this exercise, some of the comments seems not well saved to database.
    While coming back to the PDP, we are seeing a strange behavior :
    Starting from that, I tried to look in the database and the saved html format is badly formatted, you can see a </div> in the middle and a missing one at the end of the sentence:
    <div>Révision et approbation de l&#39;ODS de Facilité.</div> <div>&#160;</div></div> <div>Compléter&#160;le questionnaire à soumettre aux experts.</div>
    <div>&#160;</div> <div>Présentation et choix des experts.
    As of now, we did not find any reason why this is happening.
    While opening back the PDP in edition and saving back ,the problem is solved.
    This is annoying because we are treating the html code as xml for reporting as seen here (http://aboutmsproject.com/converting-rtf-to-text-in-sql-revisited/
    ) and this is crashing because of badly formatted html code
    any advices?
    regards
    Jérome

    Hi Jerome,
    I've seen this issue occur when text is pasted into the field from other applications, like Outlook and Word. I've not yet been able to determine how to get it to stop. The error then causes the invalid XML issue you are seeing. A former co-worker had successfully
    integrated the use of jQuery into PDPs. I'm wondering if they have a HTML clean function.
    Thanks for finding my post useful!
    Treb Gatte, Project MVP, Tumble Road LLC |
    @tgatte | http://AboutMSProject.com

  • Why is my MacBook display behaving strangely?

    I am using an alumin(i)um MacBook (13", late 2008 model with multi-function glass trackpad). In the past couple of weeks, the display has started to behave strangely. The screen seems to freeze (meaning any mouse movements or keystrokes do not display), and then the screen begins to fade to grey. It seems to be resolved by tilting the display until the MacBook "wakes". There has also been some occasional flickering of the display, although far less frequent. Could someone help me with this? Is it something like a loose connection, and, if so, how should I deal with it? (The MacBook is now out of warranty, so my next step would be my local Apple store). Thanks in advance!

    Same thing happening to me - began about four weeks ago, two weeks after warranty expired. Has gotten to the point where it's difficult to use the computer - don't get through composing an e-mail before it starts to fade - now know that even though computer display is frozen, the keystrokes are still getting through, so be careful what keys you press trying to get it to pay attention!
    I believe it's going to turn out to be a connection problem between the computer and the display in the hinge area. I found out yesterday that as it freezes, and I start to pick it up off my lap and put it aside, if I pick it up with my left hand near the lower left of the keyboard and my right hand behind the display, down low near then hinge, and pulling slightly towards me, this fixes it (for a while), and this is (for me) the most reliable way to wake it back up. I've seen references elsewhere to this being a simple problem where a connection is maintained with a black foam pad to provide pressure to the connection. I think the foam must degrade or lose resiliency (apparently at 12.5 months from purchase!) and there may be a simple solution available. When I figure it out for this particular model, I'll post my conclusions.

  • How to make multi-line report headings?

    Hi all,
    By default, Apex creates a single-line report heading for each column in a report.  To minimize white space, multi-line column headings are sometimes appropriate.  How can Apex be directed to split a column heading at certain place(s)?
    Thanks,
    Kim
    P.S. I'm running Apex 4.2.2. 

    See https://forums.oracle.com/message/11154533

  • Multi line HTML data formatting on SSRS reprot

    Hi
    I am  using SQL Server Reporting Services 2008 , data fetching by Project server database,data value is getting by multi line rich text field.
    when showing same data in HTML format
    on ssrs reports its shows every style what ever user copy and paste on particular field like font size ,colors and them.
    I have requirement to show unique font size and unique family font,I am unable to achieve this using lot of placeholder properties.
    below u can find the example
    Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Sharepoint and EPM Consultant,TCS
    |
    | Twitter

    Hi Hasan,
    According to your description that the some of the report data retrieved by multi line rich text field, which style show differently in the report, you have tried to create the placeholder using the HTML tag to format the data
    but failed to achieve, right?
    The issue due to the rich text formatting is not supported in SSRS 2008, Currently, you have mentioned that you tried to using the HTML tag to reformat the text but failed, that may due to Reporting Services support limit HTML tags when defined as placeholder
    text. Please see:
    • Hyperlinks: <A href>
    • Fonts: <FONT>
    • Header, style and block elements: <H{n}>, <DIV>, <SPAN>,<P>, <DIV>, <LI>, <HN>
    • Text format: <B>, <I>, <U>, <S>
    • List handling: <OL>, <UL>, <LI>
    In your scenario, I recommend you to take reference of method below to get the unique format text.
    Check the supported HTML tag and using the correct tag to format
    If you want to get the RTF format:
    If using Report Viewer Windows control, we can render the RTF file into IMG file, and then display the image on the report.
    Nayan Patel written good artilce about this:
    http://binaryworld.net/Main/CodeDetail.aspx?CodeId=4049
    This article give us the idea to convert RTF to image and then display on the report.
    You can also convert the RTF text to the plain text which by default in the report:
    Article have details method about the convert for your reference:
    http://stackoverflow.com/questions/2987501/rtf-to-text-in-sql-server
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0f70e01f-6315-400c-bc75-c7da5f324062/displaying-rtf-text-in-a-ssrs-2008-report?forum=sqlreportingservices
    Similar threads for your reference:
    RTF in SSRS - SQL 2008 R2
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0f70e01f-6315-400c-bc75-c7da5f324062/displaying-rtf-text-in-a-ssrs-2008-report?forum=sqlreportingservices
    Personally, I recommend you that submit this suggestion at 
    https://connect.microsoft.com/SQLServer/. If the suggestion mentioned by customers for many times, the product team may consider to add the feature in the next release of SQL Server. Your feedback is valuable for us to improve our products and increase
    the level of service provided.
    Thanks for your understanding.
    Regards
    Vicky Liu

  • Multi-line Labels in Swing 1.1?

    Hi
    Is it possible to get multi-line labels
    (using any type of component) prior
    to 1.1.1?
    Marc

    I think you should create a custom table cell renderer. As I am a lazy one I'd subclass a default renderer as follows (I have not tried it, it's just a clue):
    public class MultilineTableCellRenderer extends DefaultTableCellRenderer
         private JTextArea renderer;
         public MultilineTableCellRenderer()
              renderer = new JTextArea();
              renderer.setEnabled(false);
              // You should find out another color constant if you are using
              // Java L&F, this works with the Windows L&F.
              renderer.setDisabledTextColor(UIManager.getColor("control"));
         public Component getTableCellRendererComponent(JTable table,
              Object value, boolean isSelected, boolean cellHasFocus, int row,
              int column)
              JComponent compo = (JComponent) super.getTableCellRendererComponent(
                   table, value, isSelected, cellHasFocus, row, column);
              renderer.setBackground(compo.getBackground());
              renderer.setForeground(compo.getForeground());
              renderer.setDisabledTextColor(compo.getForeground());
              renderer.setBorder(compo.getBorder());
              // Might need something like that.
              /* renderer.setText(value.toString() ???); */
              return renderer;
    }You might want to stub out methods like repaint, validate for better performance in a JTextArea subclass...
    Kurta

  • Chebychev Polynomial fitting results show multi lines

    I am using "nonliear curve fit.vi" with defined Chebychev Polynomial  function to fit XY data.  Strangely, if I enlarge the upturn part, I clearly see the fitting results show multi-lines (2-4) . Please the the attached snapshot.
    weitong
    LV2013
    Attachments:
    chebychev Ploynomial fit.PNG ‏48 KB
    chebychev Ploynomial fit-whole.PNG ‏19 KB

    Thanks.
     I found the reason: the data X values are not mononicaly, i. e.  there are local oscillations at some region.
    After sorting the raw data, the fitting results show single line. 
    Is the sorting of X values necessary before Chebychev Polynomial fitting?

Maybe you are looking for