import java.awt.*; import java.applet.*; import java.io.*; import java.net.*; import java.util.*; public class ExScriptControls extends Panel { Label exLabel; Label distNameLabel; TextArea exTxtArea; private void add(Component c, GridBagLayout gbl, GridBagConstraints gbc, int x, int y, int w, int h) { gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; gbl.setConstraints(c,gbc); add(c); } public void paint(Graphics g) { Dimension d = size(); Insets in = insets(); Font f = new Font("TimesRoman", Font.BOLD, 14); FontMetrics fm = g.getFontMetrics(f); String s = "EXECUTION SCRIPT"; g.setFont(f); //g.drawString(s, 130,40); //g.drawString(s, d.width/4+25, d.height/4-40); //int client_width = d.width - in.right - in.left; //int client_height = d.height - in.bottom - in.top; //int cx = (client_width - w1 - w2 - w3) /2; //int cy = client_height /2; //g.drawRect(0, 0, client_width - 1, client_height - 1); g.drawRect(0, 0, d.width-1, d.height-1); } public ExScriptControls() { GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); exLabel = new Label("EXECUTION SCRIPT",Label.CENTER); //exLabel.setBackground(Color.yellow); exLabel.setForeground(Color.blue); distNameLabel = new Label("Name :",Label.RIGHT); exTxtArea = new TextArea(11,10); Label blankLabel = new Label(" "); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 100; gbc.fill = GridBagConstraints.HORIZONTAL; //gbc.anchor = GridBagConstraints.WEST; add(exLabel, gbl, gbc, 1, 0, 2, 1); add(exTxtArea, gbl, gbc, 1, 2, 2, 1); } public Insets insets() { return new Insets(5,5,5,5); } public void setExample(String str) { int count, i; clearAll(); String s, tmp=""; StringTokenizer t = new StringTokenizer(str, "<"); s = t.nextToken(); while(!s.equals("?")) { tmp += s + '\n'; s = t.nextToken(); } System.out.println(tmp); exTxtArea.setText(tmp); } public void clearAll() { exTxtArea.setText(""); } public void sendInputToServer(DataOutputStream os) { try { os.writeBytes("exec.scrpt"); os.writeByte('\n'); os.writeBytes(exTxtArea.getText()); os.writeByte('\n'); os.writeBytes("end.exec.script"); os.writeByte('\n'); } catch (IOException e) { System.err.println("I/O failed on the connection to: taranis"); } } };