tailieunhanh - Bài giảng Lập trình Cơ sở dữ liệu – Java: Bài 3.2 - Nguyễn Hữu Thể

Bài giảng Lập trình cơ sở dữ liệu Java - Bài 3 tiếp tục cung cấp cho người học các kiến thức về Components. Nội dung chính được trình bày trong chương này gồm có: List JTable, JMenu, JOptionPane, JFileChooser. nội dung chi tiết. | Bài giảng Lập trình Cơ sở dữ liệu – Java: Bài - Nguyễn Hữu Thể LẬP TRÌNH JAVA CSDL BÀI 3 COMPONENTS Nguyễn Hữu Thể 1 Nội dung JList JTable JMenu JOptionPane JFileChooser 2 JList Creating a Model There are three ways to create a list model: •DefaultListModel — everything is pretty much taken care of for you. The examples in this page use DefaultListModel. •AbstractListModel — you manage the data and invoke the "fire" methods. For this approach, you must subclass AbstractListModel and implement the getSize and getElementAt methods inherited from the ListModel interface. •ListModel — you manage everything. JList Initializing a List list = new JList(data); //data has type Object[] ( LECTION); (); (-1); . JScrollPane listScroller = new JScrollPane(list); (new Dimension(250, 80)); JList DefaultListModel Methods: • addElement (Object e) • get (int index) • getSize () • getElementAt (int index) • remove (int index) • Elements() • removeAllElements () 5 JList Methods: – setModel (ListModel model), getModel () – getMaxSelectionIndex (), getMinSelectionIndex () – getSelectedIndex (), getSelectedIndices () – getSelectedValue (), getSelectedValues () Events: – valueChanged 6 JTable 7 JOptionPane 8 JTable DefaultTableModel – addColumn (Object obj) – addRow (Object obj) – getColumnCount () – getRowCount () – getValueAt (int row, int col) – setValueAt (Object obj, int row, int col) 9 JTable Methods: – setModel (TableModel tm) – getModel () – getValueAt (int row, int col) – getRowCount () – getColumnCount () Events: – mouseClicked 10 JTable package project; import ; import ; import ; public class .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.