I have experience using PHP, Perl and JavaScript, and am now planning to teach myself Java...
I have decided to work with the NetBeans 5.0 IDE, and have completed many tutorials most of which were simple applications that accept command line arguments. Recently I have moved to learning GUI development with NetBeans 5. I have been able to create forms without much of a problem but have hit a wall when it comes to displaying/manipulating graphics.
Currently I am working toward an intricate "Towers of Hanoi" game, I'm sure most programmers are familiar with...I chose this not(exclusivly) for its recursive solution but to familiarize myself with drawing shapes and event handling.
I'm having trouble getting this one started...
I think the main problem is with the code NetBeans automatically generates when developing a GUI interface.
To start, I have created the layout using NB5 GUI builder and have been able to apply listeners and handlers to many different components...
What I can't figure out is how to add images to my JPanel. Can anyone show me how to do this? I just would like to have a couple Rectangles (3d would be nice) that appear on the JPanel (gameSheet), that should get the ball rolling. Once I have that I can worry about adding some event handlers to make them draggable.
Any help would be greatly appreciated.
Below is the basic code the NB generates when using the GUI builder.
atsea
I have decided to work with the NetBeans 5.0 IDE, and have completed many tutorials most of which were simple applications that accept command line arguments. Recently I have moved to learning GUI development with NetBeans 5. I have been able to create forms without much of a problem but have hit a wall when it comes to displaying/manipulating graphics.
Currently I am working toward an intricate "Towers of Hanoi" game, I'm sure most programmers are familiar with...I chose this not(exclusivly) for its recursive solution but to familiarize myself with drawing shapes and event handling.
I'm having trouble getting this one started...
I think the main problem is with the code NetBeans automatically generates when developing a GUI interface.
To start, I have created the layout using NB5 GUI builder and have been able to apply listeners and handlers to many different components...
What I can't figure out is how to add images to my JPanel. Can anyone show me how to do this? I just would like to have a couple Rectangles (3d would be nice) that appear on the JPanel (gameSheet), that should get the ball rolling. Once I have that I can worry about adding some event handlers to make them draggable.
Any help would be greatly appreciated.
Below is the basic code the NB generates when using the GUI builder.
Code:
/*
* hanoiWin.java
*
* Created on 2006/08/28, 17:14
*/
package my.tower;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class hanoiWin extends javax.swing.JFrame {
/** Creates new form hanoiWin */
public hanoiWin() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new hanoiWin().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel dataPanel;
private javax.swing.JPanel gameSheet;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JPanel setupPanel;
// End of variables declaration
}
atsea