Bom, eu já li os tutoriais, tentei fazer um .jar tanto na mão como no NetBeans mas não rolou. Dá um problema no “main” na hora de executar.
Vou colocar aqui o código teste que estou usando, lembrando que esse código compila e roda normalmente, exceto quandeu insiro a linha referente ao package.
package pacoteTeste2; //
import java.awt.*;
import java.applet.Applet;
import java.awt.image.*;
import javax.swing.*;
import java.awt.geom.AffineTransform;
import java.awt.event.*;
public class Map_Line extends Applet {
private BufferedImage bi;
public int x=0, y=0;
public static Map_Line Map;
public Map_Line() {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
Frame f = new Frame("Exibir Imagens");
f.addWindowListener(l);
pega_botao botao = new pega_botao();
f.addKeyListener(botao);
f.add("Center", this);
f.pack();
setBackground(Color.black);
Image img = getToolkit().getImage("kuruma.gif");
try {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForID(0);
} catch (Exception e) {}
int iw = img.getWidth(this);
int ih = img.getHeight(this);
bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
Graphics2D big = bi.createGraphics();
big.drawImage(img,0,0,this);
f.setSize(new Dimension(350, 250));
f.show();
}
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
//JOptionPane.showMessageDialog(null, "");
int w = getSize().width;
int h = getSize().height;
int bw = bi.getWidth(this);
int bh = bi.getHeight(this);
g2.drawImage(bi, null, x, y);
g2.setColor(Color.black);
g2.setStroke(new BasicStroke(5.0f));
//g2.drawLine(10, 10, bw-10, bh-10);
}
public static void main(String[ ] args) {
Map = new Map_Line();
}
class pega_botao implements KeyListener {
public int desenhando = 1;
public int sair = 0;
public String Sout;
public Graphics g;
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == KeyEvent.VK_LEFT){
//JOptionPane.showMessageDialog(null, "ESQUERDA");
Map.x -= 5;
Map.repaint();
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT){
//JOptionPane.showMessageDialog(null, "DIREITA");
Map.x += 5;
Map.repaint();
}
if (e.getKeyCode() == KeyEvent.VK_UP){
//JOptionPane.showMessageDialog(null, "ESQUERDA");
Map.y -= 5;
Map.repaint();
}
if (e.getKeyCode() == KeyEvent.VK_DOWN){
//JOptionPane.showMessageDialog(null, "ESQUERDA");
Map.y += 5;
Map.repaint();
}
}
public void keyTyped(KeyEvent e){}
public void keyReleased(KeyEvent e){
}
}
}
Meu manifest.txt tem o seguinte:
Main-Class: pacoteTeste2.Map_Line
Name: pacoteTeste2/Map_Line.class
Java-Bean: True
Obrigado.
