This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method executes an AppleScript given the source-code, using the command-line tool called osascript | |
// Note that this is a demo and doesn't do any error-checking yet such as for AppleScript syntax errors | |
// and AppleScript runtime errors. | |
+ (void)execute:(NSString *)source | |
{ | |
@try { | |
NSTask *task = [[NSTask alloc] init]; | |
[task setLaunchPath:@"/usr/bin/osascript"]; | |
NSString *arguments = [NSString stringWithFormat:@"-e %@", source]; | |
[task setArguments:[NSArray arrayWithObjects:arguments, nil]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class AverageThreeInts { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int inputs = 2; | |
int[] values = new int[3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Dimension; | |
import java.awt.FlowLayout; | |
import javax.swing.JFrame; | |
import javax.swing.JList; | |
import javax.swing.JScrollPane; | |
import javax.swing.SwingUtilities; | |
/** | |
* This class is a study in learning how to get scroll bars to work for a JList using a JScrollPane. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import javax.swing.filechooser.FileNameExtensionFilter; | |
import java.awt.*; | |
import java.io.File; | |
/** | |
* This class is a demo of a background image in a JFrame. | |
* | |
* This code was derived from the following source: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This class is a demo of how to implement for-loops correctly, declaring the loop variables | |
* inside of the for-loops, to limit their scope so that the loop variables can't be used outside | |
* of the loop where the values are too big to be valid array indexes and an ArrayIndexOutOfBoundsException | |
* is thrown. | |
* | |
* @author kaydell | |
* | |
*/ | |
public class ForLoopIndexDemo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson01.joptionpane; | |
import javax.swing.JOptionPane; | |
public class MessageDialog { | |
public static void main(String[] args) { | |
JOptionPane.showMessageDialog(null, "This is a message dialog"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package images; | |
import static org.junit.Assert.*; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This class demonstrates how to write code that can process a matrix (i.e. a two-dimensional array) | |
* Note that the method printMatrix will print any two-dimensional array of ints | |
* | |
* @author kaydell | |
* | |
* Copyright, 2013, Kaydell Leavitt, All Rights Reserved | |
* | |
* {link http://simple.wikipedia.org/wiki/Matrix_%28mathematics%29} | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.SwingUtilities; | |
/** | |
* This class is an example of how to correctly startup a GUI interface | |
* | |
* From Oracle's Java Tutorial: | |
* http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This Python source file demonstrates how Python for-loops | |
and the main() method are easier for students to understand | |
than Java is. | |
About Python: http://www.python.org/about/ | |
Free Python Download: http://www.python.org/download/ | |
It is worth considering teaching beginning students Python | |
and teach Java in more advanced courses. |
OlderNewer