Guest User

Untitled

a guest
Feb 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.event.*;
  3.  
  4. public class GUIFrame extends JFrame {
  5.  
  6. public GUIFrame(String args) {
  7. super();
  8. add(new GUIPanel(args));
  9. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  10. this.setSize(640,480);
  11. this.pack();
  12. this.setVisible(true);
  13. }
  14.  
  15. }
  16.  
  17.  
  18. ///////////////////////////////////////////
  19.  
  20. import java.awt.*;
  21. import javax.swing.*;
  22. import javax.swing.event.ListSelectionEvent;
  23. import javax.swing.event.ListSelectionListener;
  24. import java.awt.event.*;
  25. import java.util.Vector;
  26.  
  27.  
  28. public class GUIPanel extends JPanel implements ListSelectionListener
  29. {
  30.  
  31. private JSplitPane top;
  32. private String[] links;
  33. private String path;
  34. private JList list;
  35. private JLabel linknames;
  36. private Vector<CakeRecipe> cake;
  37.  
  38. public GUIPanel(String args)
  39. {
  40. super();
  41. path = args;
  42.  
  43. readFiles rf = new readFiles(path);
  44. links = rf.getFiles();
  45. list = new JList(links);
  46. list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  47. list.setSelectedIndex(0);
  48. list.addListSelectionListener(this);
  49.  
  50. JScrollPane listScrollPane = new JScrollPane(list);
  51. linknames = new JLabel();
  52. linknames.setFont(linknames.getFont().deriveFont(Font.ITALIC));
  53. linknames.setHorizontalAlignment(JLabel.CENTER);
  54.  
  55.  
  56.  
  57.  
  58. JScrollPane pictureScrollPane = new JScrollPane();
  59.  
  60.  
  61. //Create a split pane with the two scroll panes in it.
  62. top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
  63. listScrollPane, pictureScrollPane);
  64. top.setOneTouchExpandable(true);
  65. top.setDividerLocation(150);
  66.  
  67. //Provide minimum sizes for the two components in the split pane.
  68. Dimension minimumSize = new Dimension(100, 50);
  69. listScrollPane.setMinimumSize(minimumSize);
  70. pictureScrollPane.setMinimumSize(minimumSize);
  71.  
  72. //Provide a preferred size for the split pane.
  73. top.setPreferredSize(new Dimension(400, 200));
  74.  
  75. top.setBorder(null);
  76.  
  77. JPanel bot = new JPanel(new GridLayout(0,3));
  78.  
  79. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
  80. top, bot);
  81. splitPane.setOneTouchExpandable(true);
  82. splitPane.setDividerLocation(360);
  83.  
  84. top.setMinimumSize(new Dimension(100, 50));
  85. bot.setMinimumSize(new Dimension(100, 30));
  86. splitPane.setPreferredSize(new Dimension(640, 480));
  87.  
  88.  
  89. JButton redButton = new JButton("Process HTML and Print to File");
  90. bot.add(redButton);
  91. redButton.addActionListener(new ActionListener()
  92. {
  93. public void actionPerformed(ActionEvent ev)
  94. {
  95. for(int i=0; i<cake.size();i++)
  96. {
  97. cake.get(i).printFile();
  98. }
  99. }
  100. });
  101.  
  102.  
  103.  
  104. JButton greenButton = new JButton("");
  105. bot.add(greenButton);
  106. greenButton.addActionListener(new ActionListener()
  107. {
  108. public void actionPerformed(ActionEvent ev)
  109. {
  110.  
  111. }
  112. });
  113.  
  114. JButton blueButton = new JButton("");
  115. bot.add(blueButton);
  116. blueButton.addActionListener(new ActionListener()
  117. {
  118. public void actionPerformed(ActionEvent ev)
  119. {
  120.  
  121. }
  122. });
  123.  
  124.  
  125. add(splitPane);
  126. }
  127.  
  128. public void valueChanged(ListSelectionEvent e) {
  129. JList list = (JList)e.getSource();
  130. }
  131. }
Add Comment
Please, Sign In to add comment