Link to home
Start Free TrialLog in
Avatar of drewmore44
drewmore44

asked on

Java GUI visibility

Please forgive me for already having  a similar post to this up, but this is really driving me crazy and keeping me from doing work I need to do today.

I have created a JInternalFrame, inside of which there is a panel, inside of which there is a   JTable. The panel is appearing (I tested this by setting its background to yellow, which did appear), but the table inside it is not.

Please help!!!!!

package ckout;

import java.awt.Color;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author drew
 */
public class DE extends javax.swing.JInternalFrame {

    /**
     * Creates new form DE
     */
    public DE(Shift shift) {
                   
       Object[][] data = new Object[shift.serversOn.size()][6];
       for (int curr = 0; curr < shift.serversOn.size(); curr++){
           data[curr][0] = shift.serversOn.get(curr).name;
           data[curr][1] = shift.serversOn.get(curr).ccTips;           
           data[curr][2] = shift.serversOn.get(curr).totSales;
           data[curr][3] = shift.serversOn.get(curr).foodSales;
           data[curr][4] = shift.serversOn.get(curr).bevSales;
           data[curr][5] = shift.serversOn.get(curr).covers;     }
        
        String [] colNames = {"name","cc tips", "total sales", "food sales", "bev sales", "covers"};           
        JPanel panel = new JPanel();
        
        DefaultTableModel dtm = new DefaultTableModel(data, colNames);
   
        JTable sv = new JTable(dtm);
        sv.setVisible(true);
        
        panel.add(sv);
        panel.setBackground(Color.yellow);
        panel.setVisible(true);
               
        this.add(panel);
      //  TESTA.super.add(sv);
       this.pack();
       this.setContentPane(panel);
        this.setVisible(true);
        
  
        initComponents();
    }
        

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial