@@ -34,6 +34,12 @@ public static void openURL(String url) {
3434 }
3535 }
3636
37+ /** Creates a JFrame with desired size and position.
38+ * @param title = Window title
39+ * @param x,y = position of window
40+ * @param w,h = size of client area within window
41+ * @param lm = LayoutManager
42+ */
3743 public static JFrame createJFrame (String title , int x , int y , int w , int h , LayoutManager lm ) {
3844 //NOTE : When you add components, you must validate() the frame
3945 JFrame frame = new JFrame (title );
@@ -48,6 +54,7 @@ public static JFrame createJFrame(String title, int x, int y, int w, int h, Layo
4854 return frame ;
4955 }
5056
57+ /** Creates JPanel that will fill parent container. */
5158 public static JPanel createJPanel (LayoutManager lm , Container parent ) {
5259 JPanel ret = new JPanel ();
5360 ret .setLayout (lm );
@@ -61,6 +68,7 @@ public static JPanel createJPanel(LayoutManager lm, Container parent) {
6168 return ret ;
6269 }
6370
71+ /** Creates JPanel with size and position within container. */
6472 public static JPanel createJPanel (int x , int y , int w , int h , LayoutManager lm , Container parent ) {
6573 JPanel ret = new JPanel ();
6674 ret .setLayout (lm );
@@ -72,6 +80,7 @@ public static JPanel createJPanel(int x, int y, int w, int h, LayoutManager lm,
7280 return ret ;
7381 }
7482
83+ /** Creates JFImage that will fill parent container. */
7584 public static JFImage createJFImage (Container parent ) {
7685 JFImage ret = new JFImage ();
7786 if (parent != null ) {
@@ -81,6 +90,7 @@ public static JFImage createJFImage(Container parent) {
8190 return ret ;
8291 }
8392
93+ /** Creates JFImage with size and position within container. */
8494 public static JFImage createJFImage (int x , int y , int w , int h , Container parent ) {
8595 JFImage ret = new JFImage ();
8696 ret .setBounds (x , y , w , h );
@@ -156,25 +166,31 @@ public static int[] getFontMetrics(Font font, String txt) {
156166 return ret ;
157167 }
158168
169+ /** Show a message with title. */
159170 public static void showMessage (String title , String msg ) {
160171 JOptionPane .showMessageDialog (null , msg , title , JOptionPane .INFORMATION_MESSAGE );
161172 }
162173
174+ /** Show error message with title. */
163175 public static void showError (String title , String msg ) {
164176 JOptionPane .showMessageDialog (null , msg , title , JOptionPane .ERROR_MESSAGE );
165177 }
166178
179+ /** Popup dialog that allows String input. */
167180 public static String getString (String msg , String str ) {
168181 return JOptionPane .showInputDialog (null , msg , str );
169182 }
170183
184+ /** Show confirmation popup with message and title (OK, CANCEL). */
171185 public static boolean showConfirm (String title , String msg ) {
172186 return JOptionPane .showConfirmDialog (null , msg , title , JOptionPane .OK_CANCEL_OPTION ) == JOptionPane .OK_OPTION ;
173187 }
188+
174189 public static final int YES = JOptionPane .YES_OPTION ;
175190 public static final int NO = JOptionPane .NO_OPTION ;
176191 public static final int CANCEL = JOptionPane .CANCEL_OPTION ;
177192
193+ /** Show confirmation popup with message and title that includes 3 options (YES, NO, CANCEL). */
178194 public static final int showConfirm3 (String title , String msg ) {
179195 return JOptionPane .showConfirmDialog (null , msg , title , JOptionPane .YES_NO_CANCEL_OPTION );
180196 }
@@ -320,6 +336,7 @@ public static void donate() {
320336 showMessage ("Donate" , "If you find this program useful,\n please send $5 US or more via Paypal to pquiring@gmail.com\n Thanks!" );
321337 }
322338
339+ /** Show open file dialog with init path. */
323340 public static String getOpenFile (String path ) {
324341 return getOpenFile (path , null );
325342 }
@@ -328,7 +345,7 @@ public static String getOpenFile(String path) {
328345 *
329346 * @param path = init path
330347 * @param filters[][] = new String[][] { {"desc", "txt"}, ...};
331- * @return
348+ * @return selected file (null = cancel)
332349 */
333350 public static String getOpenFile (String path , String [][] filters ) {
334351 JFileChooser chooser = new JFileChooser ();
@@ -349,6 +366,7 @@ public static String getOpenFile(String path, String[][] filters) {
349366 }
350367 }
351368
369+ /** Show save file dialog with init path. */
352370 public static String getSaveFile (String file ) {
353371 return getSaveFile (file , null );
354372 }
@@ -357,7 +375,7 @@ public static String getSaveFile(String file) {
357375 *
358376 * @param file = init file
359377 * @param filters[][] = new String[][] { {"desc", "txt"}, ...};
360- * @return
378+ * @return selected file (null = cancel)
361379 */
362380 public static String getSaveFile (String file , String [][] filters ) {
363381 JFileChooser chooser = new JFileChooser ();
@@ -386,15 +404,16 @@ public static String getSaveFile(String file, String[][] filters) {
386404 }
387405 }
388406
407+ /** Show save file as dialog with init path. */
389408 public static String getSaveAsFile (String path ) {
390409 return getSaveAsFile (path , null );
391410 }
392411
393- /** Show save file dialog.
412+ /** Show save file as dialog.
394413 *
395414 * @param path = init path
396415 * @param filters[][] = new String[][] { {"desc", "txt"}, ...};
397- * @return
416+ * @return selected file (null = cancel)
398417 */
399418 public static String getSaveAsFile (String path , String [][] filters ) {
400419 JFileChooser chooser = new JFileChooser ();
@@ -422,6 +441,7 @@ public static String getSaveAsFile(String path, String[][] filters) {
422441 }
423442 }
424443
444+ /** Show select folder dialog with init path. */
425445 public static String getOpenFolder (String path ) {
426446 JFileChooser chooser = new JFileChooser ();
427447 chooser .setFileSelectionMode (JFileChooser .DIRECTORIES_ONLY );
@@ -434,6 +454,7 @@ public static String getOpenFolder(String path) {
434454 }
435455 }
436456
457+ /** Change LAF to Metal theme. */
437458 public static void setMetalLAF () {
438459 try {
439460 javax .swing .UIManager .setLookAndFeel ("javax.swing.plaf.metal.MetalLookAndFeel" );
@@ -459,13 +480,6 @@ public static double getScaling() {
459480 return device .getDisplayMode ().getWidth () / (double ) device .getDefaultConfiguration ().getBounds ().width ;
460481 }
461482
462- public static void main (String [] args ) {
463- while (true ) {
464- System .out .println ("scaling=" + getScaling ());
465- JF .sleep (1000 );
466- }
467- }
468-
469483 /** Loads font config for graal apps. */
470484 public static void loadFontConfig () {
471485 try {
@@ -489,6 +503,7 @@ public static void listFonts() {
489503 }
490504 }
491505
506+ /** Creates empty Set of AWTKeyStoke. */
492507 public static Set <? extends AWTKeyStroke > emptyKeys () {
493508 HashSet <AWTKeyStroke > list = new HashSet <>();
494509 return list ;
0 commit comments