2012-01-31 3 views
0

학교용 프로그램을 만들고 있습니다.JTextfield에서 JTextfield의 데이터를 2 JFrames로 표시

내 프로그램은이 두 JFrame의의 첫 번째 JFrame의 = Basisscherm 내가 MySQL 데이터베이스에서 데이터로 채워 JTable의를 가지고 한 JFrame의의 basisscherm에 두 번째 JFrame의 = Toetsenbord

.

의 에디터

을 지금이 라벨은 특정 텍스트입니다있는 레이블을 보여주는이 표는 각각의 라벨은 내가 이름으로 JTextField로있어 toetsenbord이이 JFrame의에

이제 동일한 데이터베이스에 자신의 텍스트를 가지고 있으며, 내 문제는 내가 jtext에서 레이블을 선택하고 확인 버튼을 클릭하여 jtextfield에 텍스트를 표시하고 싶습니다하지만 지금 어디서부터 시작해야합니까?

+2

1) [tag : 숙제] 태그를 숙제 질문에 추가하는 것을 잊지 마십시오. 2) 질문이 있으십니까? 3) 일반적인 Java 명명법을 사용하십시오. 4) 더 빨리 도움을 받으려면 현재 코드의 [SSCCE] (http://sscce.org/)를 게시하십시오. –

+0

나는 아직 어떤 코드도 가지고 있지 않다. 어떤 방법으로 시작해야 하는지를 알고 싶다. 예제를 사용할 필요가있다. – user1138629

+0

오라클 튜토리얼을 확인하면 배울 것이 좋다! -> http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#selection. 결코 혼자서 시도하지 않으면 혼자서는 할 수 없을 것입니다 ... 귀하의 질문은 기본적으로 자기 투자로 문제를 해결할 것입니다! –

답변

0

이것 좀보세요. JTable에서 선택한 텍스트를 가져올 수있는 사용 방법.

JTable table = new JTable(); 

if (table.getColumnSelectionAllowed() 
     && !table.getRowSelectionAllowed()) { 
    // Column selection is enabled 
    // Get the indices of the selected columns 
    int[] vColIndices = table.getSelectedColumns(); 
} else if (!table.getColumnSelectionAllowed() 
     && table.getRowSelectionAllowed()) { 
    // Row selection is enabled 
    // Get the indices of the selected rows 
    int[] rowIndices = table.getSelectedRows(); 
} else if (table.getCellSelectionEnabled()) { 
    // Individual cell selection is enabled 

    // In SINGLE_SELECTION mode, the selected cell can be retrieved using 
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
    int rowIndex = table.getSelectedRow(); 
    int colIndex = table.getSelectedColumn(); 

    // In the other modes, the set of selected cells can be retrieved using 
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); 
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 

    // Get the min and max ranges of selected cells 
    int rowIndexStart = table.getSelectedRow(); 
    int rowIndexEnd = table.getSelectionModel().getMaxSelectionIndex(); 
    int colIndexStart = table.getSelectedColumn(); 
    int colIndexEnd = table.getColumnModel().getSelectionModel() 
     .getMaxSelectionIndex(); 

    // Check each cell in the range 
    for (int r=rowIndexStart; r<=rowIndexEnd; r++) { 
     for (int c=colIndexStart; c<=colIndexEnd; c++) { 
      if (table.isCellSelected(r, c)) { 
       // cell is selected 
      } 
     } 
    } 
} 
관련 문제