Max170602

Membre
Inscription
24 Mars 2016
Messages
2
Réactions
0
Points
2 286
Bonjour je crée cette discussion en espérant régler mon problème, il y a maintenant un jour j'ai décidé de crée un launcher minecraft le problème étant que la je suis bloqué depuis qu'elles heures avec ce problème que je ne comprend pas

Exception in thread "main" java.lang.NullPointerException
at fr.theshark34.openlauncherlib.launcher.util.UsernameSaver.<init>(UsernameSaver.java:66)
at fr.maxmx.LauncherPanel.<init>(
LauncherPanel.java:23)
at fr.maxmx.LauncherFrame.<init>(
LauncherFrame.java:22)
at fr.maxmx.LauncherFrame.main(
LauncherFrame.java:38)

Je vous donne le code des différente class que j'ai

Launcher.java

package fr.maxmx;

import java.io.File;

import fr.theshark34.openlauncherlib.launcher.GameInfos;
import fr.theshark34.openlauncherlib.launcher.GameTweak;
import fr.theshark34.openlauncherlib.launcher.GameType;
import fr.theshark34.openlauncherlib.launcher.GameVersion;

public class Launcher {

public static final GameVersion LC_VERSION = new GameVersion("1.7.10", GameType.V1_7_10);
public static final GameInfos LC_INFOS = new GameInfos("ElypZia", LC_VERSION, true, new GameTweak[] {GameTweak.FORGE});
public static final File LC_DIR = LC_INFOS.getGameDir();
public static final GameInfos SC_INFOS = null;
public static void auth(String text, String string) {
// TODO Auto-generated method stub

}

}

LauncherFrame.java

package fr.maxmx;

import javax.swing.JFrame;

import fr.theshark34.openlauncherlib.launcher.util.WindowMover;
import fr.theshark34.swinger.Swinger;

@SuppressWarnings("serial")
public class LauncherFrame extends JFrame {


private static LauncherFrame instance;
private LauncherPanel launcherPanel;

public LauncherFrame() {
this.setTitle("Elypzia Launcher");
this.setSize(975, 625);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setUndecorated(true);
this.setIconImage(Swinger.getResource("icon.png"));
launcherPanel = new LauncherPanel();
this.setContentPane(launcherPanel);

WindowMover mover = new WindowMover(this);
this.addMouseListener(mover);
this.addMouseMotionListener(mover);


this.setVisible(true);
}

public static void main(String[] args) {
Swinger.setSystemLookNFeel();
Swinger.setResourcePath("/fr/maxmx/resources");


instance = new LauncherFrame();
}

public static LauncherFrame getInstance() {
return instance;
}

public LauncherFrame getLauncherPanel() {
return instance;
}

}

LauncherPanel.java

package fr.maxmx;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import fr.theshark34.openlauncherlib.launcher.util.UsernameSaver;
import fr.theshark34.swinger.Swinger;
import fr.theshark34.swinger.event.SwingerEvent;
import fr.theshark34.swinger.event.SwingerEventListener;
import fr.theshark34.swinger.textured.STexturedButton;

@SuppressWarnings({ "serial", })
public class LauncherPanel extends JPanel implements SwingerEventListener {

private Image background = Swinger.getResource("background.png");

private UsernameSaver saver = new UsernameSaver (Launcher.SC_INFOS);

// private Saver saver = new Saver(new File(Launcher.LC_DIR, "Launcher.properties")); // a garder au cas ou que les autre marche pas

private JTextField usernameField = new JTextField(saver.getUsername(""));
private JPasswordField passwordField = new JPasswordField();

private STexturedButton playButton = new STexturedButton (Swinger.getResource("play.png")); // a faire ( l'image )
private STexturedButton quitButton = new STexturedButton (Swinger.getResource("quit.png")); // a faire ( l'image )
private STexturedButton hideButton = new STexturedButton (Swinger.getResource("hide.png")); // a faire ( l'image )

public LauncherPanel() {
this.setLayout(null);

usernameField.setForeground(Color.WHITE);
usernameField.setFont(usernameField.getFont().deriveFont(20F));
usernameField.setCaretColor(Color.WHITE);
usernameField.setOpaque(false);
usernameField.setBorder(null);
usernameField.setBounds(326, 360, 326, 350); //Pas sur a verifier les coord
this.add(usernameField);


passwordField.setForeground(Color.WHITE);
passwordField.setFont(passwordField.getFont().deriveFont(20F));
passwordField.setCaretColor(Color.WHITE);
passwordField.setOpaque(false);
passwordField.setBorder(null);
passwordField.setBounds(326, 360, 326, 350); //A changer les coord pour ecrire le text Mdp
this.add(passwordField);

playButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(playButton);

quitButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(quitButton);

hideButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(hideButton);
}

@Override
public void onEvent (SwingerEvent e) {
if(e.getSource() == playButton) {
System.out.println("Je suis cliqué"); // pour tester le button
} else if(e.getSource() == quitButton)
System.exit(0);
else if (e.getSource() == hideButton)
LauncherFrame.getInstance().setState(JFrame.ICONIFIED);

}

@Override
public void paintComponent (Graphics graphics) {
super.paintComponent(graphics);
drawfullsizedImage(graphics, this, background);

}

private void drawfullsizedImage(Graphics graphics, LauncherPanel launcherPanel, Image background2) {
// TODO Auto-generated method stub

}
}

Voila merci d'avance pour votre aide !
 

Ruby.

