browse for share folder and close button working
git-svn-id: svn://anubis/gvsu@24 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
0804d210f0
commit
858e0b2976
@ -1,11 +1,14 @@
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class KaZaGUI extends JFrame
|
||||
{
|
||||
private JButton m_browseButton;
|
||||
private JButton m_connectButton;
|
||||
private JButton m_closeButton;
|
||||
private JTextField m_shareFolderField;
|
||||
|
||||
public KaZaGUI()
|
||||
{
|
||||
@ -15,6 +18,8 @@ public class KaZaGUI extends JFrame
|
||||
setSize(600, 400);
|
||||
setVisible(true);
|
||||
|
||||
ActionEventHandler handler = new ActionEventHandler(this);
|
||||
|
||||
Container c = getContentPane();
|
||||
JTabbedPane pane = new JTabbedPane();
|
||||
c.add(pane);
|
||||
@ -34,8 +39,10 @@ public class KaZaGUI extends JFrame
|
||||
p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
|
||||
p.add(new JLabel("Shared folder: "));
|
||||
p.add(new JTextField());
|
||||
m_shareFolderField = new JTextField();
|
||||
p.add(m_shareFolderField);
|
||||
m_browseButton = new JButton("...");
|
||||
m_browseButton.addActionListener(handler);
|
||||
p.add(m_browseButton);
|
||||
clientPanel.add(p);
|
||||
clientPanel.add(Box.createVerticalGlue());
|
||||
@ -46,7 +53,11 @@ public class KaZaGUI extends JFrame
|
||||
p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
|
||||
m_connectButton = new JButton("Connect");
|
||||
m_connectButton.addActionListener(handler);
|
||||
p.add(m_connectButton);
|
||||
m_closeButton = new JButton("Close");
|
||||
m_closeButton.addActionListener(handler);
|
||||
p.add(m_closeButton);
|
||||
clientPanel.add(p);
|
||||
pane.add("Client", clientPanel);
|
||||
|
||||
@ -57,7 +68,28 @@ public class KaZaGUI extends JFrame
|
||||
pane.add("Server", serverPanel);
|
||||
}
|
||||
|
||||
public void run()
|
||||
private class ActionEventHandler implements ActionListener
|
||||
{
|
||||
private KaZaGUI m_kg;
|
||||
|
||||
public ActionEventHandler(KaZaGUI kg)
|
||||
{
|
||||
m_kg = kg;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (e.getSource() == m_browseButton)
|
||||
{
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
fc.showOpenDialog(m_kg);
|
||||
m_shareFolderField.setText(fc.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
else if (e.getSource() == m_closeButton)
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user