/** * A getter for the high scores list. Reads it directly from file and throws an error if the file * is not found (!working on this!). * * @return Object[][] where [i][0] is the rank (String), [i][1] is the name (String) and [i][2] is * the score (Integer). */ public static Object[][] getHighScore() { if (!new File("HighScores.dat").exists()) { // This object matrix actually stores the information of the high scores list Object[][] highScores = new Object[10][3]; // We fill the high scores list with blank entries: #. " " 0 for (int i = 0; i < highScores.length; i++) { highScores[i][0] = (i + 1) + "."; highScores[i][1] = " "; highScores[i][2] = 0; } // This actually writes and makes the high scores file try { ObjectOutputStream o = new ObjectOutputStream(new FileOutputStream("HighScores.dat")); o.writeObject(highScores); o.close(); } catch (IOException e) { e.printStackTrace(); } } try { // Read and return the read object matrix ObjectInputStream o = new ObjectInputStream(new FileInputStream("HighScores.dat")); Object[][] highScores = (Object[][]) o.readObject(); o.close(); return highScores; } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } return null; }
/** Stop talking to the server */ public void stop() { if (socket != null) { // Close all the streams and socket if (out != null) { try { out.close(); } catch (IOException ioe) { } out = null; } if (in != null) { try { in.close(); } catch (IOException ioe) { } in = null; } if (socket != null) { try { socket.close(); } catch (IOException ioe) { } socket = null; } } else { // Already stopped } // Make sure the right buttons are enabled start_button.setEnabled(true); stop_button.setEnabled(false); setStatus(STATUS_STOPPED); }
// Close crap after chatting private void closeCrap() { showMessage("\n Closing connection... \n "); ableToType(false); try { output.close(); input.close(); connection.close(); } catch (IOException ioException) { ioException.printStackTrace(); } }
// reads the configuration (breakpoints, window sizes and positions...) for the current index private void restoreConfig() { Breakpoints.reset(); Properties.reset(); try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(idxName + ".config")); Breakpoints.restore(in); Properties.restore(in); in.close(); } catch (IOException exc) { // something went wrong - there probably was no .config file // ignore it } }
public void disconnect() { int cmdID = commID++; this.connected = false; try { out.println(cmdID + ";logout"); out.flush(); in.close(); out.close(); socket.close(); } catch (IOException ex) { System.err.println("Server stop failed."); } }
public void windowOpened(WindowEvent e) // read file on start { FileInputStream in = null; ObjectInputStream data = null; try { in = new FileInputStream(DB); data = new ObjectInputStream(in); p = (Person) data.readObject(); while (p != null) { persons.add(p); // store Person object in ArrayList collection p = (Person) data.readObject(); // read the next record } data.close(); } catch (Exception ex) { // IOException will always occur on the last read above } finally { if (persons.size() > 0) displayRecord(); } }
public static void init(GameController gc, Registry r) { int version; registry = r; resolutions = new ArrayList(); resolutions.add("800x600"); resolutions.add("1024x768"); resolutions.add("1152x864"); resolutions.add("1280x720"); resolutions.add("1280x768"); resolutions.add("1280x800"); resolutions.add("1280x960"); resolutions.add("1280x1024"); resolutions.add("1360x768"); resolutions.add("1366x768"); resolutions.add("1440x900"); resolutions.add("1600x900"); resolutions.add("1600x1024"); resolutions.add("1680x1050"); resolutions.add("1920x1080"); resolutions.add("1920x1200"); // resolutions.add("Full Screen"); players = new ArrayList<Player>(); blockManagers = new ArrayList<BlockManager>(); placeableManagers = new ArrayList<PlaceableManager>(); monsterManagers = new ArrayList<MonsterManager>(); // try to load the settings file try { FileInputStream settingsFile = new FileInputStream("Settings.dat"); ObjectInputStream settings = new ObjectInputStream(settingsFile); version = ((Integer) settings.readObject()).intValue(); resolution = ((Integer) settings.readObject()).intValue(); volumeMusic = ((Integer) settings.readObject()).intValue(); volumeFX = ((Integer) settings.readObject()).intValue(); buttonMoveRight = ((Integer) settings.readObject()).intValue(); buttonMoveLeft = ((Integer) settings.readObject()).intValue(); buttonJump = ((Integer) settings.readObject()).intValue(); buttonAction = ((Integer) settings.readObject()).intValue(); buttonRobot = ((Integer) settings.readObject()).intValue(); buttonInventory = ((Integer) settings.readObject()).intValue(); buttonPause = ((Integer) settings.readObject()).intValue(); settings.close(); } catch (Exception e) { EIError.debugMsg(e.getMessage(), EIError.ErrorLevel.Warning); } if (volumeMusic < -1 || volumeMusic > 10) { volumeMusic = 8; } if (volumeMusic == 0) { volumeMusic = 8; } if (volumeMusic == -1) { volumeMusic = 0; } if (volumeFX < -1 || volumeFX > 10) { volumeFX = 8; } if (volumeFX == 0) { volumeFX = 8; } if (volumeFX == -1) { volumeFX = 0; } if (buttonMoveRight == 0) { buttonMoveRight = KeyEvent.VK_D; } if (buttonMoveLeft == 0) { buttonMoveLeft = KeyEvent.VK_A; } if (buttonJump == 0) { buttonJump = KeyEvent.VK_SPACE; } if (buttonAction == 0) { buttonAction = KeyEvent.VK_E; } if (buttonRobot == 0) { buttonRobot = KeyEvent.VK_R; } if (buttonInventory == 0) { buttonInventory = KeyEvent.VK_I; } if (buttonPause == 0) { buttonPause = KeyEvent.VK_P; } // try to load the players for (int i = 1; i <= NUMBER_OF_PLAYER_SLOTS; i++) { try { FileInputStream playerFile = new FileInputStream("Player" + i + ".dat"); ObjectInputStream playerInfo = new ObjectInputStream(playerFile); version = ((Integer) playerInfo.readObject()).intValue(); players.add((Player) playerInfo.readObject()); blockManagers.add((BlockManager) playerInfo.readObject()); placeableManagers.add((PlaceableManager) playerInfo.readObject()); MonsterManager mm = null; if (version >= 2) { mm = (MonsterManager) playerInfo.readObject(); } if (mm == null) { mm = new MonsterManager(gc, r); } monsterManagers.add(mm); playerInfo.close(); EIError.debugMsg("Added Player " + i); } catch (Exception e) { if (players.size() >= i) { players.set(i - 1, null); } else { players.add(null); } if (blockManagers.size() >= i) { blockManagers.set(i - 1, null); } else { blockManagers.add(null); } if (placeableManagers.size() >= i) { placeableManagers.set(i - 1, null); } else { placeableManagers.add(null); } if (monsterManagers.size() >= i) { monsterManagers.set(i - 1, null); } else { monsterManagers.add(null); } EIError.debugMsg( "Couldn't load Player " + i + " " + e.getMessage(), EIError.ErrorLevel.Error); } } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == jbSaveLayer) { try { FileOutputStream fout = new FileOutputStream(jtfCengMing.getText() + ".wyf"); ObjectOutputStream oout = new ObjectOutputStream(fout); oout.writeObject(itemArray); oout.close(); fout.close(); } catch (Exception ea) { ea.printStackTrace(); } } else if (e.getSource() == jbLoadLayer) { try { FileInputStream fin = new FileInputStream(jtfCengMing.getText() + ".wyf"); ObjectInputStream oin = new ObjectInputStream(fin); itemArray = (Item[][]) oin.readObject(); oin.close(); fin.close(); this.flush(); } catch (Exception ea) { ea.printStackTrace(); } lvp.repaint(); } else if (e.getSource() == jbLoadAll) { // 全部铺上当前选中 for (int row = 0; row < 40; row++) { for (int col = 0; col < 60; col++) { Item item = ((Item) (jl.getSelectedValue())).clone(); itemArray[row][col] = item; if (item != null) { item.setPosition(col, row); } } } lvp.repaint(); } else if (e.getSource() == jbCreate) { // 生成源代码 try { FileOutputStream fout = null; DataOutputStream dout = null; fout = new FileOutputStream("maps.so"); dout = new DataOutputStream(fout); int totalBlocks = 0; for (int i = 0; i < 40; i++) { for (int j = 0; j < 60; j++) { Item item = itemArray[i][j]; if (item != null) { totalBlocks++; } } } System.out.println("totalBlocks=" + totalBlocks); // 写入不空块的数量 dout.writeInt(totalBlocks); for (int i = 0; i < 40; i++) { for (int j = 0; j < 60; j++) { Item item = itemArray[i][j]; if (item != null) { int w = item.w; // 元素的图片宽度 int h = item.h; // 元素的图片高度 int col = item.col; // 元素的地图列 int row = item.row; // 元素的地图行 int pCol = item.pCol; // 元素的占位列 int pRow = item.pRow; // 元素的占位行 String leiMing = item.leiMing; // 类名 int[][] notIn = item.notIn; // 不可通过 int[][] keYu = item.keYu; // 可遇矩阵 // 计算图片下标 int outBitmapInxex = 0; if (leiMing.equals("Grass")) { outBitmapInxex = 0; } else if (leiMing.equals("XiaoHua1")) { outBitmapInxex = 1; } else if (leiMing.equals("MuZhuang")) { outBitmapInxex = 2; } else if (leiMing.equals("XiaoHua2")) { outBitmapInxex = 3; } else if (leiMing.equals("Road")) { outBitmapInxex = 4; } else if (leiMing.equals("Jing")) { outBitmapInxex = 5; } dout.writeByte(outBitmapInxex); // 记录图片下标 dout.writeByte(0); // 记录可遇标志 0-不可遇 底层都不可遇 dout.writeByte(w); // 图片宽度 dout.writeByte(h); // 图片高度 dout.writeByte(col); // 总列数 dout.writeByte(row); // 总行数 dout.writeByte(pCol); // 占位列 dout.writeByte(pRow); // 占位行 int bktgCount = notIn.length; // 不可通过点的数量 dout.writeByte(bktgCount); // 写入不可通过点的数量 for (int k = 0; k < bktgCount; k++) { dout.writeByte(notIn[k][0]); dout.writeByte(notIn[k][1]); } } } } dout.close(); fout.close(); } catch (Exception ea) { ea.printStackTrace(); } } }
public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed"); if (e.getSource() == pen) // 画笔 { System.out.println("pen"); toolFlag = 0; } if (e.getSource() == eraser) // 橡皮 { System.out.println("eraser"); toolFlag = 1; } if (e.getSource() == clear) // 清除 { System.out.println("clear"); toolFlag = 2; paintInfo.removeAllElements(); repaint(); } if (e.getSource() == drLine) // 画线 { System.out.println("drLine"); toolFlag = 3; } if (e.getSource() == drCircle) // 画圆 { System.out.println("drCircle"); toolFlag = 4; } if (e.getSource() == drRect) // 画矩形 { System.out.println("drRect"); toolFlag = 5; } if (e.getSource() == colchooser) // 调色板 { System.out.println("colchooser"); Color newColor = JColorChooser.showDialog(this, "我的调色板", c); c = newColor; } if (e.getSource() == openPic) // 打开图画 { openPicture.setVisible(true); if (openPicture.getFile() != null) { int tempflag; tempflag = toolFlag; toolFlag = 2; repaint(); try { paintInfo.removeAllElements(); File filein = new File(openPicture.getDirectory(), openPicture.getFile()); picIn = new FileInputStream(filein); VIn = new ObjectInputStream(picIn); paintInfo = (Vector) VIn.readObject(); VIn.close(); repaint(); toolFlag = tempflag; } catch (ClassNotFoundException IOe2) { repaint(); toolFlag = tempflag; System.out.println("can not read object"); } catch (IOException IOe) { repaint(); toolFlag = tempflag; System.out.println("can not read file"); } } } if (e.getSource() == savePic) // 保存图画 { savePicture.setVisible(true); try { File fileout = new File(savePicture.getDirectory(), savePicture.getFile()); picOut = new FileOutputStream(fileout); VOut = new ObjectOutputStream(picOut); VOut.writeObject(paintInfo); VOut.close(); } catch (IOException IOe) { System.out.println("can not write object"); } } }
public fileBackupProgram(JFrame frame) { super(new BorderLayout()); this.frame = frame; errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this); errorDialog.pack(); moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this); moveDialog.pack(); printer = new FilePrinter(); timers = new ArrayList<>(); log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); Object obj; copy = true; listModel = new DefaultListModel(); // destListModel = new DefaultListModel(); directoryList = new directoryStorage(); // Create a file chooser fc = new JFileChooser(); // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("File"); menu.getAccessibleContext() .setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); editError = new JMenuItem("Save Error Log As..."); editError .getAccessibleContext() .setAccessibleDescription("Change the name of the error log file"); editError.addActionListener(new ErrorListener()); menu.add(editError); editMove = new JMenuItem("Save Move Log As..."); editMove .getAccessibleContext() .setAccessibleDescription("Change the name of the move log file"); editMove.addActionListener(new MoveListener()); menu.add(editMove); exit = new JMenuItem("Exit"); exit.getAccessibleContext().setAccessibleDescription("Exit the Program"); exit.addActionListener(new CloseListener()); menu.add(exit); frame.setJMenuBar(menuBar); // Uncomment one of the following lines to try a different // file selection mode. The first allows just directories // to be selected (and, at least in the Java look and feel, // shown). The second allows both files and directories // to be selected. If you leave these lines commented out, // then the default mode (FILES_ONLY) will be used. // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); openButton = new JButton(openString); openButton.setActionCommand(openString); openButton.addActionListener(new OpenListener()); destButton = new JButton(destString); destButton.setActionCommand(destString); destButton.addActionListener(new DestListener()); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). saveButton = new JButton(saveString); saveButton.setActionCommand(saveString); saveButton.addActionListener(new SaveListener()); URL imageURL = getClass().getResource(greenButtonIcon); ImageIcon greenSquare = new ImageIcon(imageURL); startButton = new JButton("Start", greenSquare); startButton.setSize(60, 20); startButton.setHorizontalTextPosition(AbstractButton.LEADING); startButton.setActionCommand("Start"); startButton.addActionListener(new StartListener()); imageURL = getClass().getResource(redButtonIcon); ImageIcon redSquare = new ImageIcon(imageURL); stopButton = new JButton("Stop", redSquare); stopButton.setSize(60, 20); stopButton.setHorizontalTextPosition(AbstractButton.LEADING); stopButton.setActionCommand("Stop"); stopButton.addActionListener(new StopListener()); copyButton = new JRadioButton("Copy"); copyButton.setActionCommand("Copy"); copyButton.setSelected(true); copyButton.addActionListener(new RadioListener()); moveButton = new JRadioButton("Move"); moveButton.setActionCommand("Move"); moveButton.addActionListener(new RadioListener()); ButtonGroup group = new ButtonGroup(); group.add(copyButton); group.add(moveButton); // For layout purposes, put the buttons in a separate panel JPanel optionPanel = new JPanel(); GroupLayout layout = new GroupLayout(optionPanel); optionPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton)); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(copyButton) .addComponent(moveButton))); JPanel buttonPanel = new JPanel(); // use FlowLayout layout = new GroupLayout(buttonPanel); buttonPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(openButton) .addComponent(optionPanel)) .addComponent(destButton) .addComponent(startButton) .addComponent(stopButton) // .addComponent(saveButton) ); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(openButton) .addComponent(destButton) .addComponent(startButton) .addComponent(stopButton) // .addComponent(saveButton) ) .addComponent(optionPanel)); buttonPanel.add(optionPanel); /* buttonPanel.add(openButton); buttonPanel.add(destButton); buttonPanel.add(startButton); buttonPanel.add(stopButton); buttonPanel.add(saveButton); buttonPanel.add(listLabel); buttonPanel.add(copyButton); buttonPanel.add(moveButton); */ destButton.setEnabled(false); startButton.setEnabled(false); stopButton.setEnabled(false); // Add the buttons and the log to this panel. // add(logScrollPane, BorderLayout.CENTER); JLabel listLabel = new JLabel("Monitored Directory:"); listLabel.setLabelFor(list); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(8); JScrollPane listScrollPane = new JScrollPane(list); JPanel listPane = new JPanel(); listPane.setLayout(new BorderLayout()); listPane.add(listLabel, BorderLayout.PAGE_START); listPane.add(listScrollPane, BorderLayout.CENTER); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); // monitored, destination, waitInt, check destination = new JLabel("Destination Directory: "); waitField = new JFormattedTextField(); // waitField.setValue(240); waitField.setEditable(false); waitField.addPropertyChangeListener(new FormattedTextListener()); waitInt = new JLabel("Wait Interval (in minutes)"); // waitInt.setLabelFor(waitField); checkField = new JFormattedTextField(); checkField.setSize(1, 10); // checkField.setValue(60); checkField.setEditable(false); checkField.addPropertyChangeListener(new FormattedTextListener()); check = new JLabel("Check Interval (in minutes)"); // check.setLabelFor(checkField); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); JPanel fieldPane = new JPanel(); // fieldPane.add(destField); layout = new GroupLayout(fieldPane); fieldPane.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(waitInt) .addComponent(check)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(waitField, 60, 60, 60) .addComponent(checkField, 60, 60, 60))); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(waitInt) .addComponent(waitField)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(check) .addComponent(checkField))); JPanel labelPane = new JPanel(); labelPane.setLayout(new BorderLayout()); labelPane.add(destination, BorderLayout.PAGE_START); labelPane.add(fieldPane, BorderLayout.CENTER); layout = new GroupLayout(labelPane); labelPane.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(destination) .addComponent(fieldPane))); layout.setVerticalGroup( layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane)); // labelPane.add(destination); // labelPane.add(fieldPane); try { // Read from disk using FileInputStream FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data"); // Read object using ObjectInputStream ObjectInputStream obj_in = new ObjectInputStream(f_in); // Read an object directoryList = (directoryStorage) obj_in.readObject(); ERROR_LOG_NAME = (String) obj_in.readObject(); MOVE_LOG_NAME = (String) obj_in.readObject(); if (ERROR_LOG_NAME instanceof String) { printer.changeErrorLogName(ERROR_LOG_NAME); } if (MOVE_LOG_NAME instanceof String) { printer.changeMoveLogName(MOVE_LOG_NAME); } if (directoryList instanceof directoryStorage) { System.out.println("found object"); // directoryList = (directoryStorage) obj; Iterator<Directory> directories = directoryList.getDirectories(); Directory d; while (directories.hasNext()) { d = directories.next(); try { listModel.addElement(d.getDirectory().toRealPath()); } catch (IOException x) { printer.printError(x.toString()); } int index = list.getSelectedIndex(); if (index == -1) { list.setSelectedIndex(0); } index = list.getSelectedIndex(); Directory dir = directoryList.getDirectory(index); destButton.setEnabled(true); checkField.setValue(dir.getInterval()); waitField.setValue(dir.getWaitInterval()); checkField.setEditable(true); waitField.setEditable(true); // directoryList.addNewDirectory(d); // try { // listModel.addElement(d.getDirectory().toString()); // } catch (IOException x) { // printer.printError(x.toString()); // } // timer = new Timer(); // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer, // d.copy), 0, d.getInterval()); } } else { System.out.println("did not find object"); } obj_in.close(); } catch (ClassNotFoundException x) { printer.printError(x.getLocalizedMessage()); System.err.format("Unable to read"); } catch (IOException y) { printer.printError(y.getLocalizedMessage()); } // Layout the text fields in a panel. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(buttonPanel, BorderLayout.PAGE_START); add(listPane, BorderLayout.LINE_START); // add(destListScrollPane, BorderLayout.CENTER); add(fieldPane, BorderLayout.LINE_END); add(labelPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
public void run() { while (connected) { try { Object obj = in.readObject(); if (obj.toString().equals("-101")) { connected = false; in.close(); out.close(); socket.close(); SwingUtilities.invokeLater( new Runnable() { public void run() { Cashier.closee = true; JOptionPane.showMessageDialog( null, "Disconnected from server. Please Restart", "Error:", JOptionPane.PLAIN_MESSAGE); try { m.stop(); } catch (Exception w) { } } }); } else if (obj.toString().split("::")[0].equals("broadcast")) { // System.out.println("braodcast received"); bc.run(obj.toString().substring(obj.toString().indexOf("::") + 2)); } else if (obj.toString().split("::")[0].equals("chat")) { // System.out.println("chat received: // "+obj.toString().substring(obj.toString().indexOf("::")+2)); cc.run(obj.toString().substring(obj.toString().indexOf("::") + 2)); } else if (obj.toString().split("::")[0].equals("rankings")) { String hhh = obj.toString().split("::")[1]; final JDialog jd = new JDialog(); jd.setUndecorated(false); JPanel pan = new JPanel(new BorderLayout()); JLabel ppp = new JLabel(); ppp.setFont(new Font("Arial", Font.BOLD, 20)); ppp.setText( "<html><pre>Thanks for playing !!!<br/>1st: " + hhh.split(":")[0] + "<br/>2nd: " + hhh.split(":")[1] + "<br/>3rd: " + hhh.split(":")[2] + "</pre></html>"); pan.add(ppp, BorderLayout.CENTER); JButton ok = new JButton("Ok"); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jd.setVisible(false); try { m.stop(); } catch (Exception w) { } } }); pan.add(ok, BorderLayout.SOUTH); jd.setContentPane(pan); jd.setModalityType(JDialog.ModalityType.APPLICATION_MODAL); jd.pack(); jd.setLocationRelativeTo(null); jd.setVisible(true); } else if (obj.toString().split("::")[0].equals("rank")) { rc.run(obj.toString().substring(obj.toString().indexOf("::") + 2)); } else { User hhh = null; try { hhh = (User) obj; /*if(usrD==1) { reply=obj; ccl.interrupt(); } else*/ { try { m.ur.changeData((User) obj); } catch (Exception w) { try { maain.ur.changeData((User) obj); } catch (Exception ppp) { ppp.printStackTrace(); } } } } catch (Exception p) { int iid = -1; try { iid = Integer.parseInt(obj.toString()); obj = in.readObject(); if (obj.toString().equals("-102")) { // ccl.interrupt(); SwingUtilities.invokeLater( new Runnable() { public void run() { Cashier.closee = true; JOptionPane.showMessageDialog( null, "Server Not Running.", "Error:", JOptionPane.PLAIN_MESSAGE); } }); } // Thread th = ((Thread)rev.remove(iid)); rev2.put(iid, obj); // System.out.println("Put: "+iid+" : "+obj.toString()+" : // "+Thread.currentThread()); // th.interrupt(); // ccl.interrupt(); } catch (Exception ppp) { /*ppp.printStackTrace();*/ System.out.println( "Shit: " + iid + " : " + obj.toString() + " : " + Thread.currentThread()); } } } try { Thread.sleep(500); } catch (Exception n) { } } catch (Exception m) { } } }