Undefined
Inscription
25 Avril 2012
Messages
518
Réactions
118
Points
11 846
Bonjour je crée cette discussion en espérant régler mon problème, il y a maintenant un jour j'ai décidé de crée un launcher minecraft le problème étant que la je suis bloqué depuis qu'elles heures avec ce problème que je ne comprend pas

Exception in thread "main" java.lang.NullPointerException
at fr.theshark34.openlauncherlib.launcher.util.UsernameSaver.<init>(UsernameSaver.java:66)
at fr.maxmx.LauncherPanel.<init>(
LauncherPanel.java:23)
at fr.maxmx.LauncherFrame.<init>(
LauncherFrame.java:22)
at fr.maxmx.LauncherFrame.main(
LauncherFrame.java:38)

Je vous donne le code des différente class que j'ai

Launcher.java

package fr.maxmx;

import java.io.File;

import fr.theshark34.openlauncherlib.launcher.GameInfos;
import fr.theshark34.openlauncherlib.launcher.GameTweak;
import fr.theshark34.openlauncherlib.launcher.GameType;
import fr.theshark34.openlauncherlib.launcher.GameVersion;

public class Launcher {

public static final GameVersion LC_VERSION = new GameVersion("1.7.10", GameType.V1_7_10);
public static final GameInfos LC_INFOS = new GameInfos("ElypZia", LC_VERSION, true, new GameTweak[] {GameTweak.FORGE});
public static final File LC_DIR = LC_INFOS.getGameDir();
public static final GameInfos SC_INFOS = null;
public static void auth(String text, String string) {
// TODO Auto-generated method stub

}

}

LauncherFrame.java

package fr.maxmx;

import javax.swing.JFrame;

import fr.theshark34.openlauncherlib.launcher.util.WindowMover;
import fr.theshark34.swinger.Swinger;

@SuppressWarnings("serial")
public class LauncherFrame extends JFrame {


private static LauncherFrame instance;
private LauncherPanel launcherPanel;

public LauncherFrame() {
this.setTitle("Elypzia Launcher");
this.setSize(975, 625);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setUndecorated(true);
this.setIconImage(Swinger.getResource("icon.png"));
launcherPanel = new LauncherPanel();
this.setContentPane(launcherPanel);

WindowMover mover = new WindowMover(this);
this.addMouseListener(mover);
this.addMouseMotionListener(mover);


this.setVisible(true);
}

public static void main(String[] args) {
Swinger.setSystemLookNFeel();
Swinger.setResourcePath("/fr/maxmx/resources");


instance = new LauncherFrame();
}

public static LauncherFrame getInstance() {
return instance;
}

public LauncherFrame getLauncherPanel() {
return instance;
}

}

LauncherPanel.java

package fr.maxmx;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import fr.theshark34.openlauncherlib.launcher.util.UsernameSaver;
import fr.theshark34.swinger.Swinger;
import fr.theshark34.swinger.event.SwingerEvent;
import fr.theshark34.swinger.event.SwingerEventListener;
import fr.theshark34.swinger.textured.STexturedButton;

@SuppressWarnings({ "serial", })
public class LauncherPanel extends JPanel implements SwingerEventListener {

private Image background = Swinger.getResource("background.png");

private UsernameSaver saver = new UsernameSaver (Launcher.SC_INFOS);

// private Saver saver = new Saver(new File(Launcher.LC_DIR, "Launcher.properties")); // a garder au cas ou que les autre marche pas

private JTextField usernameField = new JTextField(saver.getUsername(""));
private JPasswordField passwordField = new JPasswordField();

private STexturedButton playButton = new STexturedButton (Swinger.getResource("play.png")); // a faire ( l'image )
private STexturedButton quitButton = new STexturedButton (Swinger.getResource("quit.png")); // a faire ( l'image )
private STexturedButton hideButton = new STexturedButton (Swinger.getResource("hide.png")); // a faire ( l'image )

public LauncherPanel() {
this.setLayout(null);

usernameField.setForeground(Color.WHITE);
usernameField.setFont(usernameField.getFont().deriveFont(20F));
usernameField.setCaretColor(Color.WHITE);
usernameField.setOpaque(false);
usernameField.setBorder(null);
usernameField.setBounds(326, 360, 326, 350); //Pas sur a verifier les coord
this.add(usernameField);


passwordField.setForeground(Color.WHITE);
passwordField.setFont(passwordField.getFont().deriveFont(20F));
passwordField.setCaretColor(Color.WHITE);
passwordField.setOpaque(false);
passwordField.setBorder(null);
passwordField.setBounds(326, 360, 326, 350); //A changer les coord pour ecrire le text Mdp
this.add(passwordField);

playButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(playButton);

quitButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(quitButton);

hideButton.setBounds(562, 464); // fait apparaitre un carré blanc quand on passe la sourise souris //coord a prendre en haut a gauche du bouton
playButton.addEventListener(this);
this.add(hideButton);
}

@Override
public void onEvent (SwingerEvent e) {
if(e.getSource() == playButton) {
System.out.println("Je suis cliqué"); // pour tester le button
} else if(e.getSource() == quitButton)
System.exit(0);
else if (e.getSource() == hideButton)
LauncherFrame.getInstance().setState(JFrame.ICONIFIED);

}

@Override
public void paintComponent (Graphics graphics) {
super.paintComponent(graphics);
drawfullsizedImage(graphics, this, background);

}

private void drawfullsizedImage(Graphics graphics, LauncherPanel launcherPanel, Image background2) {
// TODO Auto-generated method stub

}
}

Voila merci d'avance pour votre aide !
je te conseil d'aller sur ce discord y'a pas mal de dev minecraft
 
Haut