All pastes #277046 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-12-12 21:30 UTC
rendered paste body
--------------- Frame --------------

public class frame extends JFrame {

	JButton addButton, statusButton;
	JTextField ip;
	status stat = new status();
	
	public frame() {
		/* initialise JFrame */
		super("NAD");
		setSize(500,400);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container content=getContentPane();
		content.setLayout(new BorderLayout());
		
		/* JPanel1 */
		JPanel panel1 = new JPanel(new FlowLayout());
		panel1.add(new JLabel("Enter a Machine IP:    "));
		ip = new JTextField(10);
		panel1.add(ip);

		
		ButtonHandler handler = new ButtonHandler();
		addButton = new JButton ("add");
		panel1.add(addButton);
		addButton.addActionListener(handler);
		panel1.add(new JButton("ping"));
		
		/* add panel1 to Content pane */
		content.add(panel1, BorderLayout.SOUTH);
		
		/* create the center JPanel */
		JPanel box = new JPanel(new FlowLayout());
		// box.setPreferredSize(new Dimension(400, 300));		
				

		box.add(new JLabel("Ip               OS              Version              Username               Java Version"));		
		JList li = new JList(arr);
		box.add(li); 
		content.add(box, BorderLayout.CENTER);  


		/* JPanel2 */
		JPanel panel2 = new JPanel(new FlowLayout());
		panel2.add(new JButton("ping"));	
		panel2.add(new JButton("isolate"));
		panel2.add(new JButton("removes"));
		statusButton = new JButton("status");
		panel2.add(statusButton);
		statusButton.addActionListener(handler);
		
		
		/* add Panel2 to ContentPane */
		content.add(panel2, BorderLayout.NORTH);
		
		
		
	} /* end constructor */

	/* events handler */
	public class ButtonHandler implements ActionListener {
		hosts hoo = new hosts();
		public void actionPerformed( ActionEvent actionEvent )
		{
			if (actionEvent.getSource() == addButton) 
			{
				hoo.addHost(ip.getText());
//				control cont = new control();
//				cont.addServer(ip.getText());
			}
			else if (actionEvent.getSource() == statusButton)
			{
				status stat = new status();
				stat.requestStatus(ip.getText());
				// st.setText(stat.theOsName);
			}
		}
	} // end events
		
} /* end frame class */
	
	

--------------------------------------------------------------------------------


public class hosts {

	public String[] arr;

	public void addHost(String hostname) {
		
		ArrayList hostnames = new ArrayList();

		hostnames.add(hostname);
		
		System.out.println("hostname is currently " + hostnames.size() + " in length..");
		
		String[] arr = (String[]) hostnames.toArray(new String[0]);		


	}
}