Calling a user defined class

I have different class files that do their specific work. So, in another separate files, i want to call them when certain buttons are pressed. can anybody help me?

thanks again. i have now understood how i should be. but the problem is: in my frame1.java, i don't have the 'doSomthing()' or such kind of method directly because, i had to inherit another method called connection() in that file from another class file called 'javacc' so, here is how the code goes:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import java.text.*;
class frameB extends JFrame implements ActionListener
JLabel lblCompany, lblSlogan, lblCaption, lblInstruction, lblCompNo, lblUserID, lblStartTime, lblRemarks;
JTextField jtfCompNo, jtfUserID, jtfStartTime, jtfRemarks;
JButton btnOk, btnCancel, btnStart;
String sCompNo, sUserID, sStartTime, sRemarks;
String dateOut;
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
java.util.Date today;
frameB() //constructor of the class
     Font Font1, Font2, Font3, Font4;
     Font1 = new Font("Comic Sans MS", Font.PLAIN, 25);
     Font2 = new Font("Comic Sans MS", Font.ITALIC, 16);
     Font3 = new Font("verdana", Font.PLAIN, 10);
     Font4 = new Font("verdana", Font.PLAIN, 11);
     lblCompany=new JLabel("Cyber World");
     lblCompany.setFont(Font1);
     lblSlogan=new JLabel("Connect with the net...");
     lblSlogan.setFont(Font2);
     lblCaption=new JLabel("using Cyber Manager");
     lblCaption.setFont(Font3);
     lblInstruction=new JLabel("Enter the log in time...");
     lblInstruction.setFont(Font4);
     lblCompNo=new JLabel("Computer No.");
     lblCompNo.setFont(Font4);
     lblUserID=new JLabel("User ID");
     lblUserID.setFont(Font4);
     lblStartTime=new JLabel("Start Time");
     lblStartTime.setFont(Font4);
     lblRemarks=new JLabel("Remarks");
     lblRemarks.setFont(Font4);
     jtfCompNo=new JTextField(5);
     jtfUserID=new JTextField(10);
     jtfStartTime=new JTextField(10);
     jtfRemarks=new JTextField(15);
     btnOk=new JButton("OK");
     btnOk.setFont(Font4);
     btnCancel=new JButton("Cancel");
     btnCancel.setFont(Font4);
     btnStart=new JButton("Start");
     btnStart.setFont(Font4);
     Container c=getContentPane(); //creating the container
     c.setLayout(null);
     lblCompany.setBounds(125,20,300,30);//setting the places of the components in the frame
     lblSlogan.setBounds(120,50,200,20);
     lblCaption.setBounds(129,75,150,20);
     lblInstruction.setBounds(40,110,200,20);
     lblCompNo.setBounds(40,160,100,20);
     lblUserID.setBounds(40,190,100,20);
     lblStartTime.setBounds(40,220,100,20);
     lblRemarks.setBounds(40,250,100,20);
     jtfCompNo.setBounds(150,160,100,20);
     jtfUserID.setBounds(150,190,100,20);
     jtfStartTime.setBounds(150,220,100,20);
     jtfRemarks.setBounds(150,250,100,20);
     btnOk.setBounds(145,300,70,30);
     btnCancel.setBounds(230,300,90,30);
     btnStart.setBounds(50,300,80,30);
     c.add(lblCompany);//adding the components to the container
     c.add(lblSlogan);
     c.add(lblCaption);
     c.add(lblInstruction);
     c.add(lblCompNo);
     c.add(lblUserID);
     c.add(lblStartTime);
     c.add(lblRemarks);
     c.add(jtfCompNo);
     c.add(jtfUserID);
     c.add(jtfStartTime);
     c.add(jtfRemarks);
     c.add(btnOk);
     c.add(btnCancel);
     c.add(btnStart);
     btnOk.addActionListener(this);
     btnCancel.addActionListener(this);
     btnStart.addActionListener(this);
     setSize(400,400); //size of the frame
     show(); //this shows or displays the frame
     public void actionPerformed(ActionEvent ae)
          if(ae.getSource()==btnStart)
               today = new java.util.Date();
               dateOut = formatter.format(today);
               jtfStartTime.setText(""+dateOut);;
          if(ae.getSource()==btnOk)
               insertData();
          else if (ae.getSource()==btnCancel)
               return;
     class DoWork extends javacc //innerclass to to extend and use another interface
     {                                   // because only one can be inherited in one class
          public void insert()
               readinput();
               if (sCompNo.length()==0)
                    JOptionPane.showMessageDialog(null,"Computer Number is empty");
                    jtfCompNo.requestFocus();
                    return;
               if(sUserID.length()==0)
                    JOptionPane.showMessageDialog(null,"User ID is empty");
                    jtfUserID.requestFocus();
                    return;
          if(sStartTime.length()==0)
                    JOptionPane.showMessageDialog(null,"Start Time is empty");
                    jtfStartTime.requestFocus();
                    return;
          if(sRemarks.length()==0)
                    sRemarks = "N/A";
java.util.Date today;
String dateOut;
DateFormat dateFormatter;
dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);
today = new java.util.Date();
dateOut = dateFormatter.format(today);
JOptionPane.showMessageDialog(null,""+dateOut);
          String abc="insert into transact values('"+dateOut+"',"+sCompNo+","+sUserID+",'"+sStartTime+"','"+0+"','"+0+"',"+0+",'"+sRemarks+"')";
          connection();
          try
               stmt.executeUpdate(abc);
          catch(SQLException sqlExep)
          JOptionPane.showMessageDialog(null,"Data is inserted!!");
}//end of insert
public void readinput()
     sCompNo = jtfCompNo.getText();
     sUserID = jtfUserID.getText();
     sStartTime = jtfStartTime.getText();
     sRemarks = jtfRemarks.getText();
}//end of inner class DoWork
public void insertData()
          DoWork dw=new DoWork();
          dw.insert();
}//end of outer class frameB
public class frame2
     public static void main(String args[])
          frameB frm = new frameB();
