Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. static String[] Maps = { };
  2.  
  3. static JComboBox<String> cb = new JComboBox<String>(directions);
  4.  
  5.  
  6.  
  7. ==========================================
  8. public static void loadAThing{
  9. EventQueue.invokeLater(new Runnable() {
  10. @Override
  11. public void run() {
  12. JButton button = new JButton("Enter");
  13. int xlenght = findLength(map) + 1;
  14. button.addActionListener(new ActionListener() {
  15. public void actionPerformed(ActionEvent ev) {
  16. String filecontents = "";
  17.  
  18. FileReader fr = null;
  19. try {
  20. fr = new FileReader(("resources/" + cb.ToString));
  21. } catch (FileNotFoundException e) {
  22. // TODO Auto-generated catch block
  23. e.printStackTrace();
  24. }
  25.  
  26. int i;
  27.  
  28.  
  29. if (fr != null) {
  30.  
  31. try {
  32. while ((i = fr.read()) != -1) {
  33. filecontents = filecontents + (char) i;
  34.  
  35. }
  36. } catch (IOException | NullPointerException n) {
  37.  
  38. n.printStackTrace();
  39. }
  40. try {
  41. fr.close();
  42. } catch (IOException e) {
  43. e.printStackTrace();
  44. }
  45. });
  46. Object[] options = new Object[] {};
  47. JOptionPane frame = new JOptionPane("Please Select", JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION,
  48. null, options, null);
  49. frame.add(cb);
  50. frame.add(cb1);
  51. frame.add(button);
  52. JDialog diag = new JDialog();
  53. diag.getContentPane().add(frame);
  54. diag.pack();
  55. diag.setVisible(true);
  56. }
  57. });
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement