Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Button calling Event failure

0 views
Skip to first unread message

karwa...@yahoo.com

unread,
Aug 12, 2004, 10:23:06 AM8/12/04
to
Dear Mr/Ms

Here i submmited my coding to all of you, could you please check for
me which line of coding statement is error.

i can't link to Client Registration frame when i click the New Client
button in my ServiceRequest frame. when i click the new client
button,it successful link to the client registration frame but all the
GUI in client registration cannot be see. so thanks for your help...

here i attach my coding:
******************************************************************************
ServiceRequest frame

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;

public class ServiceRequest extends Applet implements ActionListener {
JLabel label_1;
JLabel label_2;
JLabel label_3;
JLabel label_4;
JLabel label_5;
JLabel label_6;
JScrollBar scrollbar_v_1;
JLabel label_7;
JComboBox combobox_1;
JLabel label_8;
JTextArea textarea_1;
JScrollPane sp_textarea_1;
JTextField textfield_1;
JButton button_1;
JButton button_2;
JButton button_3;
JTextField textfield_2;
JTextField textfield_3;
JTextField textfield_4;
JTextField textfield_5;

public void init() {
ServiceRequestLayout customLayout = new
ServiceRequestLayout();

setFont(new Font("Helvetica", Font.PLAIN, 12));
setLayout(customLayout);

label_1 = new JLabel("Client Service Request");
add(label_1);

label_2 = new JLabel("Client:");
add(label_2);

label_3 = new JLabel("Machine ID:");
add(label_3);

label_4 = new JLabel("Date:");
add(label_4);

label_5 = new JLabel("Time:");
add(label_5);

label_6 = new JLabel("Problem Description:");
add(label_6);

scrollbar_v_1 = new JScrollBar(Scrollbar.VERTICAL);
add(scrollbar_v_1);

label_7 = new JLabel("Technician Name:");
add(label_7);

combobox_1 = new JComboBox();
combobox_1.addItem("item1");
combobox_1.addItem("item2");
add(combobox_1);

label_8 = new JLabel("Unresolved Work Type:");
add(label_8);

textarea_1 = new JTextArea("");
sp_textarea_1 = new JScrollPane(textarea_1);
add(sp_textarea_1);

textfield_1 = new JTextField("");
add(textfield_1);

button_1 = new JButton("Save");
add(button_1);

button_2 = new JButton("New Client");
add(button_2);

button_3 = new JButton("Exit");
add(button_3);

textfield_2 = new JTextField("");
add(textfield_2);

textfield_3 = new JTextField("");
add(textfield_3);

textfield_4 = new JTextField("");
add(textfield_4);

textfield_5 = new JTextField("");
add(textfield_5);

setSize(getPreferredSize());

button_1.addActionListener(this);
button_2.addActionListener(this);
button_3.addActionListener(this);

}



public void actionPerformed(ActionEvent ae){


if(ae.getActionCommand().equals("New Client")){
ClientRegistration cr = new ClientRegistration();
this.setVisible(false);
cr.setVisible(true);
}
}



public static void main(String args[]) {

ServiceRequest applet = new ServiceRequest();
Frame window = new Frame("ServiceRequest");

window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});


applet.init();
window.add("Center", applet);
window.pack();
window.setVisible(true);
}
}

class ServiceRequestLayout implements LayoutManager {

public ServiceRequestLayout() {
}

public void addLayoutComponent(String name, Component comp) {
}

public void removeLayoutComponent(Component comp) {
}

public Dimension preferredLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);

Insets insets = parent.getInsets();
dim.width = 454 + insets.left + insets.right;
dim.height = 389 + insets.top + insets.bottom;

return dim;
}

public Dimension minimumLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
return dim;
}

public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();

Component c;
c = parent.getComponent(0);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+8,192,24);}
c = parent.getComponent(1);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+40,96,24);}
c = parent.getComponent(2);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+72,96,24);}
c = parent.getComponent(3);
if (c.isVisible())
{c.setBounds(insets.left+288,insets.top+40,40,24);}
c = parent.getComponent(4);
if (c.isVisible())
{c.setBounds(insets.left+288,insets.top+72,40,24);}
c = parent.getComponent(5);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+112,160,24);}
c = parent.getComponent(6);
if (c.isVisible())
{c.setBounds(insets.left+408,insets.top+144,24,112);}
c = parent.getComponent(7);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+272,152,24);}
c = parent.getComponent(8);
if (c.isVisible())
{c.setBounds(insets.left+184,insets.top+272,112,24);}
c = parent.getComponent(9);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+304,152,24);}
c = parent.getComponent(10);
if (c.isVisible())
{c.setBounds(insets.left+24,insets.top+144,408,112);}
c = parent.getComponent(11);
if (c.isVisible())
{c.setBounds(insets.left+184,insets.top+304,56,24);}
c = parent.getComponent(12);
if (c.isVisible())
{c.setBounds(insets.left+160,insets.top+344,72,24);}
c = parent.getComponent(13);
if (c.isVisible())
{c.setBounds(insets.left+240,insets.top+344,104,24);}
c = parent.getComponent(14);
if (c.isVisible())
{c.setBounds(insets.left+352,insets.top+344,72,24);}
c = parent.getComponent(15);
if (c.isVisible())
{c.setBounds(insets.left+128,insets.top+40,112,24);}
c = parent.getComponent(16);
if (c.isVisible())
{c.setBounds(insets.left+128,insets.top+72,112,24);}
c = parent.getComponent(17);
if (c.isVisible())
{c.setBounds(insets.left+336,insets.top+40,96,24);}
c = parent.getComponent(18);
if (c.isVisible())
{c.setBounds(insets.left+336,insets.top+72,96,24);}
}
}
*******************************************************************************