hope you understand me.
thanks once again. i am learning a lot of things.

Similar Messages

  • How to import user defined class in UIX page?

    Does anyone know how to import user defined class in UIX page so that the class can be called in the javascript in the UIX ?
    Thks & Rgds,
    Benny

    what you are referring to is not javascript.
    it is JSP scriptlets. These are very different.
    In order to keep a strict separation between View and Controller, it is not possible to run arbitrary java code from within your UIX code.
    However, you can run java code from within a UIX event handler; see:
    http://otn.oracle.com/jdeveloper/help/topic?inOHW=true&linkHelp=false&file=jar%3Afile%3A/u01/app/oracle/product/IAS904/j2ee/OC4J_ohw/applications/jdeveloper904/jdeveloper/helpsets/jdeveloper/uixhelp.jar!/uixdevguide/introducingbaja.html
    event handler code is run before the page is rendered.

  • Pass an array of a user defined class to a stored procedure in java

    Hi All,
    I am trying to pass an array of a user defined class as an input parameter to a stored procedure. So far i have done the following:
    Step 1: created an object type.
    CREATE TYPE department_type AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    Step 2: created a varray of the above type.
    CREATE TYPE dept_array1 AS TABLE OF department_type;
    Step 3:Created a package to insert the records.
    CREATE OR REPLACE PACKAGE objecttype
    AS
    PROCEDURE insert_object (d dept_array);
    END objecttype;
    CREATE OR REPLACE PACKAGE BODY objecttype
    AS
    PROCEDURE insert_object (d dept_array)
    AS
    BEGIN
    FOR i IN d.FIRST .. d.LAST
    LOOP
    INSERT INTO department
    VALUES (d (i).dno,d (i).name,d (i).location);
    END LOOP;
    END insert_object;
    END objecttype;
    Step 4:Created a java class to map the columns of the object type.
    public class Department
    private double DNO;
    private String Name;
    private String Loation;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLoation(String Loation)
    this.Loation = Loation;
    public String getLoation()
    return Loation;
    Step 5: created a method to call the stored procedure.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1); d1.setName("Accounts"); d1.setLoation("LHR");
    Department d2 = new Department();
    d2.setDNO(2); d2.setName("HR"); d2.setLoation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false); //using a framework to get connections
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray); //I get an SQLException here
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){ 
    System.out.println(e.toString());
    I get the following exception:
    java.sql.SQLException: Fail to convert to internal representation
    My question is can I pass an array to a stored procedure like this and if so please help me reslove the exception.
    Thank you in advance.

    OK I am back again and seems like talking to myself. Anyways i had a talk with one of the java developers in my team and he said that making an array of structs is not much use to them as they already have a java bean/VO class defined and they want to send an array of its objects to the database not structs so I made the following changes to their java class. (Again hoping some one will find this useful).
    Setp1: I implemented the SQLData interface on the department VO class.
    import java.sql.SQLData;
    import java.sql.SQLOutput;
    import java.sql.SQLInput;
    import java.sql.SQLException;
    public class Department implements SQLData
    private double DNO;
    private String Name;
    private String Location;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLocation(String Location)
    this.Location = Location;
    public String getLoation()
    return Location;
    public void readSQL(SQLInput stream, String typeName)throws SQLException
    public void writeSQL(SQLOutput stream)throws SQLException
    stream.writeDouble(this.DNO);
    stream.writeString(this.Name);
    stream.writeString(this.Location);
    public String getSQLTypeName() throws SQLException
    return "DOCCOMPLY.DEPARTMENT_TYPE";
    Step 2: I made the following changes to the main method.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1);
    d1.setName("CPM");
    d1.setLocation("LHR");
    Department d2 = new Department();
    d2.setDNO(2);
    d2.setName("Admin");
    d2.setLocation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false);
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray);
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_array_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){
    System.out.println(e.toString());
    and it started working no more SQLException. (The changes to the department class were done manfully but they tell me JPublisher would have been better).
    Regards,
    Shiraz

  • User defined classes

    Hi,
    I need to create a project which requires the application to have user defined classes. I am thinking of creating a Timer class which is imported into the main application and shown on the screen. Is this what a user defined class is, by importing another made class into the main class of the application?
    Thanks for your help.

    There are two basic types of classes in Java, ones written by someone else, and ones written by you.
    The ones you write may use the ones other people write (like the classes that come with the SDK) or may use the other ones you write, or even better, both.
    In Java there is no concept of a "main application". But there is a static method in a class your write that you call "main" and is special because it's the method that gets called by the java runtime when you tell it to load your class. i.e., it's the starting point of your application. In fact, you can have many classes in your collection of classes that make up an application with a main method and you can have java start with any one of these classes.
    Hope this helps.

  • Clone a user defined class..

    Hello all,
    just curious to know how can I copy/clone an instance of a class that I cant change/rebuild? I have gone thru the forums and I understand that to be able to clone a class-instance, the class itself should implement Cloneable or apply the deep-copy technique as mentioned in one of the JavaWorld pages but, as I said, what happens in a case where one has no access to the class code?
    however, if these are the only ways to have a user defined class cloned then, it should be possible to avoid a clone/copy situation... I dont know how. Does anyone else know?
    I have tried with few examples to understand what a shallow/deep copy is.
    the curiosity is terribly grown once I heard from one of my colligues that this is very much (easily) possible in c++ and delphi!!!
    please clarify. thanks in advance!

    Object.clone() is native and create a copy by ignoring all access checks (native code have access to everything by default), therefore copying all fields in the new object. All you have to do is implements Cloneable. Overload the method if you want it to be public and then just call super.clone() or if you don't want to copy everything you have to deal with it manually, copy all the fields you need. If you don't have access to all members you have to use reflection and suppress the access checks.

  • An array of vectors that contain a user defined class gives: warning: [unch

    I've read two tutorial on Generics and still don't get everything.
    Anyway I have a user defined class called a Part. I have some Vectors of Part objects, and these Vectors of Part objects are stored in an Array of Vectors.
    Amazingly, I got all the checking right so far; however, am now trying to loop through my Array, an pass the individual Vectors to a method:
    //create a single list of all parts numbers
    //add the part number from each vector/part into a new vector of strings
    for(int y=0; y < ArrayOfPartVectors.length; y++) {
        Vector<Part> vTemp = ArrayOfPartVectors[y];
        vAllPartNumbers.addAll(pm.getPartNumbersFromVector(vTemp));
    }I get the following warning:
    com\gdls\partMatrix\PartMatrix.java:75: warning: [unchecked] unchecked conversion
    found   : java.util.Vector
    required: java.util.Vector<com.gdls.partMatrix.Part>
                                    Vector<Part> vTemp = VectorArrayParts[y];
                                                                         ^
    1 warningNow I have put the 'check' (<Part>) in every concievable spot in that statement, and I get a compler error now instead of a warning.
    Any guidance would be appreciated.
    Thank you,

    The problem is not with Vector. If you want to use it that's fine.
    You could also want to use ArrayList because the class is roughly equivalent to Vector, except that it is unsynchronized.
    But your problem is that arrays and generics don't mix well as previously mentioned in the first reply.
    You did not specify the type of ArrayOfPartVectors but I guess it is Vector[], not Vector<Part>[], right?
    So you'll have an unchecked warning when doing the conversion from Vector to Vector<Part> in the assignment within the loop.
    Maybe you tried to use a ArrayOfPartVectors of type Vector<Part>[] instead but found it impossible to create it with new
    You can do it with Array.newinstance() but you'll get an unchecked warning at this line instead of later.
    So mixing generics and arrays will allways result in warnings.
    You should read: [url http://www.angelikalanger.com/Articles/Papers/JavaGenerics/ArraysInJavaGenerics.htm]Arrays in Java Generics.
    Regards

  • Calling a user defined function as default value for a column

    Hi All
    Can we call a user defined function as default value for a column ??
    for example:
    create or replace  function test1  return number is
    begin
    return 10;
    end;
    create table testt
    (id  as test1,
      name varchar2(20));
    getting error:
    Error at line 1
    ORA-02000: missing ( keywordThanks
    Ashwani
    Edited by: Ashwani on Jan 16, 2012 1:19 AM

    Hi;
    For your issue i suggest close your thread here as changing thread status to answered and move it to Forum Home » Database » SQL and PL/SQL which you can get more quick response
    Regard
    Helios

  • Cannot comile user defined classes

    Hello i have a problem on compiling user defined classes .
    example
    file x.java
    public class x{
    file y.java
    import x;
    public class y{
    I first compile x.java and everything is OK .
    Then i compile y.java and the compiler gives the folowing
    y.java:2: '.' expected
    import y
    I have tried to put the classes on a package and added the folowing line yo each file
    import /home/bill/test
    Then i puted the java files on that dir
    and compiled with
    javac -classpath /home/bill/test y.java
    AGAIN THE SAME
    y.java:2: '.' expected
    import y
    WHAT I DO WRONG PLEASE HELP!!!!!!!!!!!!

    1. Since J2SDK 1.4, you can not import classes that are in the default (or unnamed) package. You are getting the error because the compiler expects something after y like y.*;
    2. You do not need to import classes that are in the same package, and all classes in the default package are in the same package.
    In your case, your classes are in the default package so remove the import statement.

  • How to put a user defined class in Web dynpro

    How and where can we create some user defined classes?
    For example i wanted to create some utility classs for my project. Under what folder should i create this?

    Please create the .java files under src folder of the project
    Go to PackageExplorer->expand the project->select src/packages and create the package under this and create java file.
    Regards, Anilkumar

  • User defined class  for Web Services

    I am trying to use the Web Service Publishing Wizard to publish
    a class as a web service. The wizard will not allow me to select
    the method I wish to publish. When I click on the "Why Not?"
    button the message says:
    "One or more parameters did not have an XML Schema mapping
    and/or serializer specified"
    I use user defined classes as parameters of the methods of the service web.
    How cam i install this web service on "Oracle J2EE Web services"?

    If you use Java Beans (or single dimension arrays of Java Beans) that implement the java.io.serializable interface as per this article:
    http://otn.oracle.com/tech/webservices/htdocs/samples/customtype/content.html
    then Oracle9iAS will handle the publishing process of custom data types. The publishing wizard in Oracle9i JDeveloper 9.0.2 doesn't support this yet, but the link in the article to the JDeveloper help gives a fairly straightforward workaround. This workaround will be eliminated in Oracle9i JDeveloper 9.0.3 (due late August).
    Does representing your parameters as Java Beans work for your problem?
    Mike.

  • Class Data Sharing for User Defined Classes

    i am using jdk 5.0 . JDK 5.0 supports class data sharing for system level classes. Is there any way a class data sharing be done for a user defined class?

    Samantha10 wrote:
    Is this class data sharing possible for user defined classes also? i have a singleton class which i am invoking through a script. The script has been scheduled to run every 1 sec . Since it is being invoked every 1 sec hence the singleton pattern is failing . Hence if the this class data sharing is possible then the singleton pattern can be made applicable.If you have a single process and you have a single class loaded by two different ClassLoader instances
    in some respects they will be two different classes
    if (class1 instanceof class2.getClass())returns false.
    This is not the case for Java core classes because they are always loaded by the SystemClassLoader.
    You write you
    have a singleton class which i am invoking through a script. What approach to you use to invoke the singleton?
    I am trying to figure out if you launch a new JVM every second...
    Maybe you can use Nailgun.

  • Identifying APIs & user-defined classes

    I have a class name in a string variable. Is it possible to identify whether that class is a Java API or user-defined class ? Please note that the identification has to be done thru code not manually.

    There is no clear distinction between Java API and user defined classes. What I mean is there is no rule to limit user to use java.util as their package name and create their own classes like java.util.CustomCollection. Although that is not recommended at all, but nothing prevents it. There is sun.* package which implements most of the java.* classes, do you consider those Java API? And there are third party classes such as org.omg.* etc. All these classes including user defined classes are treated equally with the JVM.
    So there is no clear distinction. The only thing you can do is to define a list of class names you consider Java API.
    Why do you want to seperate them if I may ask? Since the JVM doesn't care.
    --lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • User defined class objects for a ADF component (button,inputfield)

    How do I define a user defined class object for ADF objects?
    My requirement is that when I do a modification to the class object, it should get reflectected to all the instances on my page.
    E.g:- I'm having class object clsInputField, and all my input fields in my pages are based on this object. So when I change clsInputField it should get reflected to all my controls based on this class object.
    Please help!!!

    Hi Timo,
    In our client server environment, we have a custom control for managing the zip code (used a Custom InputText field which extends the actual TextField) . All zip code specific validations are written in this custom class. In our application many of the pages uses this Custom component. So if any of the zipcode specific behaviour changes, we could implement this by only changing the Custom InputText field class.
    We need to implement this behaviour in our ADF applications. Please advise.
    Thanks,
    Vishnu

  • Call a user defined method in web dynpro from interactive forms

    Hi All,
    how to call a user defined method in web dynpro java, when a selecting value from drop down list which is in interactive forms by adobe
    thanks.
    Edited by: venkat99 on May 24, 2010 4:52 PM

    Well, you can use F4 help, of course, check here: http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/a1900622ec062be10000000a42189d/frameset.htm
    You need to select the value first and then use the submit button, which is mapped to the WD action submit (you have to set this up in WD designer!!). To use the submit button for more actions, you need to use something like a hidden field, where the value is set according to the action you want to do with your submit button. The submit sends this value back to WD, where you can switch the program code according to the value.
    Otto
    p.s.: and maybe this blog can help: /people/shruti.rathour/blog/2008/02/07/uploading-sap-interactive-form-on-the-abap-webdynpro-view

  • Loading the user defined class file

    Hai,
    Is there any way to load the user defined class at the time of starting my Jakarta Tomcat server.
    Regards
    ackumar

    Hi!!
    Hope, <load-on-startup> tag of web.xml helps in
    s in this regard.I think this tag is to load servlet. I am talking about loading a user defined class file for example xyz.class which is no a servlet just a class file.
    Regards
    ackumar

Maybe you are looking for

  • Best practice to monitor 10gR3 OSB performance using JMX API?

    Hi guys, I need some advice on the best practice to monitor 10gR3 OSB performance using JMX API. Jus to show I have done my home work, I managed to get the JMX sample code from http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/jmx_monitoring

  • Odd WindowsXP networking issues

    Well, previously I had no trouble accessing the shared folders on my PC from my iMac. Somewhere along the way, things stopped working properly, but I was never able to point to any specific event that preceded the problem. The Mac can see the PC and

  • Please help (oracle Financial logon problem)

    any body help me to logon in oracle financial application rel 11 .when i enter username password in his interface he gave me erro INVALID APPLICATION USERNAME .please give its proper solution please send me mail or give answer thanks

  • Scrollbar issues

    Hi, I recently created a site and placed a layer with some text inside it on one of the pages. Problem is the text is justified and it seems that Dreamweaver stretches (justifies) it to such an extreme that the words look like they are moving in unde

  • Windows 8 Compatability

    I am running Windows 8 Release Preview-Evaluation Copy. Build 8400. Is Firefox compatible with Windows 8? For weeks now, I have been having a problem with downloads and delays. On fresh install, I have decent speeds, but after a day or two, speeds bo