Advertisement
CThoms

Program Example

Nov 18th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.22 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package side.project;
  6.  
  7. import java.awt.Container;
  8. import java.awt.Dimension;
  9. import java.awt.FlowLayout;
  10. import java.awt.image.BufferedImage;
  11. import java.io.File;
  12. import java.io.IOException;
  13. import javax.imageio.ImageIO;
  14. import javax.swing.ImageIcon;
  15. import javax.swing.JFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JPanel;
  18. import javax.swing.JScrollPane;
  19. import javax.swing.JTextArea;
  20.  
  21. /**
  22. *
  23. * @author cthomsen18
  24. */
  25. public class SideProject {
  26.  
  27. /**
  28. * @param args the command line arguments
  29. */
  30.  
  31. private static JFrame mainframe;
  32. private static Container dataplacement;
  33. private static JTextArea textdata;
  34. private static ImageIcon iconb;
  35. private static String j;
  36. private static BufferedImage img;
  37.  
  38. private static int x;
  39.  
  40. private static JPanel imgcontainer;
  41.  
  42. private static JScrollPane scrollPane;
  43. private static JScrollPane imgScrollPane;
  44.  
  45. private static JLabel lab;
  46. private static JLabel laba;
  47. private static JLabel labb;
  48. private static JLabel labc;
  49. private static JLabel labd;
  50. private static JLabel labe;
  51. private static JLabel labf;
  52. private static JLabel labg;
  53. private static JLabel labh;
  54. private static JLabel labi;
  55. private static JLabel labj;
  56. private static JLabel labk;
  57. private static JLabel labl;
  58. private static JLabel labm;
  59. private static JLabel labn;
  60. private static JLabel labo;
  61. private static JLabel labp;
  62. private static JLabel labq;
  63. private static JLabel labr;
  64. private static JLabel labs;
  65.  
  66. private static JTextArea textArea;
  67.  
  68. private static String sc = "C:\\Users\\cthomsen18\\Documents\\NetBeansProjects\\Side Project\\src\\Image Sources";
  69.  
  70. private static void changeimg(String stringname, String stringn, String stringr, JLabel las) {
  71.  
  72. j = (sc + "\\" + stringn + "\\" + stringr + "\\" + stringname + ".png");
  73. System.out.println(j);
  74.  
  75. img = null;
  76.  
  77. try {
  78.  
  79. img = ImageIO.read(new File(j));
  80.  
  81. } catch (IOException e) {
  82.  
  83. }
  84.  
  85. iconb = new ImageIcon(img, "Pokemon Image");
  86.  
  87. las.setIcon(iconb);
  88. las.setOpaque(true);
  89.  
  90. }
  91.  
  92. private static void printstats(int n, int x, String texts, String[] columnNames, String [][] firstevolutiondata) {
  93.  
  94. n = 0;
  95.  
  96. while ( n < 10 ) {
  97.  
  98. texts = texts + columnNames[n] + " : " + firstevolutiondata[x][n] + " \n";
  99. textArea.setText(texts);
  100. n++;
  101.  
  102. }
  103.  
  104. texts = texts + "\n";
  105. textArea.setText(texts);
  106. texts = texts + "\n";
  107. textArea.setText(texts);
  108.  
  109. }
  110.  
  111. private static void constructGui() {
  112.  
  113. String[] columnNames = {"Pokemon Name",
  114. "Type",
  115. "Generation",
  116. "Region",
  117. "Games Appeared In",
  118. "Base HP",
  119. "Base Attack",
  120. "Base Speed",
  121. "Base Defense",
  122. "Level to Evolve",
  123. "Evolutionary Stage"};
  124.  
  125.  
  126.  
  127. String[][] firstevolutiondata = {
  128.  
  129. {"Pikachu", "Electric", "1", "Kanto", "Yellow", "35", "55", "90", "40", "Thunderstone", "1"},
  130. {"Charmander", "Fire", "1", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "39", "52", "65", "43", "Level 16", "1"},
  131. {"Bulbasaur", "Grass", "1", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "45", "49", "45", "49", "Level 16", "1"},
  132. {"Squirtle", "Water", "2", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "44", "43", "65", "Level 16", "1"},
  133. {"Cyndaquil", "Fire", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "39", "52", "65", "43", "Level 14", "1"},
  134. {"Chikorita", "Grass", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "45", "49", "45", "65", "Level 16", "1"},
  135. {"Totodile", "Water", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "50", "65", "43", "64", "Level 18", "1"},
  136. {"Torchic", "Fire", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "45", "60", "45", "40", "Level 16", "1"},
  137. {"Treecko", "Grass", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "40", "45", "70", "35", "Level 16", "1"},
  138. {"Mudkip", "Water", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "50", "70", "40", "50", "Level 16", "1"},
  139. {"Chimchar", "Fire", "4", "Sinnoh", "Diamond, Pearl, Platinum", "44", "58", "61", "44", "Level 14", "1"},
  140. {"Turtwig", "Grass", "4", "Sinnoh", "Diamond, Pearl, Platinum", "55", "68", "31", "64", "Level 18", "1"},
  141. {"Piplup", "Water", "4", "Sinnoh", "Diamond, Pearl, Platinum", "53", "51", "40", "53", "Level 16", "1"},
  142. {"Tepig", "Fire", "5", "Unova", "Black, White, Black 2, White 2", "65", "63", "45", "45", "Level 17", "1"},
  143. {"Snivy", "Grass", "5", "Unova", "Black, White, Black 2, White 2", "45", "45", "63", "55", "Level 17", "1"},
  144. {"Oshawott", "Water", "5", "Unova", "Black, White, Black 2, White 2", "55", "55", "45", "45", "Level 17", "1"},
  145. {"Fennekin", "Fire", "6", "Kalos", "X, Y", "40", "45", "60", "40", "Level 16", "1"},
  146. {"Chespin", "Grass", "6", "Kalos", "X, Y", "56", "61", "38", "65", "Level 16", "1"},
  147. {"Froakie", "Water", "6", "Kalos", "X, Y", "41", "56", "71", "40", "Level 16", "1"},
  148.  
  149. };
  150.  
  151. String[] [] secondevolutiondata = {
  152.  
  153. {"Raichu", "Electric", "1", "Kanto", "Yellow", "60", "90", "110", "55", "Final", "2"},
  154. {"Charmeleon", "Fire", "1", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "58", "64", "80", "58", "Level 36", "2"},
  155. {"Ivysaur", "Grass", "1", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "60", "62", "60", "63", "Level 36", "2"},
  156. {"Wartortle", "Water", "2", "Kanto", "Red, Blue, Green, Fire Red, Leaf Green", "59", "63", "58", "80", "Level 36", "2"},
  157. {"Quilava", "Fire", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "58", "64", "80", "58", "Level 36", "2"},
  158. {"Bayleef", "Grass", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "60", "62", "60", "80", "Level 32", "2"},
  159. {"Croconaw", "Water", "2", "Johto", "Silver, Crystal, Gold, Heart Gold, Soul Silver", "65", "80", "58", "80", "Level 30", "2"},
  160. {"Combusken", "Fire", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "60", "85", "55", "60", "Level 36", "2"},
  161. {"Grovyle", "Grass", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "50", "65", "95", "45", "Level 36", "2"},
  162. {"Marshtomp", "Water", "3", "Hoenn", "Sapphire, Ruby, Emerald, Omega Ruby, Alpha Sapphire", "70", "85", "50", "70", "Level 35", "2"},
  163. {"Monferno", "Fire", "4", "Sinnoh", "Diamond, Pearl, Platinum", "64", "78", "81", "52", "Level 36", "2"},
  164. {"Grotle", "Grass", "4", "Sinnoh", "Diamond, Pearl, Platinum", "75", "89", "36", "85", "Level 32", "2"},
  165. {"Prinplup", "Water", "4", "Sinnoh", "Diamond, Pearl, Platinum", "64", "66", "50", "68", "Level 36", "2"},
  166. {"Pignite", "Fire", "5", "Unova", "Black, White, Black 2, White 2", "90", "93", "55", "55", "Level 36", "2"},
  167. {"Servine", "Grass", "5", "Unova", "Black, White, Black 2, White 2", "60", "60", "83", "75", "Level 36", "2"},
  168. {"Dewott", "Water", "5", "Unova", "Black, White, Black 2, White 2", "75", "75", "60", "60", "Level 36", "2"},
  169. {"Braixen", "Fire", "6", "Kalos", "X, Y", "59", "59", "73", "58", "Level 36", "2"},
  170. {"Quilladin", "Grass", "6", "Kalos", "X, Y", "61", "78", "57", "95", "Level 36", "2"},
  171. {"Froakie", "Water", "6", "Kalos", "X, Y", "41", "56", "71", "40", "Level 16", "1"},
  172.  
  173. };
  174.  
  175. imgcontainer = new JPanel();
  176. imgcontainer.setSize(1080, 500);
  177.  
  178. int unix = 100;
  179. int uniy = 100;
  180.  
  181. lab = new JLabel();
  182. lab.setSize(unix, uniy);
  183.  
  184. labb = new JLabel();
  185. labb.setSize(unix, uniy);
  186.  
  187. labc = new JLabel();
  188. labc.setSize(unix, uniy);
  189.  
  190. labd = new JLabel();
  191. labd.setSize(unix, uniy);
  192.  
  193. labe = new JLabel();
  194. labe.setSize(unix, uniy);
  195.  
  196. labf = new JLabel();
  197. labf.setSize(unix, uniy);
  198.  
  199. labg = new JLabel();
  200. labg.setSize(unix, uniy);
  201.  
  202. labh = new JLabel();
  203. labh.setSize(unix, uniy);
  204.  
  205. labi = new JLabel();
  206. labi.setSize(unix, uniy);
  207.  
  208. labj = new JLabel();
  209. labj.setSize(unix, uniy);
  210.  
  211. labk = new JLabel();
  212. labk.setSize(unix, uniy);
  213.  
  214. labl = new JLabel();
  215. labl.setSize(unix, uniy);
  216.  
  217. labm = new JLabel();
  218. labm.setSize(unix, uniy);
  219.  
  220. labn = new JLabel();
  221. labn.setSize(unix, uniy);
  222.  
  223. labo = new JLabel();
  224. labo.setSize(unix, uniy);
  225.  
  226. labp = new JLabel();
  227. labp.setSize(unix, uniy);
  228.  
  229. labq = new JLabel();
  230. labq.setSize(unix, uniy);
  231.  
  232. labr = new JLabel();
  233. labr.setSize(unix, uniy);
  234.  
  235. labs = new JLabel();
  236. labs.setSize(unix, uniy);
  237.  
  238. System.out.println(firstevolutiondata[0][0]);
  239.  
  240. // changeimg(pokemonname, regionname, labelname)
  241.  
  242. changeimg(firstevolutiondata[0][0], firstevolutiondata[0][3], "1", lab);
  243. changeimg(firstevolutiondata[1][0], firstevolutiondata[1][3], "1", labb);
  244. changeimg(firstevolutiondata[2][0], firstevolutiondata[2][3], "1", labc);
  245. changeimg(firstevolutiondata[3][0], firstevolutiondata[3][3], "1", labd);
  246. changeimg(firstevolutiondata[4][0], firstevolutiondata[4][3], "1", labe);
  247. changeimg(firstevolutiondata[5][0], firstevolutiondata[5][3], "1", labf);
  248. changeimg(firstevolutiondata[6][0], firstevolutiondata[6][3], "1", labg);
  249. changeimg(firstevolutiondata[7][0], firstevolutiondata[7][3], "1", labh);
  250. changeimg(firstevolutiondata[8][0], firstevolutiondata[8][3], "1", labi);
  251. changeimg(firstevolutiondata[9][0], firstevolutiondata[9][3], "1", labj);
  252. changeimg(firstevolutiondata[10][0], firstevolutiondata[10][3], "1", labk);
  253. changeimg(firstevolutiondata[11][0], firstevolutiondata[11][3], "1", labl);
  254. changeimg(firstevolutiondata[12][0], firstevolutiondata[12][3], "1", labm);
  255. changeimg(firstevolutiondata[13][0], firstevolutiondata[13][3], "1", labn);
  256. changeimg(firstevolutiondata[14][0], firstevolutiondata[14][3], "1", labo);
  257. changeimg(firstevolutiondata[15][0], firstevolutiondata[15][3], "1", labp);
  258. changeimg(firstevolutiondata[16][0], firstevolutiondata[16][3], "1", labq);
  259. changeimg(firstevolutiondata[17][0], firstevolutiondata[16][3], "1", labr);
  260. changeimg(firstevolutiondata[18][0], firstevolutiondata[16][3], "1", labs);
  261.  
  262. imgcontainer.add(lab); imgcontainer.add(labb); imgcontainer.add(labc); imgcontainer.add(labd); imgcontainer.add(labe); imgcontainer.add(labf); imgcontainer.add(labg); imgcontainer.add(labh); imgcontainer.add(labi); imgcontainer.add(labj); imgcontainer.add(labk); imgcontainer.add(labl); imgcontainer.add(labm); imgcontainer.add(labn); imgcontainer.add(labo); imgcontainer.add(labp); imgcontainer.add(labq); imgcontainer.add(labr); imgcontainer.add(labs);
  263.  
  264. textArea = new JTextArea(1080, 500);
  265. textArea.setEditable(false);
  266. textArea.setLineWrap(true);
  267.  
  268. scrollPane = new JScrollPane(textArea);
  269. scrollPane.setPreferredSize(new Dimension(1080, 500));
  270.  
  271. imgScrollPane = new JScrollPane(imgcontainer);
  272. imgScrollPane.setPreferredSize(new Dimension(1080, 500));
  273.  
  274. mainframe = new JFrame("Starter Pokemon Analyzer");
  275. mainframe.setSize(1080, 1080);
  276.  
  277. lab.setVisible(true);
  278. mainframe.setVisible(true);
  279. mainframe.add(imgScrollPane);
  280. mainframe.add(scrollPane);
  281. mainframe.setLayout(new FlowLayout (FlowLayout.LEADING));
  282.  
  283. String texts = "";
  284.  
  285. // N is a value
  286. // X value is Row number in Data
  287.  
  288. printstats(0, 0, texts, columnNames, firstevolutiondata);
  289. printstats(0, 1, texts, columnNames, firstevolutiondata);
  290. printstats(0, 2, texts, columnNames, firstevolutiondata);
  291. printstats(0, 3, texts, columnNames, firstevolutiondata);
  292. printstats(0, 4, texts, columnNames, firstevolutiondata);
  293. printstats(0, 5, texts, columnNames, firstevolutiondata);
  294. printstats(0, 6, texts, columnNames, firstevolutiondata);
  295. printstats(0, 7, texts, columnNames, firstevolutiondata);
  296. printstats(0, 8, texts, columnNames, firstevolutiondata);
  297. printstats(0, 10, texts, columnNames, firstevolutiondata);
  298. printstats(0, 11, texts, columnNames, firstevolutiondata);
  299. printstats(0, 12, texts, columnNames, firstevolutiondata);
  300. printstats(0, 13, texts, columnNames, firstevolutiondata);
  301. printstats(0, 14, texts, columnNames, firstevolutiondata);
  302. printstats(0, 15, texts, columnNames, firstevolutiondata);
  303. printstats(0, 16, texts, columnNames, firstevolutiondata);
  304. printstats(0, 17, texts, columnNames, firstevolutiondata);
  305. printstats(0, 18, texts, columnNames, firstevolutiondata);
  306.  
  307.  
  308. }
  309.  
  310. public static void main(String[] args) {
  311.  
  312. // TODO code application logic here
  313. // Starter Pokemon Data Compiler
  314.  
  315. constructGui();
  316.  
  317. }
  318. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement