launcher Probleme Launcher



  • Bonjour à tous je suis en train de développer un launcher pour un serveur pvp faction mais j'ai une erreur que je n'arrive pas à régler.

    package fr.prutix.lagalauncher;
    
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.io.File;
    import java.io.IOException;
    
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;
    
    import fr.theshark34.openauth.AuthenticationException;
    import fr.theshark34.openlauncherlib.LaunchException;
    import fr.theshark34.openlauncherlib.util.Saver;
    import fr.theshark34.swinger.Swinger;
    import fr.theshark34.swinger.animation.Animator;
    import fr.theshark34.swinger.colored.SColoredBar;
    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 Saver saver = new Saver(new File(Launcher.LG_DIR, "launcher.properties"));
    	
    	private JTextField usernameField = new JTextField(this.saver.get("username"));
    	private JPasswordField passwordField = new JPasswordField();
    	
    	private STexturedButton playButton = new STexturedButton(Swinger.getResource("play.png"));
    	private STexturedButton quitButton = new STexturedButton(Swinger.getResource("quit.png"));
    	private STexturedButton hideButton = new STexturedButton(Swinger.getResource("hide.png"));
    	
    	private SColoredBar progressBar = new SColoredBar(new Color(255, 255, 255, 175), new Color(255, 255, 255, 255));
    	private JLabel infoLabel = new JLabel("Cliquez sur Se Connecter !", SwingConstants.CENTER);
    	
    
    	public LauncherPanel()
    	{
    		this.setLayout(null);
    		
    		usernameField.setForeground(Color.BLACK);
    		usernameField.setFont(usernameField.getFont().deriveFont(20.0F));
    		usernameField.setCaretColor(Color.BLACK);
    		usernameField.setOpaque(false);
    		usernameField.setBorder(null);
    		usernameField.setBounds(85, 110, 253, 34);
    		this.add(usernameField);
    		
    		passwordField.setForeground(Color.BLACK);
    		passwordField.setFont(usernameField.getFont());
    		passwordField.setCaretColor(Color.BLACK);
    		passwordField.setOpaque(false);
    		passwordField.setBorder(null);
    		passwordField.setBounds(85, 262, 253, 34);
    		this.add(passwordField);
    		
    		playButton.setBounds(86, 330);
    		playButton.addEventListener(this);
    		this.add(playButton);
    		
    		quitButton.setBounds(911, 0);
    		quitButton.addEventListener(this);
    		this.add(quitButton);
    		
    		hideButton.setBounds(850, 0);
    		hideButton.addEventListener(this);
    		this.add(hideButton);
    
    		
    		progressBar.setBounds(8, 597, 959, 20);
    		this.add(progressBar);
    		
    		infoLabel.setForeground(Color.WHITE);
    		infoLabel.setFont(usernameField.getFont());
    		infoLabel.setBounds(8, 570, 959, 20);
    		this.add(infoLabel);
    	}
    	
    	@SuppressWarnings("deprecation")
    	@Override
    	public void onEvent(SwingerEvent e)
    	{
    		if(e.getSource() == playButton)
    		{
    			setFieldsEnabled(false);
    			
    			if(usernameField.getText().replaceAll(" ", "").length() == 0 || passwordField.getText().length() == 0)
    			{
    				JOptionPane.showMessageDialog(this, "Erreur, veuillez entrer un pseudo et un mot de passe valide.", "Erreur", JOptionPane.ERROR_MESSAGE);
    				setFieldsEnabled(true);
    				return;
    			}
    			
    			Thread t = new Thread() 
    			{
    				@Override
    				public void run()
    				{
    					try
    					{
    						Launcher.auth(usernameField.getText(), passwordField.getText());
    					}catch(AuthenticationException e)
    					
    					{
    						JOptionPane.showMessageDialog(LauncherPanel.this, "Erreur, impossible de se connecter. " + e.getErrorModel().getErrorMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
    						setFieldsEnabled(true);
    						return;
    					}
    					
    					saver.set("username", usernameField.getText());
    					try
    					{
    						Launcher.update();
    					}
    					catch(IOException e)
    					{
    						Launcher.interruptThread();
    						Launcher.getCrashReporter().catchError(e, "Impossible de mettre a jour le launcher");
    						setFieldsEnabled(true);
    						return;
    					}
    					try
    					{
    						Launcher.launch();
    					}
    					catch(LaunchException e)
    					{
    						Launcher.getCrashReporter().catchError(e, "Impossible de");
    						setFieldsEnabled(true);
    						return;
    					}
    					
    				}
    				
    			};
    			t.start();
    		} else if(e.getSource() == quitButton)
    			Animator.fadeOutFrame(LauncherFrame.getInstance(), 2, new Runnable() {
    				
    				@Override
    				public void run() {
    					System.exit(0);
    					}
    			});
    		else if(e.getSource() == hideButton)
    			LauncherFrame.getInstance().setState(JFrame.ICONIFIED);
    			
    	}
    	
    	@Override
    	public void paintComponent(Graphics g)
    	{
    		super.paintComponent(g);
    		
    		g.drawImage(background, 0, 0, this.getWidth(), this.getHeight(), this);
    	}
    	
    	private void setFieldsEnabled(boolean enabled)
    	{
    		usernameField.setEnabled(enabled);
    		passwordField.setEnabled(enabled);
    		playButton.setEnabled(enabled);
    	}
    	
    	public SColoredBar getProgressBar()
    	{
    		return progressBar;
    	}
    	
    	public void setInfoText(String text)
    	{
    		infoLabel.setText(text);
    	}
    }
    

    Ceci est ma class Launcher Panel, il y a une erreur au niveau de Launcher.update().


  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonjour,
    J'ai déplacé la demande d'aide dans la bonne section.
    Pour obtenir de l'aide il serait également bien de détailler le problème.


Log in to reply