• Tidak ada hasil yang ditemukan

Pemrograman Berorientasi Objek Lanjut Lecture 01 - Introduction

N/A
N/A
Protected

Academic year: 2021

Membagikan "Pemrograman Berorientasi Objek Lanjut Lecture 01 - Introduction"

Copied!
32
0
0

Teks penuh

(1)

N I K O I B R A H I M , M I T

P R O G R A M S T U D I S I S T E M I N F O R M A S I F A K U L T A S T E K N O L O G I I N F O R M A S I U N I V E R S I T A S K R I S T E N M A R A N A T H A

Pemrograman Berorientasi Objek

Lanjut

(2)

Tujuan Perkuliahan PBO Lanjut

1. Mahasiswa mampu membuat program aplikasi

Java berdasarkan konsep objek oriented.

2. Mahasiwa mampu membuat program aplikasi yang

berhubungan dengan database.

3. Mahasiswa memahami konsep-konsep lanjutan

(3)

Rules

 Pedoman Perkuliahan

 Titip absen  E

 Handphone wajib di-nonaktifkan/silent

 Menggunakan pakaian rapi & bersepatu

 Kewajiban hadir:

 Kehadiran > 15 menit, tidak boleh masuk kelas

 75% kehadiran dosen (<= 25% berarti cekal)

(4)

Pedoman Penilaian

 NA= 30% UTS + 30% UAS + 15% Quiz + 25%

Praktikum  Penghitungan nilai:  A: 80 <= NA <= 100  B+: 73 <= NA < 80  B: 67 <= NA < 73  C+: 61 <= NA < 67  C: 55 <= NA < 61  D: 41 <= NA < 55  E: NA <41

(5)

Materi Keseluruhan

 Java Swing

 Komponen-komponen Swing  Layout Manager

 Event-driven programming

 Generics & Collections  File & Stream processing

(6)

Jadwal Kuliah

Session Lectures

Materials

Session 01 Pengenalan OOP Lanjut & Swing

Session 02 Komponen-komponen Swing Dasar 1

Session 03 Komponen-komponen Swing Dasar 2

Session 04 Layout Manager

Session 05 Event-Driven Programming

Session 06 NetBeans GUI Builder Tutorial

UTS

Session 07 Java Collection Framework

Session 08 Database & JDBC

Session 09 Database & JDBC

Session 10 Database & Java Persistence API (JPA)

Session 11 Database & Java Persistence API (JPA)

Session 12 Presentasi Tugas

(7)

Details of Assessable Work in The Topic

No Details about each form of

assessable work in the topic Amount

Proportion of total mark

Penalties to be applied for plagiarism 1 Programming tasks 10 20% Mark = 0, for all

practical works

2 Quizzes 5 10% Mark = 0, for all

quizzes

3 Assignments 2 10% Mark = 0

4 Mid-semester Exam 1 25% Mark = 0, for all exams 5 Final-semester Exam 1 25% Mark = 0, for all exams

(8)

Reading Materials

1. INTRODUCTION TO JAVA PROGRAMMING, 10th

Ed., Y. Daniel Liang

2. Learning Java, Jonathan Knudsen & Patrick

Niemeyer, O’Reilly, 2005. (Main Reading Materials)

3. Java Swing, Matthew Robinson & Pavel Vorobiev,

Manning, 2005.

4. Java API Documentation, Sun Microsystems 5. NetBeans Tutorials and Documentations

(9)

Softwares and Tools

 JDK 1.7 + Java API Documentation

 Editors:

 JGrasp (Simple Java editor, free download)  NetBeans 7 (Java IDE, free download)

(10)

Got Any Problems?

 Ask directly after the class! (preferable)

(11)

Review: HelloMe.java

0: // Exercise 1: HelloMe.java

1: // NIK: 730015, NAMA: Niko Ibrahim 2: public class HelloMe {

3: public static void main (String args[ ]) {

4: System.out.println("Hello World, Niko!");

5: }

6: }

Line 0: Komentar program, judul program, keterangan penting. Line 1: Selalu tuliskan identitas penulis program.

Line 2: - Nama kelas. Setiap program Java minimal memiliki 1 deklarasi kelas. - Kelas diawali huruf kapital untuk setiap kata.

