ตัวอย่างการพัฒนา ระบบงาน. 2 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SignInWindow extends JFrame { JPanel panel;

Slides:



Advertisements
Similar presentations
1 Event Listeners Some Events and Their Associated Event Listeners Act that Results in the EventListener Type User clicks a button, presses Enter while.
Advertisements

Chapter 16 GUI Programming Basics GUI Overview Event-Driven Programming Basics GUI Classes and Packages A Simple Window Program JFrame Class Java Components.
User Interfaces II GUI – Awt, Swing, Web
Introduction to Swing Components Chapter 14. Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Chapter 15 Graphics. To paint, you need to specify where to paint. Each component has its own coordinate system with the origin (0, 0) at the upper-left.
OLD BUSINESS : Lets talk about the next exam Project proposals – Functional Definitions Go over homework – NEW BUSINESS: Chapter 4 today GUIs Assignment.
Unit 121 A layout manager is an object that determines the manner in which components are arranged in a container. Each layout manager implements one of.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
GridLayout, n*m grid. Column width/row height adjusted to fith the widest/highest Component.
ITK:P1 Lektion 6 Den abstrakta datatypen kö DSV Peter Mozelius.
Graphical User Interfaces
Chapter 14: Windows and applets ● Java provides cross-platform window facilities ● In Java 1, this has been done by AWT package ● However AWT had some.
JAVA1 1. JFrame. JAVA2 JApplet import java.awt.*; import java.awt.event.*; import javax.swing.*; public class HerhalingAppletH10 extends JApplet implements.
Import javax.swing.*; public class FrameTest { public static void main(String args[]) { JFrame f = new JFrame("Frame Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLO.
ตัวอย่างแอพพลิเคชัน ประยุกต์ใช้งาน GUI. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class CarToonRental.
1 cs205: engineering software university of virginia fall 2006 Wimpy Interfaces.
Computer Science 209 Images and GUIs. Working with Java Colors The class java.awt.Color includes constants, such as Color.red, for some commonly used.
Web Design & Development Lecture 19. Java Graphics 2.
Advance Java Technology Java’s Role::MVC Architecture :: Swing Prof.Chintan Dave.
Graphics and event-driven programs Learning objectives By the end of this lecture you should be able to: identify and use some of the common components.
Page w16.1 – Spring 2010Steffen Vissing Andersen SDJ I1 subjects, Spring 2010 Agenda – Week 16, 2010 GUI.
1 MSPEL Lektion 3 DSV Peter Mozelius Grafik och spel i Java applets.
Chapter 11 Creating User Interfaces F What is JavaBean? F JComponent F JButton  ImageIcon  JLabel  JTextField  JTextArea  JComboBox  JList  JCheckBox.
Basic Java – Interface design. Understand: How to use TextPad for Java How to define classes and objects How to create a GUI interface How event-driven.
Graphical User Interfaces Java’s AWT and Swing APIs.
Graphical User Interfaces (Part IV)
Java Software Development Paradigm Lecture # 12. Basics of GUI.
Examples. // A simple Frame with Rectangle Inside import java.awt.*; import javax.swing.*; import java.awt.geom.*; // For Shapes class rectComponent extends.
More on GUI We wrap up our examination of Java GUI programming by looking at several other components and their listeners – The components all come from.
Drawing in a frame – Java GUI
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
CS18000: Problem Solving and Object-Oriented Programming.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
The Model-View Approach in Java. OK, you’ve got “Hello World” running... What now?
F27SB2 Programming Languages
Problem Solving 6 GUIs and Event Handling ICS-201 Introduction to Computing II Semester 071.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Graphical User Interface Bonus slides Interaction Between Components & Drawing.
Bar Graph Design. Left-side/Right-side mechanical processing creative, abstract reasoning.
Swing: the art of the GUI COMP204, Bernhard Pfahringer.
JAVA 程式語言入門 (II).  版面配置  事件驅動  Ch14_01.java 1. import javax.swing.*; 2. import java.awt.*; 3. class Ch14_01 4. { 5. public static void main(String.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Event-Driven Programming You might have realized in creating a GUI and clicking on the JButtons that nothing happens Clicking on a JButton causes the JVM.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Övning 5. Repetition klasser class Rektangel { private static int antal = 0; private double längd; private double bredd; public Rektangel(double l, double.
GUI Tutorial Day 3. Custom Dialog Create, display, hide, retrieve information.
Layout Mangers CSC 171 FALL 2001 LECTURE 14. History: The Transistor William Shockley, John Bardeen, and Walter Brattain invent the transfer resistance.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
CS Lecture 01 Frames and Components and events Lynda Thomas
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Basics of GUI Programming Chapter 11 and Chapter 22.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 4 – Completing the Inventory Application.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Dental Payment Application.
회원가입 - GUI ** 오지*.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
Modular Event Handling
Chapter 8 Event Handling.
A First Look at GUI Applications
Graphical User Interface (pronounced "gooey")
MSIS670: Object-Oriented Software Engineering
Introduction to Event Handling
Graphical User Interface
Presentation transcript:

ตัวอย่างการพัฒนา ระบบงาน

2

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SignInWindow extends JFrame { JPanel panel; JLabel ulbl, pwlbl; JTextField usertxt; JPasswordField pwtxt; JButton signbtn, resetbtn; Icon ani; AddPanel p; Font fn = new Font("Estrangelo Edessa",Font.PLAIN,18); public SignInWindow(String title) { setTitle(title); setSize(325, 200); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); buildPanel(); add(panel); setVisible(true); } private void buildPanel() { panel = new JPanel(); panel.setLayout(new GridBagLayout()); ulbl = new JLabel("username"); pwlbl = new JLabel("password"); usertxt = new JTextField(10); pwtxt = new JPasswordField(10); ani = new ImageIcon("edit.gif"); signbtn = new JButton("sign in",ani); ani = new ImageIcon("reset.gif"); resetbtn = new JButton(" reset ",ani); ulbl.setFont(fn); usertxt.setFont(fn); pwlbl.setFont(fn); pwtxt.setFont(fn); signbtn.setFont(fn); resetbtn.setFont(fn); p = new AddPanel(); p.addItem(panel,ulbl,0,0,3,1,GridBagConstraints.WEST); p.addItem(panel,usertxt,3,0,3,1,GridBagConstraints.WEST ); p.addItem(panel,pwlbl,0,1,3,1,GridBagConstraints.WEST); p.addItem(panel,pwtxt,3,1,3,1,GridBagConstraints.WEST); p.addItem(panel,signbtn,0,3,3,1,GridBagConstraints.WES T); p.addItem(panel,resetbtn,3,3,3,1,GridBagConstraints.WES T); signbtn.addActionListener(new ButtonListener()); resetbtn.addActionListener(new ButtonListener()); } private class ButtonListener implements ActionListener public void actionPerformed(ActionEvent e) { String u, p; if (e.getSource()==signbtn) { u = usertxt.getText(); p = pwtxt.getText(); if (u.equals("admin") && p.equals("123")) { MainWindow s = new MainWindow(" หน้าหลัก "); } else JOptionPane.showMessageDialog(null, "Login Fail; Try again !!!"); usertxt.setText(""); pwtxt.setText(""); } if (e.getSource()==resetbtn) { usertxt.setText(""); pwtxt.setText(""); } } } public static void main(String[] args){ SignInWindow s = new SignInWindow(" เข้าสู่ระบบ "); } } 3

import java.awt.*; import javax.swing.*; import java.awt.event.*; public class MainWindow extends JFrame { JPanel panel; Icon ani; JButton addbtn, salebtn, closebtn; AddPanel p; Font fn = new Font("Estrangelo Edessa",Font.PLAIN,18); public MainWindow(String title) { setTitle(title); setSize(325, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE); buildPanel(); add(panel); setVisible(true); } 4 private void buildPanel() { panel = new JPanel(); panel.setLayout(new GridBagLayout()); ani = new ImageIcon("add.gif"); addbtn = new JButton("Add Product",ani); ani = new ImageIcon("edit.gif"); salebtn = new JButton("Product Sale",ani); ani = new ImageIcon("close.gif"); closebtn = new JButton("Close",ani); addbtn.setFont(fn); salebtn.setFont(fn); closebtn.setFont(fn); p = new AddPanel(); p.addItem(panel,addbtn,0,4,3,1,GridBagConstra ints.EAST); p.addItem(panel,salebtn,0,5,3,1,GridBagConstra ints.EAST); p.addItem(panel,closebtn,0,6,3,1,GridBagConstr aints.EAST); addbtn.addActionListener(new ButtonListener()); salebtn.addActionListener(new ButtonListener()); closebtn.addActionListener(new ButtonListener()); } private class ButtonListener implements ActionListener public void actionPerformed(ActionEvent e) { if (e.getSource()==addbtn) { AddProduct s = new AddProduct(" เพิ่ม สินค้า "); } if (e.getSource()==salebtn) { ProductSale s = new ProductSale(" ขาย สินค้า "); } if(e.getSource()==closebtn) { System.exit(0); }

5 โปรแกรมเพิ่มสินค้า โปรแกรมขายสินค้า

6

โปรแกรมส่วน interface  โปรแกรมเข้าสู่ ระบบ โปรแกรมเข้าสู่ ระบบ  โปรแกรมหน้า หลัก โปรแกรมหน้า หลัก  โปรแกรมเพิ่ม สินค้า โปรแกรมเพิ่ม สินค้า  โปรแกรมขาย สินค้า โปรแกรมขาย สินค้า 7 โปรแกรมส่วนจัดการ ฐานข้อมูล  SQLConnection SQLConnection  SQLCreateTable SQLCreateTable  SQLInsertTable SQLInsertTable  SQLSelectAllTable SQLSelectAllTable  SQLSelectTable SQLSelectTable

8