Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC305 Lecture 07

210

CSC305 Lecture 07

Individual Software Design and Development
GUI
(202410)

Javier Gonzalez-Sanchez

October 07, 2024
Tweet

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 305 Individual Software Design and Development Lecture 07. Java Swing
  2. Problem public class B implements E { public B() {

    C c1 = new C(); } public void method() { B b = new B(); b.sleep(); } } public class Y extends B { A [] a = new A[5]; } public class A extends B { C c1, c2; public A() { c1 = new C(); } public void method(D d) { d.working(); } } public class X { private String s; public void m() { B var = new A(); double x – Math.sqrt(5); } }
  3. import javax.swing.*; public class Example extends JFrame{ public Example() {

    super("Hello World Swing"); BorderLayout layout = new BorderLayout(); setLayout(layout); JLabel label = new JLabel("Hello World"); add(label, BorderLayout.CENTER); JButton button = new JButton("Click Me"); add(button , BorderLayout.SOUTH); JTextField text = new JTextField("Text", 10); add(text , BorderLayout.NORTH); JCheckBox check = new JCheckBox("Option"); add(check , BorderLayout.EAST); } public static void main(String[] args) { Example frame = new Example(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } }
  4. import javax.swing.*; public class Example extends JFrame{ public Example() {

    super("Hello World Swing"); GridLayout layout = new GridLayout(3,2); setLayout(layout); JLabel label = new JLabel("Hello World"); add(label); JButton button = new JButton("Click Me"); add(button); JTextField text = new JTextField("Text", 10); add(text); JCheckBox check = new JCheckBox("Option"); add(check); } public static void main(String[] args) { Example frame = new Example(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } }
  5. Let’s Work 28 Class Diagram for the kappa version of

    my Paint App https://github.com/CSC3100/App-Paint/tree/main/ src/main/java/javiergs/paint/Kappa
  6. CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D.

    [email protected] Summer 2024 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.