- Untuk men-save public class ke file, harus diberi nama sesuai dengan nama kelas

tsb dan diakhiri dengan ekstensi .java. Tentang public akan dibahas nanti.

Line 3: main method  the starting point of every Java application

(12)

Review OOP

public class SegiEmpat extends Shape{

private int tinggi;

private int lebar;

public SegiEmpat(int h, int w){ this.tinggi = h;

this.lebar = w; }

public int luas (){ return h*w;

}

public static void main (String args[ ]) { SegiEmpat s = new SegiEmpat(3,4);

System.out.println("Luas: " + s.luas()); } } Property -->private Constructor -->public, no returned value Method --> public

Belongs to the object/instance

Static Method Belongs to the class

Interitance: copying property/method of

(13)

J A V A A W T V S J A V A S W I N G

K O M P O N E N - K O M P O N E N D A S A R S W I N G L A T I H A N

(14)

3 hal penting dalam pemrograman GUI

1. Elemen-elemen (components) apa yang bisa

ditampilkan di layar?

2. Bagaimana cara kira menyusun dan

menempatkan elemen-elemen tersebut?

3. Bagaimana kita berinteraksi dengan

(15)

No 1. Components

 Parts of GUI: buttons, menus, checkboxes, sliders,

text fields, labels, and so on.

 API provides numerous implementations

 We can create own custom components

frame button radio button checkbox label

(16)

No 2. Layouts

 Susunan komponen di layar:

 Absolute: x, y coordinates specified for each component (rarely used)

 Relative with respect to other component positions/sizes, screen resolution,

fonts used etc.

 Layout Managers (objects) are used to deal with

(17)

No 3. Event Handling

 A technique to deal with user input  Event-based model:

1. button clicked (by user)

2. event generated (by the system)

(18)

Java Solution: Swing

 Untuk melakukan GUI Programming, Java

menyediakan 2 libraries:

 AWT (Abstract Window Toolkit), and  Swing

 AWT - an old library, present in the first Java

release,

 Swing - an improved library added later

 Swing does not replace AWT , it builds on top of

(19)

AWT vs Swing

 AWT components are heavyweight

 peer-based, platform-dependant implementation (in native

code).

 Difficult to port, platform-dependant look.

 Swing components are pure Java applications  lightweight - do not use peers

 Pluggable look-and-feel - platform-independant, programmer

designed look (system independent).

 Whenever possible Swing components should be

used

(20)

AWT vs Swing (2)

 Highest level components are heavy

 Each light one has a corresponding heavy one,

somewhere in the hierarchy (a background to draw onto):

(21)

Java API (JavaDoc)

 Sebagai programmer, JAVA API adalah suatu

dokumen yang wajib dimiliki.

 Semua class & method (termasuk untuk Java Swing)

ada di dalam dokumen ini!

 Dokumentasi, Tutorial, Contoh-contoh (termasuk

aplikasi Swing):

 http://www.netbeans.org/kb/index.html  http://docs.oracle.com/javase/7/docs/api/

(22)

Komponen Swing Dasar

 JFrame

 JPanel  JLabel  JButton

(23)

Frame

 The top-level component for most Swing-based

applications is called a frame and is defined by the

JFrame class.

 By itself, a frame doesn’t do much.

 But to do anything else in Swing, you must first

create a frame.

 The figure shows a frame that does nothing but

(24)

Exercise 01: HelloFrame.java

import javax.swing.*;

public class HelloFrame extends JFrame {

/** Creates a new instance of HelloFrame */

public HelloFrame() {

this.setSize(200,100);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle("Hello World!");

this.setVisible(true);

}

public static void main(String[] args) { new HelloFrame();

} }

(25)

Positioning the Frame On-Screen

 If you want to place the frame at some arbitrary

location on-screen, use the setLocation method.

 Example: frame.setLocation(0,0);

 If you want to center the frame on-screen, call the

setLocationRelativeTo method and pass null as the parameter:

(26)

JLabel

 A label is a component that simply displays text.  Labels are used for a variety of purposes:

 to display captions for other controls such as text fields or combo

boxes,

 to display informational messages, or

 to show the results of a calculation or a database lookup.

 A label can also display an image, or it can display both

