package frame; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; @SuppressWarnings("serial") public class networkWindow extends JFrame{ SlideBrowser sb; String[] details; JTextField host; JTextField port; JTextField user; JPasswordField pass; JButton confirm; JButton deny; JComboBox connectionType; public networkWindow(SlideBrowser slideB) { //Make window for connection info super("New Network Connection"); this.setSize(400, 250); this.setLocationRelativeTo(null); this.setLayout(new GridLayout(6, 6, 5, 5)); //Set the frame icon to an image loaded from a file. this.setIconImage(new ImageIcon(getClass().getResource("/resources/16x16/world_go.png")).getImage()); sb = slideB; //Dropdown box for type of connection connectionType = new JComboBox(); connectionType.addItem("SFTP"); connectionType.addItem("FTP"); this.add(new JLabel("Connection Type: ")); this.add(connectionType); //input boxes for connection info this.add(new JLabel("Host Name: ")); host = new JTextField(); this.add(host); this.add(new JLabel("Port: ")); port = new JTextField(); this.add(port); user = new JTextField(); this.add(new JLabel("Username: ")); this.add(user); pass = new JPasswordField(); this.add(new JLabel("Password: ")); this.add(pass); //buttons confirm = new JButton("Confirm"); confirm.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent arg0) { sendDetails(); sb.newNetworkTab(); dispose(); } }); deny = new JButton("Cancel"); deny.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); this.add(confirm); this.add(deny); //Make visible this.setVisible(true); } /** * Give network details to the parent Frame for it to make * a network panel * */ public void sendDetails() { details = new String[5]; details[0] = (String) connectionType.getSelectedItem(); details[1] = host.getText(); details[2] = port.getText(); details[3] = user.getText(); char[] passd = pass.getPassword(); String sS = ""; for(int b=0; b < passd.length; b++) { sS += passd[b]; } details[4] = sS; sb.setNetworkDetails(details); } }