Jump to content

java jtable


samona

Recommended Posts

thank you for the response.  below is my cell renderer.  I can only make the size of the data but not the actual table which what I want.

 

public class MyTableCellRenderer extends javax.swing.JLabel implements
        javax.swing.table.TableCellRenderer {
    
    
  
  
    
    public java.awt.Component getTableCellRendererComponent(
            javax.swing.JTable table, java.lang.Object value,
            boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) {
        
        setText(value.toString());
        
        if (value.equals(null)) {
            
            return this;
        }
            javax.swing.JLabel label = new javax.swing.JLabel(value.toString());
            //label.setFont(new java.awt.Font("Helvetica Bold", java.awt.Font.PLAIN,7));
            label.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
            label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
           // System.out.println("IN RENDER");
     
        return label;
        
        
    }
    
    public void validate() {}
    public void revalidate() {}
    protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
    public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
    

Link to comment
https://forums.phpfreaks.com/topic/257995-java-jtable/#findComment-1322451
Share on other sites

Instead of statically calling these packages just import them at the top.

 

I can only make the size of the data but not the actual table which what I want.

That's a bit ambiguous, what part of the table do you want to increase the size to?  Padding, height, width, overall table size, what?

Have you looked at the documentation? - http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/JTable.html

 

Link to comment
https://forums.phpfreaks.com/topic/257995-java-jtable/#findComment-1322455
Share on other sites

I want to change the actual table width and height to be smaller for printing purposes.  I want the table as a whole to be smaller.  Right now for printing I have  FIT_WIDTH which span across the whole page, but I want the table width to span only across half the page. 

 

I looked at the link before, but nothing jumps at me as to adjusting overall table size for printing.

Link to comment
https://forums.phpfreaks.com/topic/257995-java-jtable/#findComment-1322456
Share on other sites

I want to change the actual table width and height to be smaller for printing purposes.  I want the table as a whole to be smaller.  Right now for printing I have  FIT_WIDTH which span across the whole page, but I want the table width to span only across half the page. 

 

I looked at the link before, but nothing jumps at me as to adjusting overall table size for printing.

I guess you could grab the screen size and just divide by 2 when you set the table size.  Try:

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        table.setSize(screenSize.width / 2, screenSize.height / 2);

Link to comment
https://forums.phpfreaks.com/topic/257995-java-jtable/#findComment-1322463
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.