/*
* Smiley.java
*
* Created on 10. April 2006, 14:36
*/
package smiley;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author Hannes
*/
public class Smiley extends javax.swing.JFrame {
/**
* Creates new form Smiley
*/
public Smiley() {
super("QIP psYNovA-Skin Smileys");
InitWindowListener();
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 ">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
jPanel1.setLayout(new java.awt.GridLayout(8, 8));
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 570, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 571, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
public void InitWindowListener() {
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
// if (JOptionPane.showConfirmDialog(null, "Aufgeben und beenden?", "Spielende", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
System.exit(0);
}
});
}
public void paint(Graphics g) {
super.paint(g);
Image img;
char c1 = 'a', c2 = 'a';
String file;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8 && !(i == 7 && j == 7); j++) {
file = Character.toString(c1)+Character.toString(c2)+".gif";
System.out.println(file);
// Ursprüngliche Methode: Smileys werden nicht animiert dargestellt
// img = this.getToolkit().getImage(this.getClass().getResource(file));
// g.drawImage(img,j*70,i*70,null);
// 2. Methode: Funktioniert nicht (??)
// ImageIcon m_icon = new ImageIcon(this.getToolkit().getImage(this.getClass().getResource(file)));
// JLabel m_label=new JLabel("text");
// m_label.setIcon(m_icon);
// jPanel1.add(m_label);
// 3. Methode
// aa.gif
// Uncaught error fetching image:
// java.lang.NullPointerException
ImageIcon m_icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource(file)),file);
JLabel m_label=new JLabel();
m_label.setIcon(m_icon);
jPanel1.add(m_label);
if (++c2 > 'z') {
c2 = 'a';
c1++;
}
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Smiley().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
// End of variables declaration
}