====== Java concept ====== C++ Code --> Executable --> OS --> CPU Java code --> Class --> { "JVM win", "JVM linux", CPU that supports JAVA} --> OS --> CPU Java is like a application (Your Java app) running in another application (JavaVM). \\ so you need cmd java to run your app (.class) javac yourJavaApp.java java youJavaApp ====== Java tool, library and system environment path ====== * Java IDE list: * Eclipse (green): http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigosr1 * J2EE - for Enterprise system and application * J2SE - for desktop application * mostly used: http://www.oracle.com/technetwork/java/javase/downloads/index.html * then click download Java JDK, * for windows x86 direct link: http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-windows-i586.exe * idiot spoon feeding video guide if you're too lazy to google or youtube: http://www.youtube.com/watch?v=Hl-zzrqQoSE * J2ME - for micro and mobile application add java bin directory path to system environment or user profile environment variable: * for win dos set path=c:\java\bin\location;%PATH% * or go system property > environment variable > user variable : path; and add java location at end * for mac,linux export path=/java/bin/location:$PATH * or edit ~/.bash_profile, add this cmd line in it. ====== Portable Java JRE ====== - copy existing JRE to portable device - when use, in mac or linux terminal, export JAVA_HOME=/jre_dir/bin/java export PATH=/jre_dir/bin:$PATH and in dos set path = %PATH%;d:\jre_dir\bin set JAVA_HOME=d:\jre_dir\bin\java - force java use local JRE instead of asking system for it java -verbose -jar MyApp.jar ====== Quick Syntax ====== * Data type and access * String // compare string new String("test").equals("test") //==> true //ref: http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java * Array (static type) int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; System.out.println("size of num[]: " + num.length); * Dynamic arrayimport java.util.ArrayList; private ArrayList items = new ArrayList(); System.out.println(items.size()); * GUI * Layout FlowLayout() //FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT, FlowLayout.LEADING, FlowLayout.TRAILING GridLayout(int rows, int columns) BorderLayout() BoxLayout() GroupLayout() SpringLayout() //ref: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html * JTable operation: * method list: http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html * header update ref: http://www.roseindia.net/java/example/java/swing/ChangeColumnName.shtml * refresh header display after update listTable.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("IC No"); listTable.getTableHeader().repaint(); //ref: http://www.java.net/node/692818 * update date ref: http://stackoverflow.com/questions/5918727/updating-data-in-a-jtable * fill data for(int i=0;i * clear data for (int i = 0; i < table.getRowCount(); i++) for(int j = 0; j < table.getColumnCount(); j++) { table.setValueAt("", i, j); } } * user input * custom form dialog String[] n_arr=new String[3]; JTextField icno = new JTextField(); JTextField firstName = new JTextField(); JTextField lastName = new JTextField(); final JComponent[] inputs = new JComponent[] { new JLabel("IC NO"), icno, new JLabel("First Name"), firstName, new JLabel("Last Name"), lastName }; JOptionPane.showMessageDialog(null, inputs, "Member Creation", JOptionPane.PLAIN_MESSAGE); n_arr[0]=icno.getText(); n_arr[1]=firstName.getText(); n_arr[2]=lastName.getText(); * Data validation for form guis * ref: http://www.codeproject.com/Articles/401805/A-framework-for-comprehensive-validation-of-user-i ====== Quick GUI dev and App dev with NetBean ====== * Quick GUI design guide from JFrame in NetBean (25 min) * http://netbeans.org/kb/docs/java/quickstart-gui.html * Quick App Build guide with user interaction (15 min) * http://netbeans.org/kb/docs/java/gui-functionality.html Some UI design Tips: * hide and show part of UI panelA.setVisible(false); //ref: http://www.codecommit.com/blog/java/techniques-of-java-ui-development ====== Program Design Pattern ====== * MVC tips: * Calc example: http://leepoint.net/notes-java/GUI/structure/40mvc.html ====== Tutorials ====== * video: http://www.youtube.com/user/VoidRealms/playlists