Use spaces instead of tabs

This commit is contained in:
ErdbeerbaerLP 2019-03-30 15:55:55 +01:00
parent d2b4b0f545
commit a0965cc92a
2 changed files with 77 additions and 77 deletions

View File

@ -40,80 +40,80 @@ import de.mas.wiiu.streaming.gui.StreamWindow;
public class Main { public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if(GraphicsEnvironment.isHeadless()) { if(GraphicsEnvironment.isHeadless()) {
System.out.println("This program does not support running in a headless environment!"); System.out.println("This program does not support running in a headless environment!");
System.exit(2); System.exit(2);
}else { }else {
String ip = null; String ip = null;
if(args.length != 0) { if(args.length != 0) {
CommandLineParser parser = new DefaultParser(); CommandLineParser parser = new DefaultParser();
Options options = new Options(); Options options = new Options();
options.addOption("ip", "ip", true, "IP address of your Wii U Console."); options.addOption("ip", "ip", true, "IP address of your Wii U Console.");
CommandLine line = parser.parse(options, args, true);
if (line.hasOption("ip")) { CommandLine line = parser.parse(options, args, true);
ip = line.getOptionValue("ip");
}else {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("streamingTool", options);
System.exit(2);
}
} else{
//Create a JFrame to show the icon in the taskbar if (line.hasOption("ip")) {
final JFrame frame = new JFrame("Wii U Streaming Client - Enter IP..."); ip = line.getOptionValue("ip");
frame.setUndecorated( true ); }else {
frame.setVisible( true ); HelpFormatter formatter = new HelpFormatter();
frame.setLocationRelativeTo( null ); formatter.printHelp("streamingTool", options);
System.exit(2);
}
} else{
//Display the IP Dialog
ip = JOptionPane.showInputDialog(frame, "Please enter the local IP address of your Wii U", "Wii U streaming client", JOptionPane.PLAIN_MESSAGE);
//Check if user clicked "Cancel"
if(ip == null) {
System.out.println("Cancelled. Exiting program");
frame.dispose();
System.exit(0);
}
//Close the JFrame again
frame.dispose();
}
try { //Create a JFrame to show the icon in the taskbar
new Main(ip); final JFrame frame = new JFrame("Wii U Streaming Client - Enter IP...");
} catch (BindException e) { frame.setUndecorated( true );
//Create a JFrame to show the icon in the taskbar frame.setVisible( true );
final JFrame frame = new JFrame("Wii U Streaming Client - "+e.getClass().getName()); frame.setLocationRelativeTo( null );
frame.setUndecorated( true );
frame.setVisible( true );
frame.setLocationRelativeTo( null );
//Display the Message //Display the IP Dialog
JOptionPane.showMessageDialog(frame, "Can't bind socket. The client is probably already running.", e.getClass().getName(), ip = JOptionPane.showInputDialog(frame, "Please enter the local IP address of your Wii U", "Wii U streaming client", JOptionPane.PLAIN_MESSAGE);
JOptionPane.WARNING_MESSAGE);
//Close the JFrame again
frame.dispose();
System.exit(-1); //Check if user clicked "Cancel"
} if(ip == null) {
} System.out.println("Cancelled. Exiting program");
} frame.dispose();
System.exit(0);
}
//Close the JFrame again
frame.dispose();
public Main(String ip) throws SocketException { }
ImageStreamer imageStreamer = new ImageStreamer(ip);
SwingUtilities.invokeLater(new Runnable() { try {
public void run() { new Main(ip);
new StreamWindow(imageStreamer.getImageProvider()); } catch (BindException e) {
} //Create a JFrame to show the icon in the taskbar
}); final JFrame frame = new JFrame("Wii U Streaming Client - "+e.getClass().getName());
} frame.setUndecorated( true );
frame.setVisible( true );
frame.setLocationRelativeTo( null );
//Display the Message
JOptionPane.showMessageDialog(frame, "Can't bind socket. The client is probably already running.", e.getClass().getName(),
JOptionPane.WARNING_MESSAGE);
//Close the JFrame again
frame.dispose();
System.exit(-1);
}
}
}
public Main(String ip) throws SocketException {
ImageStreamer imageStreamer = new ImageStreamer(ip);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new StreamWindow(imageStreamer.getImageProvider());
}
});
}
} }

View File

@ -34,11 +34,11 @@ import javax.swing.JMenuItem;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
public class StreamWindow { public class StreamWindow {
private final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); private final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private final ImagePanel image = new ImagePanel(screenSize.width-15, screenSize.height-100); private final ImagePanel image = new ImagePanel(screenSize.width-15, screenSize.height-100);
public StreamWindow(IImageProvider imageProvider) { public StreamWindow(IImageProvider imageProvider) {
JFrame editorFrame = new JFrame("Wii U Streaming Client"); JFrame editorFrame = new JFrame("Wii U Streaming Client");
editorFrame.setMaximumSize(screenSize); editorFrame.setMaximumSize(screenSize);
@ -46,27 +46,27 @@ public class StreamWindow {
imageProvider.setOnImageChange((bi) -> image.setImage(bi)); imageProvider.setOnImageChange((bi) -> image.setImage(bi));
editorFrame.getContentPane().add(image); editorFrame.getContentPane().add(image);
JMenuBar menuBar = new JMenuBar(); JMenuBar menuBar = new JMenuBar();
editorFrame.getContentPane().add(menuBar, BorderLayout.NORTH); editorFrame.getContentPane().add(menuBar, BorderLayout.NORTH);
JMenu mnSettings = new JMenu("Settings"); JMenu mnSettings = new JMenu("Settings");
menuBar.add(mnSettings); menuBar.add(mnSettings);
JMenuItem mntmNewMenuItem = new JMenuItem("Config (Not implemented!)"); JMenuItem mntmNewMenuItem = new JMenuItem("Config (Not implemented!)");
mntmNewMenuItem.addActionListener(new ActionListener() { mntmNewMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
//TODO Add program config //TODO Add program config
} }
}); });
JMenuItem mntmExit = new JMenuItem("Exit"); JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.addActionListener(new ActionListener() { mntmExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
System.exit(0); System.exit(0);
} }
}); });
mntmNewMenuItem.setEnabled(false); mntmNewMenuItem.setEnabled(false);
mnSettings.add(mntmNewMenuItem); mnSettings.add(mntmNewMenuItem);
mnSettings.add(mntmExit); mnSettings.add(mntmExit);