Bài giảng Lập trình cơ sở dữ liệu Java - Bài 3: Components. Chương này cung cấp cho người học các nội dung: JTable, JButton, JMenu, JTextField, JToolBar, JCheckBox, JOptionPane, JRadioButton, JFileChooser, JPanelJComboBox, JList. 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 JLabel JTable JButton JMenu JTextField JToolBar JCheckBox JOptionPane JRadioButton JFileChooser JPanel JComboBox, JList 2 GUI Components JButton, JLabel, JTextField, JCheckBox, JRadioButton, and JComboBox. Each GUI component class provides several constructors that you can use to create GUI component objects. 3 GUI Components // Create a button with text OK JButton btOK = new JButton("OK"); // Create a label with text "Enter your name: " JLabel lbName = new JLabel("Enter your name: "); // Create a text field with text "Type Name Here" JTextField txtName = new JTextField("Type Name Here"); // Create a check box with text bold JCheckBox chkBold = new JCheckBox("Bold"); // Create a radio button with text red JRadioButton rbRed = new JRadioButton("Red"); // Create a combo box with choices red, green, blue JComboBox cboColor = new JComboBox(new String[]{"Red", "Green", "Blue"}); 4 Working with Components Several methods: setEnabled(boolean): receive user input (an argument of true) or is inactive and cannot receive input (false). Components are enabled by default. isEnabled() returns a boolean value. setVisible(boolean): for all components. Use true to display a component and false to hide it. isVisible() setSize(int, int): width and height specified as arguments setSize(Dimension) uses a Dimension getSize(): returns a Dimension object with height and width 5 Working with Components setText() getText() setValue() and getValue() for components that store a numeric value. 6 JLabel Display Text, not editable Constructor: Label() : An empty label JLabel(String) : A label with the .