View SampleJideApp.java
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
JFrame frame = new JFrame(); | |
final JPanel panel = new JPanel(); | |
// Create tree and add nodes. | |
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TestObject("Hello")); | |
root.add(new DefaultMutableTreeNode(new TestObject("World"))); | |
root.add(new DefaultMutableTreeNode(new TestObject("Foo"))); | |
root.add(new DefaultMutableTreeNode(new TestObject("Bar"))); | |
final JTree tree = new JTree(root); |
View DynamicClassLoadingExample.java
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
private URLClassLoader childClassLoader; | |
private Class<?> clazz; | |
@Before | |
public void init() throws Exception { | |
// put class file in same package together with this source file | |
URL url = getClass().getResource("MyClass.class").toURI().toURL(); | |
childClassLoader = new URLClassLoader(new URL[] { url }, | |
getClass().getClassLoader()); | |
clazz = childClassLoader.loadClass("com.bpd.old.MyClass"); |
View sieve.java
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.ArrayList; | |
/** | |
* This program finds all of the prime numbers between 0 and a number supplied by the user, | |
* inclusive. | |
* | |
* @author BJ Peter DeLaCruz | |
* @version 1.1 | |
*/ | |
public class CountingPrimeNumbers { |
View codingstandard1.java
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
ahead(centerY * 2); // Move to the bottom edge. | |
turnRight(90.0); // Face west. | |
ahead(centerX); // Move to the lower left corner. | |
turnRight(90.0); // Face north. | |
ahead(centerY * 2); // Move to the upper left corner. |
View codingstandard2.java
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
counter = 0; // If robot loses radar contact with enemy after 10 turns, | |
tracker = 0; // try to find it again or pick another enemy by resetting | |
// tracker back to zero. |
View codingstandard3.java
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
// Move to the bottom edge. | |
ahead(centerY * 2); | |
// Face west. | |
turnRight(90.0); | |
// Move to the lower left corner. | |
ahead(centerX); | |
// Face north. | |
turnRight(90.0); | |
// Move to the upper left corner. | |
ahead(centerY * 2); |
View MyFileChooser.java
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
public class MyFileChooser extends JFileChooser { | |
public MyFileChooser() { | |
setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | |
addPropertyChangeListener(new MyListener()); | |
} | |
private class MyListener implements PropertyChangeListener { | |
public void propertyChange(PropertyChangeEvent event) { | |
String property = FileChooser.SELECTED_FILE_CHANGED_PROPERTY; |
View junit_ex1.java
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
SomeObject obj = new SomeObject(); | |
assertFalse(obj.hasA() || obj.hasB() || obj.hasC()); | |
assertTrue(obj.hasD() && obj.hasE()); |
View junit_ex2.java
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
SomeObject obj = new SomeObject(); | |
assertTrue(!obj.hasA()); | |
assertTrue(!obj.hasB()); | |
assertTrue(!obj.hasC()); | |
assertTrue(obj.hasD()); | |
assertTrue(obj.hasE()); |
View junit_ex3.java
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
SomeObject obj = new SomeObject(); | |
// initial state | |
assertTrue(obj.hasA()); | |
assertTrue(obj.hasB()); | |
assertTrue(obj.hasC()); | |
assertTrue(obj.hasD()); | |
assertTrue(obj.hasE()); | |
// perform some changes | |
assertTrue(!obj.hasA()); |
OlderNewer