How to use .jar files in NetBeans?

You would add the JAR file to the Libraries in your project: (source: netbeans.org) As for the different JARs, joda-time-1.6.jar just contains the compiled classes (this is the JAR you need in order to use Joda in your project) joda-time-1.6-javadoc.jar contains the documentation for all the classes joda-time-1.6-sources.jar contains the source code for all the … Read more

How to create a Jar file in Netbeans

Create a Java archive (.jar) file using NetBeans as follows: Right-click on the Project name Select Properties Click Packaging Check Build JAR after Compiling Check Compress JAR File Click OK to accept changes Right-click on a Project name Select Build or Clean and Build Clean and Build will first delete build artifacts (such as .class … Read more

Connect 4 check for a win algorithm

For some reason I am not so fond of counters, so I did it this way (It works for boards with different sizes). public boolean areFourConnected(int player){ // horizontalCheck for (int j = 0; j<getHeight()-3 ; j++ ){ for (int i = 0; i<getWidth(); i++){ if (this.board[i][j] == player && this.board[i][j+1] == player && this.board[i][j+2] … Read more

How to wire one pane to another

Here’s an example using the observer pattern, also seen here, here and here. Note that it would also be possible to listen to the combo’s model. import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; /** * @see http://en.wikipedia.org/wiki/Observer_pattern * @see https://stackoverflow.com/a/10523401/230513 */ public class PropertyChangeDemo { public PropertyChangeDemo() { JFrame f … Read more