|
1 | 1 | # Application Programming in Java
|
2 | 2 |
|
3 |
| -Rustam Zokirov, 9.10.2020 |
| 3 | +Rustam_Z🚀, 9.10.2020 |
4 | 4 |
|
5 |
| -## References: |
| 5 | +## Java Core Concepts |
6 | 6 | - Java full tutorial:
|
7 | 7 | - https://www.javatpoint.com/java-tutorial
|
| 8 | +- https://www.tutorialspoint.com/Pass-by-reference-vs-Pass-by-Value-in-java |
| 9 | +- https://www.geeksforgeeks.org/g-fact-31-java-is-strictly-pass-by-value/ |
| 10 | + |
8 | 11 | - Java OOPs:
|
9 | 12 | - https://www.javatpoint.com/java-oops-concepts
|
10 |
| -- Java exceptions: |
11 |
| -- https://www.javatpoint.com/exception-handling-in-java |
| 13 | +- Object casting - https://youtu.be/Qpz2MA4KE9U |
| 14 | + |
| 15 | +- Java Exceptions: |
| 16 | +- https://www.javatpoint.com/exception-handling-in-java |
| 17 | + |
| 18 | +- Design Patterns, SOLID Principles- https://youtu.be/A1PWJB98qcw |
| 19 | + |
| 20 | +## Java GUI |
| 21 | + |
| 22 | +### GUI Basics |
| 23 | +- [Lecture Notes](lecture-notes/GUI_Basics.ppt) |
| 24 | + |
| 25 | +- [Swing Notes](lecture-notes/Creating_User_Interfaces_Swing.ppt) |
| 26 | + |
| 27 | +- Swing (interface) vs. AWT (event handling) |
| 28 | + |
| 29 | +-```java |
| 30 | +import javax.swing.*; |
| 31 | + |
| 32 | +public class MyFrame { |
| 33 | +public static void main(String[] args) { |
| 34 | +JFrame frame = new JFrame("Test Frame"); |
| 35 | +frame.setSize(400, 300); |
| 36 | +frame.setLocationRelativeTo(null); |
| 37 | +frame.setVisible(true); |
| 38 | +frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 39 | +} |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +- ```java |
| 44 | +import javax.swing.*; |
| 45 | + |
| 46 | +public class MyFrameWithComponents { |
| 47 | +public static void main(String[] args) { |
| 48 | +JFrame frame = new JFrame( "MyFrameWithComponen") |
| 49 | + |
| 50 | +JButton jbtOK = new JButton("OK"); // Add a button into the frame |
| 51 | +frame.add(jbtOK); |
| 52 | + |
| 53 | +frame.setSize(400, 300); |
| 54 | +frame.setDefau1tC10seOperation(JFrame.EXIT_ON_CLOSE); |
| 55 | +frame.setLocationRe1ativeTo(nu11); // Center the frame |
| 56 | +frame.setVisib1e(true); |
| 57 | +} |
| 58 | +} |
| 59 | +``` |
| 60 | +- [JFrame with inheritence](programs/MyFrame1.java) |
| 61 | + |
| 62 | +### Layout Manager |
| 63 | +- For arraning a position into containers |
| 64 | + |
| 65 | +- [FlowLayout](programs/ShowFlowLayout.java) |
| 66 | + |
| 67 | +- [GridLayout](programs/ShowGridLayout.java) |
| 68 | + |
| 69 | +- [BorderLayout](programs/ShowBorderLayout.java) |
| 70 | + |
| 71 | +- `Color` class |
| 72 | +- ```java |
| 73 | + Color mycolor = new Color(228, 100, 50); |
| 74 | + // how to set for button |
| 75 | + mybutton.setBackground(Color.mycolor); |
| 76 | + mybutton.setForeground(Color.mycolor); |
| 77 | + ``` |
| 78 | + |
| 79 | +### JPanel |
| 80 | +- In `JFrame` we add a component `JPanel` |
| 81 | + |
| 82 | +- [TestPanels](programs/TestPanels.java) |
| 83 | + |
| 84 | +### Event-Handling in Java (Event-Driven Programming) |
| 85 | + |
| 86 | +- [Lecture Notes](lecture-notes/Event-Driven_Programming.ppt) |
| 87 | + |
| 88 | +- Event-driven programming (depends of action) <-> procedural programming (step by step) |
| 89 | + |
| 90 | +- [HandleEvent](programs/HandleEvent.java) |
| 91 | + |
| 92 | +- [HandleEvent1](programs/HandleEvent1.java) with the use of Inner Classes |
| 93 | + |
| 94 | +-``` |
| 95 | +User ActionObjectGenerated |
| 96 | + |
| 97 | +Click a buttonJButtonActionEvent |
| 98 | +Click a check boxJCheckBoxItemEvent, ActionEvent |
| 99 | +Click a radio buttonJRadioButtonItemEvent, ActionEvent |
| 100 | +Press return on a text fieldJTextFieldActionEvent |
| 101 | +Select a new item JComboBox ItemEvent, ActionEvent |
| 102 | +Window opened, closed, etc. Window WindowEvent |
| 103 | +Mouse pressed, released, etc. Component MouseEvent |
| 104 | +Key released, pressed, etc. Component KeyEvent |
| 105 | +``` |
| 106 | + |
| 107 | +- ``` |
| 108 | +Event ClassListener InterfaceListener Methods (Handlers) |
| 109 | +ActionEventActionListeneractionPerformed(ActionEvent) |
| 110 | +ItemEventItemListeneritemStateChanged(ItemEvent) |
| 111 | +WindowEventWindowListenerwindowClosing(WindowEvent) |
| 112 | +windowOpened(WindowEvent) |
| 113 | +windowIconified(WindowEvent) |
| 114 | +windowDeiconified(WindowEvent) |
| 115 | +windowClosed(WindowEvent) |
| 116 | +windowActivated(WindowEvent) |
| 117 | +windowDeactivated(WindowEvent) |
| 118 | +ContainerEventContainerListenercomponentAdded(ContainerEvent) |
| 119 | +componentRemoved(ContainerEvent) |
| 120 | +MouseEventMouseListenermousePressed(MouseEvent) |
| 121 | +mouseReleased(MouseEvent) |
| 122 | +mouseClicked(MouseEvent) |
| 123 | +mouseExited(MouseEvent) |
| 124 | +mouseEntered(MouseEvent) |
| 125 | +KeyEventKeyListenerkeyPressed(KeyEvent) |
| 126 | +keyReleased(KeyEvent) |
| 127 | +keyTypeed(KeyEvent) |
| 128 | + |
| 129 | +``` |
0 commit comments