Client Registration frame

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;

public class ClientRegistration extends Applet {
JLabel label_1;
JLabel label_2;
JLabel label_3;
JLabel label_4;
JLabel label_5;
JLabel label_6;
JButton button_1;
JButton button_2;
JButton button_3;
JTextField textfield_1;
JTextField textfield_2;
JTextField textfield_3;
JTextField textfield_4;
JTextField textfield_5;

public void init() {
ClientRegistrationLayout customLayout = new
ClientRegistrationLayout();

setFont(new Font("Helvetica", Font.PLAIN, 12));
setLayout(customLayout);

label_1 = new JLabel("Client Registration");
add(label_1);

label_2 = new JLabel("Client:");
add(label_2);

label_3 = new JLabel("Machine ID:");
add(label_3);

label_4 = new JLabel("Address:");
add(label_4);

label_5 = new JLabel("Phone No:");
add(label_5);

label_6 = new JLabel("E-mail:");
add(label_6);

button_1 = new JButton("Confirm");
add(button_1);

button_2 = new JButton("Delete");
add(button_2);

button_3 = new JButton("Exit");
add(button_3);

textfield_1 = new JTextField("");
add(textfield_1);

textfield_2 = new JTextField("");
add(textfield_2);

textfield_3 = new JTextField("");
add(textfield_3);

textfield_4 = new JTextField("");
add(textfield_4);

textfield_5 = new JTextField("");
add(textfield_5);

setSize(getPreferredSize());

}

public static void main(String args[]) {
ClientRegistration applet = new ClientRegistration();
Frame window = new Frame("ClientRegistration");

window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});

applet.init();
window.add("Center", applet);
window.pack();
window.setVisible(true);
}
}

class ClientRegistrationLayout implements LayoutManager {

public ClientRegistrationLayout() {
}

public void addLayoutComponent(String name, Component comp) {
}

public void removeLayoutComponent(Component comp) {
}

public Dimension preferredLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);

Insets insets = parent.getInsets();
dim.width = 511 + insets.left + insets.right;
dim.height = 220 + insets.top + insets.bottom;

return dim;
}

public Dimension minimumLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
return dim;
}

public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();

Component c;
c = parent.getComponent(0);
if (c.isVisible())
{c.setBounds(insets.left+8,insets.top+8,176,24);}
c = parent.getComponent(1);
if (c.isVisible())
{c.setBounds(insets.left+8,insets.top+48,96,24);}
c = parent.getComponent(2);
if (c.isVisible())
{c.setBounds(insets.left+8,insets.top+80,96,24);}
c = parent.getComponent(3);
if (c.isVisible())
{c.setBounds(insets.left+8,insets.top+112,96,24);}
c = parent.getComponent(4);
if (c.isVisible())
{c.setBounds(insets.left+264,insets.top+48,104,24);}
c = parent.getComponent(5);
if (c.isVisible())
{c.setBounds(insets.left+264,insets.top+80,104,24);}
c = parent.getComponent(6);
if (c.isVisible())
{c.setBounds(insets.left+216,insets.top+168,88,24);}
c = parent.getComponent(7);
if (c.isVisible())
{c.setBounds(insets.left+312,insets.top+168,104,24);}
c = parent.getComponent(8);
if (c.isVisible())
{c.setBounds(insets.left+424,insets.top+168,72,24);}
c = parent.getComponent(9);
if (c.isVisible())
{c.setBounds(insets.left+112,insets.top+48,96,24);}
c = parent.getComponent(10);
if (c.isVisible())
{c.setBounds(insets.left+112,insets.top+80,96,24);}
c = parent.getComponent(11);
if (c.isVisible())
{c.setBounds(insets.left+112,insets.top+112,328,24);}
c = parent.getComponent(12);
if (c.isVisible())
{c.setBounds(insets.left+376,insets.top+48,112,24);}
c = parent.getComponent(13);
if (c.isVisible())
{c.setBounds(insets.left+376,insets.top+80,112,24);}
}
}

0 new messages