1

How to make repaint for JDialog in Swing? If I click on convert button in JDialog I need to change GUI design of JDialog but it's not happening? Is their any solution?

    _convertAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            String para = new String(); 
            _task.setBookTypeId(13);
             initComponents();
           //   validate();
           //   repaint();
            setVisible(true);
        }
      };

I'm setting booking type id is 13 .

if(_task.getBookTypeId()== 1){
    String colnames[] = {"Leg","Departure", "Date","Time", "Arrival","Date", "Time","How","Aircraft","PIC","Copilot"};
    MyTableModel mytablemodel = new MyTableModel(colnames);
    legdetailsTable = new JTable(mytablemodel);
    legdetailsTable.setRowSelectionAllowed(true);
}else {
    System.out.println("Brokered booking table");   
    String   colnames[] = {"Leg","Departure", "Date","Time", "Arrival","Date", "Time","How"};
    MyTableModel mytablemodel = new MyTableModel(colnames);
    legdetailsTable = new JTable(mytablemodel);
    legdetailsTable.setRowSelectionAllowed(true);
}

Using Id I'm changing componenents in initcomponents method.

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
Ganesh
  • 169
  • 1
  • 2
  • 10
  • @Jonas If the OP posts an [SSCCE](http://pscode.org/sscce.html), it guarantees that the relevant code is present. But until they solve the problem, most people *don't know what the relevant code is.* – Andrew Thompson Aug 18 '11 at 12:51

2 Answers2

3

Instead of

legdetailsTable = new JTable(mytablemodel);

add

legdetailsTable.setModel(mytablemodel);

You recreate JTable but the new one isn't added to layout

StanislavL
  • 56,971
  • 9
  • 68
  • 98
2

You can get the Window of the current Component or any Component and than call repaint().

SwingUtilities.getWindowAncestor( this ).repaint(); 
oliholz
  • 7,447
  • 2
  • 43
  • 82