an image and some text. And we have complete control over the appearance of the text

 We can specify the font, size, whether the text is bold,

italic, or underlined, what color the text is displayed as, and so on.

 Example:

JLabel label1 = new JLabel(); label1.setText("Hello, World!"); or

(27)

JButton

 Next to labels, the Swing component you use most

is the JButton component, which creates a button the user can click.

 Example:

JButton button1 = new JButton("Click me!");

or

JButton button1 = new JButton();

(28)

JPanel

 A panel is a type of container that’s designed to hold a

group of components so they can be displayed on a frame.

 The normal way to display a group of controls such as

text fields, labels, buttons, and other GUI widgets is to add those controls to a panel, and then add the panel to the frame.

 Example:

class HelloPanel extends JPanel{ public HelloPanel(){

JLabel label1 = new JLabel("Hello, World!"); JButton button1 = new JButton("Click me!");

} }

 Then, in the frame class contstructor, we create a new

instance of the panel class and add it to the frame: frame.add(new HelloPanel());

(29)

Putting it all together

Exercise 02: HelloFrame2.java

import javax.swing.*;

public class HelloFrame2 extends JFrame { /** Creates a new instance of HelloFrame */

public HelloFrame2() {

this.setSize(200,100);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle("Hello World!");

HelloPanel panel1 = new HelloPanel(); this.add(panel1);

this.setVisible(true);

this.setLocationRelativeTo(null); // set location to the center

}

class HelloPanel extends JPanel{

public HelloPanel(){

// code to add components to the panel goes here

JLabel label1 = new JLabel("Hello, this is label!"); this.add(label1);

JButton button1 = new JButton("Click me!"); this.add(button1);

} }

public static void main(String[] args) { new HelloFrame2();

} }

FULL CODE: Copy & paste the codes into JGrasp

(30)

Y O U ’ V E L E A R N E D : R E V I E W O O P : • class, • object/instance, • property, • method, • constructor •I N T R O D U C T I O N T O S W I N G :

• JFrame, JPanel, JLabel, JButton

(31)

S K I M M I N G J A V A D O C 7

P R A K T I K U M 0 1 – P E N G E N A L A N J A V A S W I N G

To Do Today

(32)

T O D O T H I S W E E K : R e a d : J a v a R e v i e w  D i k t a t O O P L , P a g e 1 2 5 R e a d : J a v a s w i n g 2 , O ’ R e i l l y ( c h a p t e r 1 ) R u n t h e D e m o ‘ S w i n g S e t 2 . j a r ’ S t u d y t h e s o u r c e c o d e o f ‘ S w i n g S e t 2 ’ G o t o h t t p : / / j a v a . s u n . c o m / d o c s / b o o k s / t u t o r i a l / u i s w i n g /

Study Guide

Referensi

Dokumen terkait

Analisis : dari tampilan diatas, saya menggunakan tag-tag html beberapa.. diantara nya sudah saya dijelaskan dari praktikum-praktikum sebelum

Hasil penelitian ini menunjukkan bahwa dari delapan faktor yang mempengaruhi kinerja sistem informasi akuntansi terdapat lima faktor yang berpengaruh secara positif dan

berskala besar.Berdasarkan dari uraian latar belakang tersebut, maka pada riset tugas akhir ini akan dilakukan pembuktian dalam pengukuran waktu uptime pada jaringan

Correlation is significant at the 0.01 level (2-tailed).. Correlation is significant at the 0.05

Untuk menambah keterampilan peserta didik dalam memahami atau mendalami suatu materi yang konsepnya telah dipelajari maka dapat menggunakan media pembelajaran. Media pembelajaran

Oleh karena itu pembahasan bab ini akan berguna bagi bekal mahasiswa dalam mengatasi masalah-masalah yang berkaitan dengan teknologi komunikasi data mengingat

2.9.1 Pengaruh Penerapan Corporate Governance, Ukuran Perusahaan, Return on Assets (ROA), dan Kualitas Audit terhadap Penghindaran Pajak

- Pihak lain yang bukan Direktur Utama/Pimpinan Perusahaan atau yang namanya tidak disebutkan dalam Akta Pendirian/ Anggaran Dasar, dapat menandatangani Berita