Update target back to 1.6.

This commit is contained in:
Favyen Bastani
2018-11-26 15:59:34 -05:00
parent 0422de7d66
commit 5db7131e24
3 changed files with 46 additions and 30 deletions

View File

@@ -1,2 +1,2 @@
rm cls/connect2/*.class
javac -source 1.8 -target 1.8 -classpath src -d cls src/connect2/Main.java && java -classpath cls connect2.Main
javac -source 1.6 -target 1.6 -classpath src -d cls src/connect2/Main.java && java -classpath cls connect2.Main

View File

@@ -2,7 +2,6 @@ package connect2;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -66,7 +65,12 @@ public class ECUtil {
}
public static byte[] strToBytes(String str) {
return str.getBytes(StandardCharsets.UTF_8);
try {
return str.getBytes("UTF-8");
} catch(UnsupportedEncodingException uee) {
System.out.println("[ECUtil] UTF-8 is an unsupported encoding: " + uee.getLocalizedMessage());
return str.getBytes();
}
}
public static byte[] encodeStatString(byte[] data)

View File

@@ -2,37 +2,49 @@ package connect2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
public class GuiApp {
public GuiApp(){
JFrame frame = new JFrame("WC3Connect-Java");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton launch = new JButton("Launch");
JButton exit = new JButton("Exit");
launch.setFont(new Font("Arial", Font.PLAIN, 30));
exit.setFont(new Font("Arial", Font.PLAIN, 30));
launch.addActionListener(e -> this.launch());
exit.addActionListener(e -> System.exit(0));
public class GuiApp implements ActionListener {
JButton launchBtn, exitBtn;
if(!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)){
launch.setEnabled(false);
launch.setText("Open your webbrowser and go to: 127.0.0.1:8033");
}
public GuiApp(){
JFrame frame = new JFrame("WC3Connect-Java");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.launchBtn = new JButton("Launch");
this.exitBtn = new JButton("Exit");
this.launchBtn.setFont(new Font("Arial", Font.PLAIN, 30));
this.exitBtn.setFont(new Font("Arial", Font.PLAIN, 30));
this.launchBtn.addActionListener(this);
this.exitBtn.addActionListener(this);
frame.getContentPane().add(launch, BorderLayout.PAGE_START);
frame.getContentPane().add(exit, BorderLayout.PAGE_END);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
if(!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)){
this.launchBtn.setEnabled(false);
this.launchBtn.setText("Open your webbrowser and go to: 127.0.0.1:8033");
}
private void launch(){
try {
Desktop.getDesktop().browse(URI.create("http://127.0.0.1:8333"));
} catch (IOException e1) {
e1.printStackTrace();
}
}
frame.getContentPane().add(this.launchBtn, BorderLayout.PAGE_START);
frame.getContentPane().add(this.exitBtn, BorderLayout.PAGE_END);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private void launch(){
try {
Desktop.getDesktop().browse(URI.create("http://127.0.0.1:8333"));
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == this.launchBtn) {
this.launch();
} else if(e.getSource() == this.exitBtn) {
System.exit(0);
}
}
}