2011-08-18 3 views
1

스윙에서 JDialog를 다시 그리는 방법? JDialog의 변환 버튼을 클릭하면 JDialog의 GUI 디자인을 변경해야하지만 실제로 발생하지는 않습니까? 그들의 모든 해결책이 있습니까?스윙에서 JDialog를 다시 그리는 방법?

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

예약 유형 ID는 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); 
} 

이드를 사용하여 initcomponents 메소드에서 구성 요소를 변경하고 있습니다.

+0

@Jonas 만약 OP를 게시 [SSCCE] (http://pscode.org/sscce.html), 관련 코드가 있음을 보증합니다. 그러나 문제가 해결 될 때까지 대부분의 사람들은 관련 코드가 무엇인지 모릅니다. * –

답변

2

현재 구성 요소 나 구성 요소의 창을 가져올 수 있으며 repaint()으로 전화를 걸 수 있습니다.

SwingUtilities.getWindowAncestor(this).repaint(); 
+0

메신저는 페인트 칠을 사용하지만 작동하지 않습니다. – Ganesh

3

대신

legdetailsTable = new JTable(mytablemodel); 

의 당신은 JTable가 있지만, 새로운 레이아웃에 추가되지 않습니다 다시

legdetailsTable.setModel(mytablemodel); 

추가

관련 문제