Popular in Course
Popular in ComputerScienence
This 71 page Class Notes was uploaded by Vito Kilback on Wednesday September 23, 2015. The Class Notes belongs to CS190 at Drexel University taught by Staff in Fall. Since its upload, it has received 59 views. For similar materials see /class/212468/cs190-drexel-university in ComputerScienence at Drexel University.
Reviews for Java
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/23/15
CS 190 Java Introduction to Java Andy Mroczkowski uamroczkcs drexel edu Department of Computer Science Drexel University March 10 2008 Lecture 8 Outline Course Status Course Information amp Schedule Assignments amp Final Project Networking lP Networking Intro Simple Sockets in Java Demo GUI Java GUI Intro Events Layouts Swing Controls Wrapup Wrapup The End Course Status 90 Course Information 0 Instructor 0 Andy Mroczkowski uamroczk ics drexel edu 0 Office Location UC 147 0 Office Hours Monday 67 amp evenings by appointment 0 Course 0 CS 190 Java 0 Web www cs drexel eduNuamroczkcsl90 0 Book Thinking in Java 4th Edition 0 Previous edition available for tree at wwwwmindviewnetBookSTIJ 0 Course materials adapted from Nadya Belov 0 Many examples from TiJ 4th Ed Course Status on at Schedule1 Jan 7 Course Overview Introduction to Java Jan 14 No Class Jan 21 No Class University Holiday Jan 28 Object Oriented Concepts Control Statements Feb 4 Access Control Intialization amp Cleanup Reuse Interfaces Feb 11 Containers Exceptions Polymorphism Midterm Review Feb 18 Midterm InnerClasses Feb 25 Type Information Generics Arrays Mar 3 Files amp IO Threading Mar 10 GUI Special Topics Networking Reflection Mar 19 Final Project 1Also subject to change Course S a us mmmg gone Assignment 5 0 Questions Course S a us 6300 Final Project 0 Collaboration OK but you must let me know 0 Group of 3 Max Course Status 6300 Final Project 0 Collaboration OK but you must let me know 0 Group of 3 Max 0 Extra credit 0 Multiple players Live or automated 0 Saving Scores File lO o Betting 0 Networking 0 oryouridea Course Status 6300 Final Project 0 Collaboration OK but you must let me know 0 Group of 3 Max 0 Extra credit Multiple players Live or automated Saving Scores File lO Betting Networking 0 oryouridea oGUl Course S a us mmmg gone Final Project 0 Questions Course S a us 660 Final Project Tips Random generator new Random int index1 generatornextnt deckSize int index2 generatornextnt deckSize Course S a us oo Final Project Tips public class BlackjackHand extends Hand 0mm 51am Networkmg 00 was Demo on Networking Networkmg uooo mom cu Networking A quick introduction Cwse 5mm 09 NeIwoerg aw 000 0000000 memos DO SO co 0 IP Networking 0mm 51w Networkmg 00 03900 Cw 0000 CH IP Networking 0 Addressing Networkmg ouoo mom cu IP Networking 0 Addressing 0 Host 0 Port Networkmg ouoo IP Networking 0 Addressing 0 Host 0 Port 0 Data transmission NeIWOrKirig ouoo IP Networking 0 Addressing 0 Host 0 Port 0 Data transmission 0 Send 0 Receive CourseSlam Networkmg a 000 000 0000 00 n QQDOD OOOE O r C as o IP Hosts 0 Host Course 51w Networkmg 0 com 7 mm Cu IP Hosts 0 Host 0 Post office Networkmg oouo 00000 cm IP Hosts 0 Host 0 Postoffice o wwwgoog1ecom o 1921682010 0 127001 Networkmg oouo 00000 cm IP Hosts 0 Host 0 Postoffice o wwwgoogle com o 192168 2010 o 1270 Ol 0 Port IP Hosts 0 Host 0 Post office 0 wwwgoog1ecom 0 1921682010 0 127001 0 Port 0 Mailbox Networkmg owns 900 IP Hosts 0 Host 0 Post office 0 www google com 0 192 168 2010 0 12 7 O O l 0 Port 0 Mailbox ftp 21 http 80 less than 1024 priveledged greater than 1024 unpriveledged Course 51w Networkmg 00 000 cm 0000 as Data transmission IP Sockets Networking coo Doom Data transmission IP Sockets 0 Data endpoints Networking coo 00003 Data transmission IP Sockets 0 Data endpoints 0 Two types Networking 9 Data transmission IP Sockets 0 Data endpoints 0 Two types 0 Stream TOP 0 Datagram UDP CourseSlam Networkmg w 3 o o 0 000000 Simple Sockets in Java Simple Sockets in Java Socket and ServerSocket classes 5mm Networking to at o 00 Simple Sockets in Java Socket and ServerSocket classes 0 ServerSocket 0 Listen for and accept connections 0 Can have handle many incoming connections Elm Networking to at o 00 Simple Sockets in Java Socket and ServerSocket classes 0 ServerSocket 0 Listen for and accept connections 0 Can have handle many incoming connections 0 Socket 0 Initiate client connections Elm Networking to at o 00 Simple Sockets in Java Socket and ServerSocket classes 0 ServerSocket 0 Listen for and accept connections 0 Can have handle many incoming connections 0 Socket 0 Initiate client connections 0 Read and write data streams Networkmg was no 5 Create a ServerSocket ServerSocket server new ServerSocket int listeniport Networkmg mum 0000 g a Listening for connections ServerSocket server new ServerSocket int listeniport Socket 5 serveraccept Create a client Socket Socket client new Socket String server int port NeIWOrKii ig i i goo Sending and Receiving data Readin39 InputStream in socketgetnputStream Writin39 OutputStream out socketgetOutputStream Now we can readwrite just like they was files Networkmg GU Qooogo Qourse b alus non 0009000 0 00 gggwo Demo bmlrse 51am NeIwoerg GLH Iquot up 00 0000 0009000 000000 c g moon ammo o a com 0 Questions GUI ALL examlpes from Thinking in Java 4th ed ooooooo ammo no 0 Java GUI History o In the beginning there was AWT Java GUI History 0 In the beginning there was AWT And it was a dark dark time Java GUI History 0 In the beginning there was AWT And it was a dark dark time 0 Then the geeks said let there be Swing Java GUI History 0 In the beginning there was AWT And it was a dark dark time 0 Then the geeks said let there be Swing And so it was Java GUI History 0 In the beginning there was AWT And it was a dark dark time 0 Then the geeks said let there be Swing And so it was 0 Some of the elders tell stories about quotAppletsquot but no one has seen one in years They are thought to be extinct bmlrse 51am GU u 00 0000000 000000 E D 00030 o co Swing Basics ooooooo ODQO goo Swing Basics 0 Objects just like everything else Swing Basics 0 Objects just like everything else 0 Most things inherit from java awt Component 000000 0 3m Swing Basics 0 Objects just like everything else 0 Most things inherit from java awt Component 0 Everything is done programatically 0 Though there are visual tools that can generate code for 000000 0 3m Swing Basics 0 Objects just like everything else 0 Most things inherit from java awt Component 0 Everything is done programatically 0 Though there are visual tools that can generate code for o Strives for consistency Swing Basics JFrame import javax swmg public class HeHoSwmg P ublic static void mam SmngH JFrame 1 args e new JFrame HeHoHSwmg rame se DevauMmoseOperauon JFrame ExmomoLOSE rame se SZe 300 100 rame se Vsbe rue Swing Basics JLabel import javax swmg h import java um concurrent h public class HeHoLabet public static void mam Smn JFrame tame new JFrame HeH JLabe label new JLabeH 4Labe trame add label trame setDetauttotoseOperauon JFrame EXtLomoLOSE trame setStze 300 100 trame setVtstbte true 0N steep 1 label setTeXt HeytHThtsH 9H args throws Exceptton OHSng t sudtHerent GU 000000 392m 0 Swing Demo Display Helper import javax swmg 4 public class SwmgConso P 40 4 ublic static void run I39nal JFrame 4 Iinal int w4d4h Iinal int he4gh4 SwmgUmmes 4nvoKeLa4e new Runnab4e0 public void run 4 004M404 4 ge404ass4 ge44mp4eName 1 se DemuHmoseOper 4 JFrame EXVLON CLOSE 4 4 00484204 w4d4h he4gh4 4 se4V4s4b4e l e 4 H4 JButton import lavax Swing import public lava awl class Bullonl extends JFrame private JBuHon b1 new JButton Bullonu l private JBuHon b2 new JButton Buttonuz public BullonH selLayoul new FlowLayoul Nate Layuur Manager dd b1 add b2 public static void maln String args SwingConsole run new Bullon l 200 m Events Ok we can create controls How do we make them do something latw import import import public lavax Swing lava a wt lava awl event t class Buttonz extends JFrame rivate JBullon b1 p new JButton Bullonu l prIvat B in b2 new JButton Bullo H2 private JTeXl leld txt new JTextField 1 class But onLlSlel i r implem nts ACllOl iLlSlel i r blic Id acilonPerlormed Acti Event e l g name JB llone gelSource gelTeXlU txt selTeXl name l private ButtonListener bl new ButtonListeneML public Button2 b1 addAcllonLlslener bl b2 addAcllonLlslener bl set new Flo L youl add 1 add b2 add m public static void maln String args SwingConsole run new Bullon2 200 150 lalw import import import public lavax Swing lava awl lava awl event class Buttonzb extends JFrarne private JBuHon b1 private JBuHon b2 private JTextField new JButton BullonH l new JButton Button 2 lxl new JTeXlField in private ACllOl iLlSlel ier bl new ACllOnLlSlener public void actionPerlormed ACllOnEVel il e String name JBullone gelSource txt selTeXl name getrexur public Buttonzb b l addAcllonLlslener bl add m j public static void main Smng SW args lngConSole run new Bull0n2 200 150 t wtatw Action Event AdjustmentEvent ComponentEvent ContainerEvent FocusEvent KeyEvent MouseEvent WindowEvent Item Event Text Event Events JButton JList JScrollBar Component and its derivatives Container and its derivatives Component and its derivatives Component and its derivatives Component and its derivatives Window and its derivatives JCheckBox JComboBox JTextArea JTextField JTextField JList Wrzr up w M Course status I lwor 0000000 gooooo 5390 0000 09 r smog DOD an Event Demo Layouts 0 Java can automatically position or layout components 0 Several different LayoutManagers Layouts 0 Java can automatically position or layout components 0 Several different LayoutManagers 0 Absolute positioning still available but hard to do by hand 0 Designercode generation tools Layouts BorderLayout North South East West FlowLayout quotflowsquot in GridLayout Rows by Columns GridBagLayout Control Freak BoxLayout Simplified GridBagLayout mono Ooooooo Course Status Nawomm GU meup 0 39 cocoa 00030 0 on can Layout Demos Swing Controls Bunons Icons TextFields Borders TextPane CheckBoxes RadioButtons ComboBoxes List Tabbed Pane MessageBoxes Menus Drawing Dialogs HTM L Progress H Mrquot aux Wraprup Came WO 3 0000000 000000 DOUG OOOQO o 00 QQDDD OCH an Wrapup Wraprup oooooo What We Covered 0 Object Oriented Concepts 0 Information Hiding o Encapsulation o Reuse o Operators 0 Control Statements 0 Conditionals o Loops 0 Java coding style 0 Access Control 0 Scope 0 Packages 0 Visibility Wraprup oooooo What We Covered cont 0 Initialization amp Cleanup 0 Creating objects 0 Constructors o finalize o Reuse 0 Composition 0 Delegation o Inheritance 0 Abstract Classes 0 Interfaces 0 Collections 0 ArrayList o HashMap o Iterator Wraprup oooooo What We Covered cont Exceptions Inner Classes 0 Anonymous Inner Classes Type Information 0 RTTI 0 Class objects Arrays Generics IO 0 Files 0 Streams Wraprup gooooo What We Covered cont 0 Basic threads 0 Basic networkins o GUI 0 Swing Components 0 Layouts 0 Events Wraprup Qooooo What we didn t cover 0 Enumerated Types 0 Containers in depth 0 Annotations 0 In Thinking in Java or on the web Wraprup 000000 a m a Thank you and Good Night
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'