// --------------------------------actionConnect------------------------------ private void actionConnect() { if (oParty == null) { JOptionPane.showMessageDialog(frame, "Make a party before trying to connect."); return; } String[] oResults = (String[]) DialogManager.show(DialogManager.CONNECT, frame); if (oResults[DialogManager.RETURN_IP].equals("cancel")) return; lblStatus3.setText("Connecting..."); try { oConn.connect( oResults[DialogManager.RETURN_IP], Integer.parseInt(oResults[DialogManager.RETURN_PORT])); } catch (UnknownHostException e) { JOptionPane.showMessageDialog( frame, "The IP of the host cannot be determined.", "Unknown Host Exception", JOptionPane.ERROR_MESSAGE); frame.repaint(); return; } catch (IOException e) { JOptionPane.showMessageDialog( frame, e.getMessage(), "Input/Output Exception", JOptionPane.ERROR_MESSAGE); frame.repaint(); return; } echo("Connected to opponent!"); tConn = new Thread(oConn, "conn"); tConn.start(); tMain = new Thread(this, "main"); tMain.start(); }
// --------------------------------actionHost--------------------------------- private void actionHost() { if (oParty == null) { JOptionPane.showMessageDialog(frame, "Make a party before trying to connect."); return; } JFileChooser oFC = new JFileChooser(DEFAULT_MAP_DIRECTORY); int nReturn = oFC.showOpenDialog(frame); if (nReturn == JFileChooser.CANCEL_OPTION) { return; } int nPort = Integer.parseInt((String) (DialogManager.show(DialogManager.HOST, frame))); JDialog dlgBox = (JDialog) (DialogManager.show(DialogManager.WAITING_FOR_CONN, frame)); dlgBox.pack(); try { oConn.host(nPort); } catch (IOException e) { JOptionPane.showMessageDialog(frame, e.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE); frame.repaint(); return; } dlgBox.setVisible(false); echo("Connected to opponent!"); tConn = new Thread(oConn, "conn"); tConn.start(); tMain = new Thread(this, "main"); tMain.start(); try { oMap.loadMap(oFC.getSelectedFile()); oConn.send("loadmap", oFC.getName(oFC.getSelectedFile())); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } }
public void eventDispatched(AWTEvent event) { if (!isAssertTrigger(event)) { return; } MouseEvent mouse = (MouseEvent) event; GuiComponent guiComponent = factory.find(mouse); if (guiComponent == null) { return; } assertContext.setGuiComponent(guiComponent); assertContext.setPoint(mouse.getPoint()); JPopupMenu menu = dialogManager.newPopupMenu(); for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) { AbstractAssert assertAction = (AbstractAssert) iterator.next(); String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID); ActionViewUtil.connectActionTo(assertAction, menu.add(actionId)); assertAction.update(); if (!guiComponent.isFindable() && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) { assertAction.setEnabled(false); } } menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5)); menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY()); }
@Override public void endEvent() { DialogManager.endDialog(); }
@Override public void progressEvent() { DialogManager.progressDialog(); }