Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.event.*;
- public class GUIFrame extends JFrame {
- public GUIFrame(String args) {
- super();
- add(new GUIPanel(args));
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setSize(640,480);
- this.pack();
- this.setVisible(true);
- }
- }
- ///////////////////////////////////////////
- import java.awt.*;
- import javax.swing.*;
- import javax.swing.event.ListSelectionEvent;
- import javax.swing.event.ListSelectionListener;
- import java.awt.event.*;
- import java.util.Vector;
- public class GUIPanel extends JPanel implements ListSelectionListener
- {
- private JSplitPane top;
- private String[] links;
- private String path;
- private JList list;
- private JLabel linknames;
- private Vector<CakeRecipe> cake;
- public GUIPanel(String args)
- {
- super();
- path = args;
- readFiles rf = new readFiles(path);
- links = rf.getFiles();
- list = new JList(links);
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- list.setSelectedIndex(0);
- list.addListSelectionListener(this);
- JScrollPane listScrollPane = new JScrollPane(list);
- linknames = new JLabel();
- linknames.setFont(linknames.getFont().deriveFont(Font.ITALIC));
- linknames.setHorizontalAlignment(JLabel.CENTER);
- JScrollPane pictureScrollPane = new JScrollPane();
- //Create a split pane with the two scroll panes in it.
- top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- listScrollPane, pictureScrollPane);
- top.setOneTouchExpandable(true);
- top.setDividerLocation(150);
- //Provide minimum sizes for the two components in the split pane.
- Dimension minimumSize = new Dimension(100, 50);
- listScrollPane.setMinimumSize(minimumSize);
- pictureScrollPane.setMinimumSize(minimumSize);
- //Provide a preferred size for the split pane.
- top.setPreferredSize(new Dimension(400, 200));
- top.setBorder(null);
- JPanel bot = new JPanel(new GridLayout(0,3));
- JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- top, bot);
- splitPane.setOneTouchExpandable(true);
- splitPane.setDividerLocation(360);
- top.setMinimumSize(new Dimension(100, 50));
- bot.setMinimumSize(new Dimension(100, 30));
- splitPane.setPreferredSize(new Dimension(640, 480));
- JButton redButton = new JButton("Process HTML and Print to File");
- bot.add(redButton);
- redButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- for(int i=0; i<cake.size();i++)
- {
- cake.get(i).printFile();
- }
- }
- });
- JButton greenButton = new JButton("");
- bot.add(greenButton);
- greenButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- }
- });
- JButton blueButton = new JButton("");
- bot.add(blueButton);
- blueButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- }
- });
- add(splitPane);
- }
- public void valueChanged(ListSelectionEvent e) {
- JList list = (JList)e.getSource();
- }
- }
Add Comment
Please, Sign In to add comment