Advertisement
Guest User

Game Profile Selector

a guest
Apr 15th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.63 KB | None | 0 0
  1.  
  2. import java.io.BufferedReader;
  3. import java.io.BufferedWriter;
  4. import java.io.File;
  5. import java.io.FileReader;
  6. import java.io.FileWriter;
  7. import java.io.IOException;
  8. import java.io.StringWriter;
  9. import java.net.URL;
  10. import java.util.logging.Level;
  11. import java.util.logging.Logger;
  12. import javax.swing.JOptionPane;
  13.  
  14. /*
  15. * To change this license header, choose License Headers in Project Properties.
  16. * To change this template file, choose Tools | Templates
  17. * and open the template in the editor.
  18. */
  19.  
  20. /**
  21. *
  22. * @author clement
  23. */
  24. public class SelectorForm extends javax.swing.JFrame {
  25. private static StringWriter sw;
  26. private static BufferedWriter bw;
  27. private static FileWriter fw;
  28. private static FileReader fr;
  29. static String[] Read = new String[9];
  30. static String[] ReadNames = new String[9];
  31. static String CurrentAccount = "none";
  32.  
  33. public static void main(String args[]) throws Exception
  34. {
  35.  
  36. //Checks the files current Directory
  37. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  38. System.out.println(location.getFile()+"Accounts.ini");
  39. String Dir = location.getFile().toString();
  40. //Replaces the %20 with a " ".
  41. String NewDir = Dir.replaceAll("%20"," ");
  42. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  43. //Checks if the file exists
  44. File f = new File(NewDir2+"Accounts.ini");
  45.  
  46. if(f.exists())
  47. {
  48.  
  49.  
  50.  
  51.  
  52. // read the file and load the accounts
  53. System.out.println("True");
  54. File file = new File(NewDir2+"Accounts.ini");
  55. fr = new FileReader(file);
  56. BufferedReader br = new BufferedReader(fr);
  57. int i = 0;
  58.  
  59. while(i<8)
  60. {
  61. i = i+1;
  62. Read[i] = br.readLine();
  63. System.out.println(Read[i]);
  64. }
  65.  
  66. i = 0;
  67. while(i<8)
  68. {
  69. i = i+1;
  70.  
  71. int indexpass = Read[i].indexOf("/");
  72. System.out.println(indexpass);
  73. ReadNames[i] = Read[i].substring(4, indexpass);
  74.  
  75. }
  76.  
  77.  
  78.  
  79. }
  80. else
  81. {
  82. System.out.println("False");
  83. // Create file and load defaults
  84. File file = new File(NewDir2+"Accounts.ini");
  85. file.createNewFile();
  86.  
  87. fw = new FileWriter(file);
  88. BufferedWriter bw = new BufferedWriter(fw);
  89.  
  90. int n = 1;
  91. while(n<9)
  92. {
  93. bw.write("AC"+n+"=new/Pass");
  94. bw.newLine();
  95. n = n+1;
  96. }
  97. bw.close();
  98.  
  99. }
  100.  
  101.  
  102.  
  103. /* Set the Nimbus look and feel */
  104. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  105. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  106. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  107. */
  108. try {
  109. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  110. if ("Nimbus".equals(info.getName())) {
  111. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  112. break;
  113. }
  114. }
  115. } catch (ClassNotFoundException ex) {
  116. java.util.logging.Logger.getLogger(SelectorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  117. } catch (InstantiationException ex) {
  118. java.util.logging.Logger.getLogger(SelectorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  119. } catch (IllegalAccessException ex) {
  120. java.util.logging.Logger.getLogger(SelectorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  121. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  122. java.util.logging.Logger.getLogger(SelectorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  123. }
  124. //</editor-fold>
  125.  
  126. /* Create and display the form */
  127. java.awt.EventQueue.invokeLater(new Runnable() {
  128. @Override
  129. public void run() {
  130. new SelectorForm().setVisible(true);
  131. }
  132. });
  133. }
  134.  
  135. /**
  136. * Creates new form SelectorForm
  137. */
  138. public SelectorForm() {
  139. initComponents();
  140. }
  141.  
  142. /**
  143. * This method is called from within the constructor to initialize the form.
  144. * WARNING: Do NOT modify this code. The content of this method is always
  145. * regenerated by the Form Editor.
  146. */
  147. @SuppressWarnings("unchecked")
  148. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  149. private void initComponents() {
  150.  
  151. jButton4 = new javax.swing.JButton();
  152. jPanel1 = new javax.swing.JPanel();
  153. jButton10 = new javax.swing.JButton();
  154. jButton1 = new javax.swing.JButton();
  155. CurrentAcc = new javax.swing.JLabel();
  156. jButton2 = new javax.swing.JButton();
  157. jButton3 = new javax.swing.JButton();
  158. jButton5 = new javax.swing.JButton();
  159. jButton6 = new javax.swing.JButton();
  160. jButton7 = new javax.swing.JButton();
  161. jButton8 = new javax.swing.JButton();
  162. jButton9 = new javax.swing.JButton();
  163. jButton11 = new javax.swing.JButton();
  164. jLabel1 = new javax.swing.JLabel();
  165. jLabel2 = new javax.swing.JLabel();
  166.  
  167. jButton4.setText("jButton3");
  168.  
  169. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  170. jPanel1.setLayout(jPanel1Layout);
  171. jPanel1Layout.setHorizontalGroup(
  172. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  173. .addGap(0, 100, Short.MAX_VALUE)
  174. );
  175. jPanel1Layout.setVerticalGroup(
  176. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  177. .addGap(0, 100, Short.MAX_VALUE)
  178. );
  179.  
  180. jButton10.setText("jButton10");
  181.  
  182. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  183.  
  184. jButton1.setText("Play!");
  185. jButton1.addActionListener(new java.awt.event.ActionListener() {
  186. public void actionPerformed(java.awt.event.ActionEvent evt) {
  187. jButton1ActionPerformed(evt);
  188. }
  189. });
  190.  
  191. CurrentAcc.setText("Current Account:");
  192.  
  193. jButton2.setText(ReadNames[1]);
  194. jButton2.addActionListener(new java.awt.event.ActionListener() {
  195. public void actionPerformed(java.awt.event.ActionEvent evt) {
  196. jButton2ActionPerformed(evt);
  197. }
  198. });
  199.  
  200. jButton3.setText(ReadNames[2]);
  201. jButton3.addActionListener(new java.awt.event.ActionListener() {
  202. public void actionPerformed(java.awt.event.ActionEvent evt) {
  203. jButton3ActionPerformed(evt);
  204. }
  205. });
  206.  
  207. jButton5.setText(ReadNames[3]);
  208. jButton5.addActionListener(new java.awt.event.ActionListener() {
  209. public void actionPerformed(java.awt.event.ActionEvent evt) {
  210. jButton5ActionPerformed(evt);
  211. }
  212. });
  213.  
  214. jButton6.setText(ReadNames[4]);
  215. jButton6.addActionListener(new java.awt.event.ActionListener() {
  216. public void actionPerformed(java.awt.event.ActionEvent evt) {
  217. jButton6ActionPerformed(evt);
  218. }
  219. });
  220.  
  221. jButton7.setText(ReadNames[5]);
  222. jButton7.addActionListener(new java.awt.event.ActionListener() {
  223. public void actionPerformed(java.awt.event.ActionEvent evt) {
  224. jButton7ActionPerformed(evt);
  225. }
  226. });
  227.  
  228. jButton8.setText(ReadNames[6]);
  229. jButton8.addActionListener(new java.awt.event.ActionListener() {
  230. public void actionPerformed(java.awt.event.ActionEvent evt) {
  231. jButton8ActionPerformed(evt);
  232. }
  233. });
  234.  
  235. jButton9.setText(ReadNames[7]);
  236. jButton9.addActionListener(new java.awt.event.ActionListener() {
  237. public void actionPerformed(java.awt.event.ActionEvent evt) {
  238. jButton9ActionPerformed(evt);
  239. }
  240. });
  241.  
  242. jButton11.setText(ReadNames[8]);
  243. jButton11.addActionListener(new java.awt.event.ActionListener() {
  244. public void actionPerformed(java.awt.event.ActionEvent evt) {
  245. jButton11ActionPerformed(evt);
  246. }
  247. });
  248.  
  249. jLabel1.setText("Archlord Account sellecter v1");
  250.  
  251. jLabel2.setText("Clement Kirton");
  252.  
  253. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  254. getContentPane().setLayout(layout);
  255. layout.setHorizontalGroup(
  256. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  257. .addGroup(layout.createSequentialGroup()
  258. .addContainerGap()
  259. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  260. .addGroup(layout.createSequentialGroup()
  261. .addComponent(CurrentAcc, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
  262. .addGap(18, 18, 18)
  263. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
  264. .addGroup(layout.createSequentialGroup()
  265. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  266. .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  267. .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
  268. .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  269. .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  270. .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  271. .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  272. .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  273. .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  274. .addGap(81, 81, 81)
  275. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  276. .addComponent(jLabel1)
  277. .addComponent(jLabel2))
  278. .addGap(0, 0, Short.MAX_VALUE)))
  279. .addContainerGap())
  280. );
  281. layout.setVerticalGroup(
  282. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  283. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  284. .addContainerGap()
  285. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  286. .addComponent(jButton2)
  287. .addGroup(layout.createSequentialGroup()
  288. .addGap(4, 4, 4)
  289. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  290. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  291. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  292. .addGroup(layout.createSequentialGroup()
  293. .addComponent(jButton3)
  294. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  295. .addGroup(layout.createSequentialGroup()
  296. .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  297. .addGap(20, 20, 20)))
  298. .addComponent(jButton5)
  299. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  300. .addComponent(jButton6)
  301. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  302. .addComponent(jButton7)
  303. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  304. .addComponent(jButton8)
  305. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  306. .addComponent(jButton9)
  307. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  308. .addComponent(jButton11)
  309. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  310. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  311. .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
  312. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  313. .addComponent(CurrentAcc, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
  314. .addGap(15, 15, 15)))
  315. .addContainerGap())
  316. );
  317.  
  318. pack();
  319. }// </editor-fold>
  320.  
  321. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  322. try {
  323. Runtime runtime = Runtime.getRuntime();
  324. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  325. String Dir = location.getFile().toString();
  326. //Replaces the %20 with a " ".
  327. String NewDir = Dir.replaceAll("%20"," ");
  328.  
  329. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  330. Runtime.getRuntime().exec(NewDir2+"JUSTArchlord.exe");
  331. } catch (IOException ex) {
  332. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  333. }
  334.  
  335.  
  336. }
  337.  
  338. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  339. if(ReadNames[1].equals("new"))
  340. {
  341. try {
  342. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  343. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  344. String Temp = Read[1];
  345. Read[1] = Temp.replaceAll("new", NewAccount);
  346. String Temp2 = Read[1];
  347. Read[1] = Temp2.replaceAll("Pass", NewPass);
  348.  
  349.  
  350. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  351. String Dir = location.getFile().toString();
  352. //Replaces the %20 with a " ".
  353. String NewDir = Dir.replaceAll("%20"," ");
  354. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  355. //Checks if the file exists
  356. File f = new File(NewDir2+"Accounts.ini");
  357.  
  358.  
  359. fw = new FileWriter(f);
  360. BufferedWriter bw = new BufferedWriter(fw);
  361.  
  362.  
  363. int n = 1;
  364. while(n<9)
  365. {
  366. bw.write(Read[n]);
  367. bw.newLine();
  368. n = n+1;
  369. }
  370. bw.close();
  371. } catch (IOException ex) {
  372. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  373. }
  374.  
  375. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  376. }
  377. else
  378. {
  379. try {
  380. CurrentAcc.setText("Current Account: "+ReadNames[1]);
  381. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  382. int indexpass2 = Read[1].indexOf("/");
  383. String Pass = Read[1].substring(indexpass2+1);
  384.  
  385.  
  386. String Dir = location.getFile().toString();
  387. //Replaces the %20 with a " ".
  388. String NewDir = Dir.replaceAll("%20"," ");
  389. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  390. //Checks if the file exists
  391. File f = new File(NewDir2+"Justaccount.ini");
  392. f.createNewFile();
  393. fw = new FileWriter(f);
  394. BufferedWriter bw2 = new BufferedWriter(fw);
  395.  
  396. bw2.write("[INFO]");
  397. bw2.newLine();
  398. bw2.write("account="+ReadNames[1]);
  399. bw2.newLine();
  400. bw2.write("password="+Pass);
  401. bw2.close();
  402.  
  403. } catch (IOException ex) {
  404. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  405. }
  406. }
  407.  
  408. }
  409.  
  410. private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
  411. if(ReadNames[5].equals("new"))
  412. {
  413. try {
  414. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  415. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  416. String Temp = Read[5];
  417. Read[5] = Temp.replaceAll("new", NewAccount);
  418. String Temp2 = Read[5];
  419. Read[5] = Temp2.replaceAll("Pass", NewPass);
  420.  
  421.  
  422. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  423. String Dir = location.getFile().toString();
  424. //Replaces the %20 with a " ".
  425. String NewDir = Dir.replaceAll("%20"," ");
  426. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  427. //Checks if the file exists
  428. File f = new File(NewDir2+"Accounts.ini");
  429.  
  430.  
  431. fw = new FileWriter(f);
  432. BufferedWriter bw = new BufferedWriter(fw);
  433.  
  434.  
  435. int n = 1;
  436. while(n<9)
  437. {
  438. bw.write(Read[n]);
  439. bw.newLine();
  440. n = n+1;
  441. }
  442. bw.close();
  443. } catch (IOException ex) {
  444. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  445. }
  446.  
  447. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  448. }
  449. else
  450. {
  451. try {
  452. CurrentAcc.setText("Current Account: "+ReadNames[5]);
  453. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  454. int indexpass2 = Read[5].indexOf("/");
  455. String Pass = Read[5].substring(indexpass2+1);
  456.  
  457.  
  458. String Dir = location.getFile().toString();
  459. //Replaces the %20 with a " ".
  460. String NewDir = Dir.replaceAll("%20"," ");
  461. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  462. //Checks if the file exists
  463. File f = new File(NewDir2+"Justaccount.ini");
  464. f.createNewFile();
  465. fw = new FileWriter(f);
  466. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  467. bw2.write("[INFO]");
  468. bw2.newLine();
  469. bw2.write("account="+ReadNames[5]);
  470. bw2.newLine();
  471. bw2.write("password="+Pass);
  472. }
  473.  
  474. } catch (IOException ex) {
  475. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  476. }
  477. } // TODO add your handling code here:
  478. }
  479.  
  480. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
  481. if(ReadNames[2].equals("new"))
  482. {
  483. try {
  484. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  485. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  486. String Temp = Read[2];
  487. Read[2] = Temp.replaceAll("new", NewAccount);
  488. String Temp2 = Read[2];
  489. Read[2] = Temp2.replaceAll("Pass", NewPass);
  490.  
  491.  
  492. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  493. String Dir = location.getFile().toString();
  494. //Replaces the %20 with a " ".
  495. String NewDir = Dir.replaceAll("%20"," ");
  496. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  497. //Checks if the file exists
  498. File f = new File(NewDir2+"Accounts.ini");
  499.  
  500.  
  501. fw = new FileWriter(f);
  502. BufferedWriter bw = new BufferedWriter(fw);
  503.  
  504.  
  505. int n = 1;
  506. while(n<9)
  507. {
  508. bw.write(Read[n]);
  509. bw.newLine();
  510. n = n+1;
  511. }
  512. bw.close();
  513. } catch (IOException ex) {
  514. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  515. }
  516.  
  517. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  518. }
  519. else
  520. {
  521. try {
  522. CurrentAcc.setText("Current Account: "+ReadNames[2]);
  523. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  524. int indexpass2 = Read[2].indexOf("/");
  525. String Pass = Read[2].substring(indexpass2+1);
  526.  
  527.  
  528. String Dir = location.getFile().toString();
  529. //Replaces the %20 with a " ".
  530. String NewDir = Dir.replaceAll("%20"," ");
  531. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  532. //Checks if the file exists
  533. File f = new File(NewDir2+"Justaccount.ini");
  534. f.createNewFile();
  535. fw = new FileWriter(f);
  536. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  537. bw2.write("[INFO]");
  538. bw2.newLine();
  539. bw2.write("account="+ReadNames[2]);
  540. bw2.newLine();
  541. bw2.write("password="+Pass);
  542. }
  543.  
  544. } catch (IOException ex) {
  545. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  546. }
  547. } // TODO add your handling code here:
  548. }
  549.  
  550. private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
  551. if(ReadNames[3].equals("new"))
  552. {
  553. try {
  554. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  555. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  556. String Temp = Read[3];
  557. Read[3] = Temp.replaceAll("new", NewAccount);
  558. String Temp2 = Read[3];
  559. Read[3] = Temp2.replaceAll("Pass", NewPass);
  560.  
  561.  
  562. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  563. String Dir = location.getFile().toString();
  564. //Replaces the %20 with a " ".
  565. String NewDir = Dir.replaceAll("%20"," ");
  566. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  567. //Checks if the file exists
  568. File f = new File(NewDir2+"Accounts.ini");
  569.  
  570.  
  571. fw = new FileWriter(f);
  572. BufferedWriter bw = new BufferedWriter(fw);
  573.  
  574.  
  575. int n = 1;
  576. while(n<9)
  577. {
  578. bw.write(Read[n]);
  579. bw.newLine();
  580. n = n+1;
  581. }
  582. bw.close();
  583. } catch (IOException ex) {
  584. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  585. }
  586.  
  587. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  588. }
  589. else
  590. {
  591. try {
  592. CurrentAcc.setText("Current Account: "+ReadNames[3]);
  593. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  594. int indexpass2 = Read[3].indexOf("/");
  595. String Pass = Read[3].substring(indexpass2+1);
  596.  
  597.  
  598. String Dir = location.getFile().toString();
  599. //Replaces the %20 with a " ".
  600. String NewDir = Dir.replaceAll("%20"," ");
  601. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  602. //Checks if the file exists
  603. File f = new File(NewDir2+"Justaccount.ini");
  604. f.createNewFile();
  605. fw = new FileWriter(f);
  606. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  607. bw2.write("[INFO]");
  608. bw2.newLine();
  609. bw2.write("account="+ReadNames[3]);
  610. bw2.newLine();
  611. bw2.write("password="+Pass);
  612. }
  613.  
  614. } catch (IOException ex) {
  615. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  616. }
  617. } // TODO add your handling code here:
  618. }
  619.  
  620. private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
  621. if(ReadNames[4].equals("new"))
  622. {
  623. try {
  624. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  625. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  626. String Temp = Read[4];
  627. Read[4] = Temp.replaceAll("new", NewAccount);
  628. String Temp2 = Read[4];
  629. Read[4] = Temp2.replaceAll("Pass", NewPass);
  630.  
  631.  
  632. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  633. String Dir = location.getFile().toString();
  634. //Replaces the %20 with a " ".
  635. String NewDir = Dir.replaceAll("%20"," ");
  636. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  637. //Checks if the file exists
  638. File f = new File(NewDir2+"Accounts.ini");
  639.  
  640.  
  641. fw = new FileWriter(f);
  642. BufferedWriter bw = new BufferedWriter(fw);
  643.  
  644.  
  645. int n = 1;
  646. while(n<9)
  647. {
  648. bw.write(Read[n]);
  649. bw.newLine();
  650. n = n+1;
  651. }
  652. bw.close();
  653. } catch (IOException ex) {
  654. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  655. }
  656.  
  657. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  658. }
  659. else
  660. {
  661. try {
  662. CurrentAcc.setText("Current Account: "+ReadNames[4]);
  663. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  664. int indexpass2 = Read[4].indexOf("/");
  665. String Pass = Read[4].substring(indexpass2+1);
  666.  
  667.  
  668. String Dir = location.getFile().toString();
  669. //Replaces the %20 with a " ".
  670. String NewDir = Dir.replaceAll("%20"," ");
  671. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  672. //Checks if the file exists
  673. File f = new File(NewDir2+"Justaccount.ini");
  674. f.createNewFile();
  675. fw = new FileWriter(f);
  676. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  677. bw2.write("[INFO]");
  678. bw2.newLine();
  679. bw2.write("account="+ReadNames[4]);
  680. bw2.newLine();
  681. bw2.write("password="+Pass);
  682. }
  683.  
  684. } catch (IOException ex) {
  685. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  686. }
  687. } // TODO add your handling code here:
  688. }
  689.  
  690. private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
  691. if(ReadNames[6].equals("new"))
  692. {
  693. try {
  694. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  695. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  696. String Temp = Read[6];
  697. Read[6] = Temp.replaceAll("new", NewAccount);
  698. String Temp2 = Read[6];
  699. Read[6] = Temp2.replaceAll("Pass", NewPass);
  700.  
  701.  
  702. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  703. String Dir = location.getFile().toString();
  704. //Replaces the %20 with a " ".
  705. String NewDir = Dir.replaceAll("%20"," ");
  706. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  707. //Checks if the file exists
  708. File f = new File(NewDir2+"Accounts.ini");
  709.  
  710.  
  711. fw = new FileWriter(f);
  712. BufferedWriter bw = new BufferedWriter(fw);
  713.  
  714.  
  715. int n = 1;
  716. while(n<9)
  717. {
  718. bw.write(Read[n]);
  719. bw.newLine();
  720. n = n+1;
  721. }
  722. bw.close();
  723. } catch (IOException ex) {
  724. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  725. }
  726.  
  727. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  728. }
  729. else
  730. {
  731. try {
  732. CurrentAcc.setText("Current Account: "+ReadNames[6]);
  733. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  734. int indexpass2 = Read[6].indexOf("/");
  735. String Pass = Read[6].substring(indexpass2+1);
  736.  
  737.  
  738. String Dir = location.getFile().toString();
  739. //Replaces the %20 with a " ".
  740. String NewDir = Dir.replaceAll("%20"," ");
  741. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  742. //Checks if the file exists
  743. File f = new File(NewDir2+"Justaccount.ini");
  744. f.createNewFile();
  745. fw = new FileWriter(f);
  746. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  747. bw2.write("[INFO]");
  748. bw2.newLine();
  749. bw2.write("account="+ReadNames[6]);
  750. bw2.newLine();
  751. bw2.write("password="+Pass);
  752. }
  753.  
  754. } catch (IOException ex) {
  755. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  756. }
  757. } // TODO add your handling code here:
  758. }
  759.  
  760. private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
  761. if(ReadNames[7].equals("new"))
  762. {
  763. try {
  764. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  765. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  766. String Temp = Read[7];
  767. Read[7] = Temp.replaceAll("new", NewAccount);
  768. String Temp2 = Read[7];
  769. Read[7] = Temp2.replaceAll("Pass", NewPass);
  770.  
  771.  
  772. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  773. String Dir = location.getFile().toString();
  774. //Replaces the %20 with a " ".
  775. String NewDir = Dir.replaceAll("%20"," ");
  776. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  777. //Checks if the file exists
  778. File f = new File(NewDir2+"Accounts.ini");
  779.  
  780.  
  781. fw = new FileWriter(f);
  782. BufferedWriter bw = new BufferedWriter(fw);
  783.  
  784.  
  785. int n = 1;
  786. while(n<9)
  787. {
  788. bw.write(Read[n]);
  789. bw.newLine();
  790. n = n+1;
  791. }
  792. bw.close();
  793. } catch (IOException ex) {
  794. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  795. }
  796.  
  797. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  798. }
  799. else
  800. {
  801. try {
  802. CurrentAcc.setText("Current Account: "+ReadNames[7]);
  803. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  804. int indexpass2 = Read[7].indexOf("/");
  805. String Pass = Read[7].substring(indexpass2+1);
  806.  
  807.  
  808. String Dir = location.getFile().toString();
  809. //Replaces the %20 with a " ".
  810. String NewDir = Dir.replaceAll("%20"," ");
  811. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  812. //Checks if the file exists
  813. File f = new File(NewDir2+"Justaccount.ini");
  814. f.createNewFile();
  815. fw = new FileWriter(f);
  816. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  817. bw2.write("[INFO]");
  818. bw2.newLine();
  819. bw2.write("account="+ReadNames[7]);
  820. bw2.newLine();
  821. bw2.write("password="+Pass);
  822. }
  823.  
  824. } catch (IOException ex) {
  825. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  826. }
  827. } // TODO add your handling code here:
  828. }
  829.  
  830. private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
  831. if(ReadNames[8].equals("new"))
  832. {
  833. try {
  834. String NewAccount = JOptionPane.showInputDialog("Please Enter your Account name");
  835. String NewPass = JOptionPane.showInputDialog("Please Enter your Account Password");
  836. String Temp = Read[8];
  837. Read[8] = Temp.replaceAll("new", NewAccount);
  838. String Temp2 = Read[8];
  839. Read[8] = Temp2.replaceAll("Pass", NewPass);
  840.  
  841.  
  842. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  843. String Dir = location.getFile().toString();
  844. //Replaces the %20 with a " ".
  845. String NewDir = Dir.replaceAll("%20"," ");
  846. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  847. //Checks if the file exists
  848. File f = new File(NewDir2+"Accounts.ini");
  849.  
  850.  
  851. fw = new FileWriter(f);
  852. BufferedWriter bw = new BufferedWriter(fw);
  853.  
  854.  
  855. int n = 1;
  856. while(n<9)
  857. {
  858. bw.write(Read[n]);
  859. bw.newLine();
  860. n = n+1;
  861. }
  862. bw.close();
  863. } catch (IOException ex) {
  864. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  865. }
  866.  
  867. JOptionPane.showMessageDialog (null, "Please Restart the Program", "Restart", JOptionPane.WARNING_MESSAGE);
  868. }
  869. else
  870. {
  871. try {
  872. CurrentAcc.setText("Current Account: "+ReadNames[8]);
  873. URL location = SelectorForm.class.getProtectionDomain().getCodeSource().getLocation();
  874. int indexpass2 = Read[8].indexOf("/");
  875. String Pass = Read[8].substring(indexpass2+1);
  876.  
  877.  
  878. String Dir = location.getFile().toString();
  879. //Replaces the %20 with a " ".
  880. String NewDir = Dir.replaceAll("%20"," ");
  881. String NewDir2 = NewDir.replaceAll("Archlord_Selecter.jar","");
  882. //Checks if the file exists
  883. File f = new File(NewDir2+"Justaccount.ini");
  884. f.createNewFile();
  885. fw = new FileWriter(f);
  886. try (BufferedWriter bw2 = new BufferedWriter(fw)) {
  887. bw2.write("[INFO]");
  888. bw2.newLine();
  889. bw2.write("account="+ReadNames[8]);
  890. bw2.newLine();
  891. bw2.write("password="+Pass);
  892. }
  893.  
  894. } catch (IOException ex) {
  895. Logger.getLogger(SelectorForm.class.getName()).log(Level.SEVERE, null, ex);
  896. }
  897. } // TODO add your handling code here:
  898. }
  899.  
  900. /**
  901. * @param args the command line arguments
  902. */
  903.  
  904. /**
  905. *
  906. * @param args the command line arguments
  907. * @throws java.lang.Exception
  908. */
  909.  
  910.  
  911.  
  912. // Variables declaration - do not modify
  913. private javax.swing.JLabel CurrentAcc;
  914. private javax.swing.JButton jButton1;
  915. private javax.swing.JButton jButton10;
  916. private javax.swing.JButton jButton11;
  917. private javax.swing.JButton jButton2;
  918. private javax.swing.JButton jButton3;
  919. private javax.swing.JButton jButton4;
  920. private javax.swing.JButton jButton5;
  921. private javax.swing.JButton jButton6;
  922. private javax.swing.JButton jButton7;
  923. private javax.swing.JButton jButton8;
  924. private javax.swing.JButton jButton9;
  925. private javax.swing.JLabel jLabel1;
  926. private javax.swing.JLabel jLabel2;
  927. private javax.swing.JPanel jPanel1;
  928. // End of variables declaration
  929. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement