1. Trang chủ
  2. » Giáo Dục - Đào Tạo

APJI lab2

2 52 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 581,03 KB

Nội dung

APJ-I – Lab2 - Swing Components and Dialogs box Application Programming I Module 2: Swing components and Dialog Box Lab Guide for Lab2 Session Objectives In this session, you will be practicing with  Container Components  Lightweight Components  Common Methods of Swing Components  JScrollPane, JSlider, Timer, JProgressBar, Advanced Text Components  Dialog boxes Part – Getting started (20 minutes) Create a JFrame: The following code show a JFrame with title: “My title” and contains a JPanel, JPanel contains Jbutton import java.awt.*; import javax.swing.*; public class MainFrame extends JFrame { public MainFrame() { super("My title"); setSize(300,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = getContentPane(); content.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); panel.add(new JButton("OK")); panel.add(new JButton("Cancel")); panel.add(new JButton("Close")); content.add(panel, BorderLayout.SOUTH); } } © 2011 FPT-Aptech Page / APJ-I – Lab2 - Swing Components and Dialogs box Write main() method in MainFrame class to run program public static void main(String[] args){ new MainFrame().setVisible(true); }  Compile class and run this program Add a JtextArea to last line of contructor: content.add(new JTextArea(), BorderLayout.CENTER);  Compile class and run this program Change the last line of the previous class to: content.add(new JScrollPane(new JTextArea()), BorderLayout CENTER);  Compile class and run this program Part – Workshops (30 minutes)   Quickly look at workshops for Module for reviewing basic steps Try to compile, run and observe the output of sample code provided for related workshop Discuss with your class-mate and your instructor if needed Part – Lab Assignment (60 minutes) Do the assignment for Module carefully Discuss with your class-mates and your instructor if needed © 2011 FPT-Aptech Page / ...APJ-I – Lab2 - Swing Components and Dialogs box Write main() method in MainFrame class to run program public

Ngày đăng: 27/10/2019, 22:53

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w