Adding elements of one generic container to another

Hello,
I have the following problem. I have a class that can contain objects of various kinds, let's call it a Box. Since I'm implementing an algorithm that works the same no matter what's in the box, I thought I'd do something like this:
public class Box<E> extends Vector<E> {
    public void additionalMethod() { ... }
public interface BoxFactory {
    public Box<?> createBox();
public class IntegerBoxFactory implements BoxFactory {
    public Box<Integer> createBox() { ... }
public class RealBoxFactory implements BoxFactory {
    public Box<Double> createBox() { ... }
}etcetera. Then, the client class creates boxes using the factory without needing to know what is being created. However this turns out to be a problem since at some point I need to add the contents of one box to another, e.g.
public class Test {
    public void test() {
        BoxFactory factory = new RealBoxFactory();
        Example e = new Example( factory );     
public class Example {
    BoxFactory factory;
    public Example( BoxFactory f ) {
        factory = f;
        Box<?> b1 = f.createBox(),
                     b2 = f.createBox();
        mix( b1, b2 );
    public void mix( Box<?> b1, Box<?> b2 ) {
        b1.addAll( b2.subList( 1, 5 ) );
}This doesn't compile because clearly the contents of unknown type of one Box cannot be added to another, and neither does
    public void <E> mix( Box<E> b1, Box<E> b2 ) {
        b1.addAll( b2.subList( 1, 5 ) );
    }Since because b1 and b2 are both declared to be of Box<?>, the compiler can't know they contain the same type even if I do. So, I understand why this doesn't work, but I can't think of a way to make it work. Does anyone have any ideas?
Thanks
Matt

I'm sorry but I stubbornly keep thinking there must be another way to do it that doesn't oblige me to generify all the classes in the framework. And there is. Here's an ugly example of how, adapted from [one of Angelika Langer's FAQ entries|http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ207].
First, add to the container class a method that returns a type token that represents the container's element type so that we can retrieve the element type dynamically at run-time:
public abstract class Box<E> extends Vector<E> {
    public abstract Class<E> getElementType();
public class RealBox extends Box<Double> {
    public Class<Double> getElementType() { return Double.class; }
} Then, use a generic helper method to do the "mixing" (in this example):
public class Example {
    //adds a sublist of Box b2 to Box b1
    public void mix( Box<?> b1, Box<?> b2 ) {
        List<?> l = b2.subList( 0, 5 );
        for ( Object o : l )
            _add( b1, o );
    //adds Object o to Box b by retrieving the Box's run-time element type and then casting to it
    private <T> void _add( Box<T> b, Object o ) {
        b.add( b.getElementType().cast( o ) );
}This compiles and there are no unchecked warnings, and I don't need to generify the example class. Hurray. But this solution seems no better than the solution without generics. Also, it seems that Gilad Bracha's statement in the Generics tutorial
>
[generics] is designed to guarantee that if your entire application has been compiled without unchecked warnings using javac -source 1.5, it is type safe>
is not always true (but maybe this is old news), since the code above compiles without unchecked warnings using javac -source 1.6, but it is not type safe:
public class Example {
    public Example() {
        Box<?> b1 = new RealBox(),
               b2 = new IntegerBox();
        mix( b1, b2 ); //compiles fine but will cause a run-time error when trying to cast Integer to Double in method _add
}Anyway, if anybody knows of any other solutions other than generifying everything or employing this ugly solution, I'd be happy to hear it.

Similar Messages

  • Is there an easy way to replace individual elements in one string array from another striing array?

    I have a string array with elements as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 5E 00 00 00
       00 00 50 00 30 00 33 00
       34 00 39 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    The array I want to use to replace values with is:
    43 4E 31 30 30 33 30 30 31 41
    Where 43 goes in the 3rd row fifth position
    Where 4E goes in the 3rd row seventh position
    Where 31 goes in the 4th row  first position
    Where 30 goes in the 4th row third position
    Where 30 goes in the 4th row fifth position
    Where 33 goes in the 4th row seventh position
    Where 30 goes in the 5th row  first position
    Where 30 goes in the 5th row third position
    Where 31 goes in the 5th row fifth position
    Where 41 goes in the 5th row seventh position
    So the final array looks as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 43 00 4E 00
       31 00 30 00 30 00 33 00
       30 00 30 00 31 00 41 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    Is there an easy way to replace an element of a string within an array with another element of a string within a different array?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA (temp).vi ‏13 KB

    Try this
    Omar
    Message Edited by Omar II on 03-24-2010 03:25 PM
    Omar
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA%20(temp)[1].vi ‏17 KB

  • How to move entry from one container to another

    Hi!
    We are using DBMS_LDAP package to attempt to move an entry from an LDAP container to another container. We have tried modrdn2_s (takes a session, the old dn, the new dn, and a PLS_INTEGER indicating whether or not to delete the old entry; or at least this is our interpretation of what the function does).
    Attempting to move an entry with this function gives the following error(s):
    ORA-31202:DBMS_LDAP:LDAP client/server error: Constraint violation.
    00002081:AtrErr: DSID--031D0809, #1:
    0: 00002081: DSID-031D0809, problem 1005 (CONSTRAINT_ATT_TYPE), data 0,
    Att d(description)
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_LDAP", line 1455
    ORA-06512: at "SYS.DBMS_LDAP", line 929
    ORA-06512: at "OURSCHEMA.OURPKG", line 606
    ORA-06512: at "OURSCHEMA.OURPKG", line 88
    ORA-06512: at line 45
    I can't look at the SYS.DBMS_LDAP code since that is encrypted.
    I am currently researching ORA-31202 and talking with my LDAP/AD administrator. However I'm still wondering if this is the function that I should use for this. Does anyone know of any examples for what I'm attempting to do?
    Marc

    I spoke to my Active Directory administrator, and he suggested that I try to pass a new DN as an attribute in the modifications array passed to the DBMS_LDAP.modify_s function:
    --- Start of Code Sample ---
    -- create the modifications array
    v_mod_array := DBMS_LDAP.create_mod_array(n);
    -- set other attributes here
    -- set the new distinguished name here
    vl_mod_values(i) := v_new_dn;
    DBMS_LDAP.populate_mod_array(l_mod_array, DBMS_LDAP.MOD_ADD, 'distinguishedName', l_mod_values);
    -- then call the modify function (the modifications array has all the other attributes plus the new dn)
    DBMS_LDAP.modify_s(session, dn, v_mod_array);
    --- End of Code Sample ---
    The above fails too with an ORA-31202 error (which my AD administrator has not solved yet). Still my question is if my approach to moving my entry from one container to another is correct, or if I should be trying some other method. BTW, the directory structure looks like this:
    +<Domain>
    +--<DC=myorg,DC=test>
    ----+--<OU=Team>
    --------+--<OU=Headquarters>
    --------+--<OU=Terminated>
    etc, etc.
    I want to move the entry from the OU=Headquarters container to the OU=Terminated container.
    Any help is dearly welcomed!
    Marc

  • Adding and removing current user from one SharePoint group to another with event receiver

    hi friends
    i need to change current user from one SharePoint group to another with list item adding event receiver.
    please help me

    Hi Malli,
    Greetings. Its nt possible
    http://sharepoint.stackexchange.com/questions/42286/event-receivers-on-add-remove-users
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Moving Object from One container to another in workOrder Dri

    Hi , I am able to Move Object from One container to another container in workOrder Driver.
    here is my code which i am using
    <do-move-src-object class-name="ValeUser">
    <arg-dn>
    <token-local-variable name="var-str-nwoContent"/>
    </arg-dn>
    <arg-dn>
    <token-text xml:space="preserve">\</token-text>
    <token-global-variable name="dirxml.auto.treename"/>
    <token-text xml:space="preserve">\</token-text>
    <token-global-variable name="hrfeed.inactive.container"/>
    </arg-dn>
    </do-move-src-object>
    Thanks
    Adarsh Kumar

    Originally Posted by AndersG
    Idmlearner,
    > am able to Move Object from One container to another container
    > in workOrder Driver.
    >
    Possibly better asked in support.identity-manager
    - Anders Gustafsson (Sysop)
    The Aaland Islands (N60 E20)
    Novell has a new enhancement request system,
    or what is now known as the requirement portal.
    If customers would like to give input in the upcoming
    releases of Novell products then they should go to
    http://www.novell.com/rms
    Identity Manager - NOVELL FORUMS
    If you are not a nntp user.
    Thomas

  • JMS message from one application to the another appl in the same container?

    I have a question.
    Can I send JMS message from one application to the another application in the same container?
    If yes ...can you provide me info.
    I want to know in regards of EJB2.0 and EJB3.0.
    Thanks,
    Rahul

    So the receiver application is a Message Driven Bean, right?
    In your container, do you have a mean to ensure that it is correctly configured to listen the desired destination? Like an administrative console that would show the destinations, the number of pending messages, the number of active consummers...?
    btw what is the destination type? A queue or a topic?

  • Locked Objects when i try to copy elements from one folder to another

    Hi,
    Could anyone help me to resolve a lock problem in the portal-content studio? I try to copy elements (iviews or pages) from one package(folder) to another and the objects have been locked.
    How can I set another lock time different from the system time (36 000sek.)?
    and how should I copy this files/elements to avoid this locking situation?
    thx in advance

    hi
        to unlock the objects <system admin><monitoring>in detailed navigation <portal>drill down <object locking> u may check to unlock the objects..

  • Can one move one layer relative to another in Elements 11?

    Can one move one layer relative to another in Elements 11?

    Yes. Open the layers pallet:
    Window >> Layers
    You can drag layers up and own the stack. Wait until you see a blue line and then drop.

  • Hola!  How do I move an element of one picture to another?  PSE10, Windows 7.

    Please let me know how to move an element of one picture to another.  PSE10, Win. 7.

    Jona Lewa Koola wrote:
    Please let me know how to move an element of one picture to another.  PSE10, Win. 7.
    Select the "element" you want to "move" using any of the selection tools available in PSE and then either copy it using CTRL+C or Edit >> copy or cut it using CTRL+X or Edit >> Cut
    Now go to the other image and paste it using CTRL+V or Edit >> Paste
    if you cut it then it will "move" your "element" and remove from the original but if you copy and paste it then both images will have that copied item.
    After pasting it, you may need to move it to the correct location on the target image.
    Hope this helps.

  • Would it be possible to have 2 shared resources, one local containing all common topics and pictures for several projects, and another one remote containing all topics and pictures for collaboration purposes

    Hi,
    I was wondering, now that I discovered the advantages of Resource Manger, if it would be possible to have 2 shared resources, one local with common topics and pictures for several projects, and another one, remote, containing the whole projects, i.e. topics and pictures, for collaboration purposes.
    The local one I intend to use it for my purposes to have common items (topics & pictures) updated in all projects where they appear, and the remote one I intend to use it together with my remote colleagues that might want to do changes in the topics.
    This would mean that the common topics and pictures would be present in both resources, the local one as well as the remote one.
    Thank you.

    Thank you for your fast answer Rick.
    I was merely wondering if it would be possible w/o having to use other products outside RoboHelp.
    We are already using svn for a lot of other purposes and we are using that for the RoboHelp projects as well, however I was wondering if it would not be possible to have RoboHelp take care of the RoboHelp projects, and with svn to take care of the other things in the company.
    Eventually, if it would be possible, I would think to sync all the local projects with the remote projects, then sync the local project with the local shared resources, and at the end sync the rest of the projects with the local shared resources.

  • Ocrmirror gets added on one node not on another node 11gr2 RAC on AIX 5.3

    Hi,
    I created another external diskgroup for redundancy and added ocr on to it and got added successfully on node1 but not on another node in a two node cluster,please find the below outputs.
    node1:
    mvx20b:/>ocrcheck
    Status of Oracle Cluster Registry is as follows :
    Version : 3
    Total space (kbytes) : 262120
    Used space (kbytes) : 3064
    Available space (kbytes) : 259056
    ID : 1640695116
    Device/File Name : +CRS_DATA
    Device/File integrity check succeeded
    Device/File Name : +crs_data1                                        ------>newly added ocr
    Device/File integrity check succeeded
    Device/File not configured
    Device/File not configured
    Device/File not configured
    Cluster registry integrity check succeeded
    Logical corruption check succeeded
    node 2:
    mvx21b:/>ocrcheck
    Status of Oracle Cluster Registry is as follows :
    Version : 3
    Total space (kbytes) : 262120
    Used space (kbytes) : 3064
    Available space (kbytes) : 259056
    ID : 1640695116
    Device/File Name : +CRS_DATA
    Device/File integrity check succeeded
    Device/File not configured
    Device/File not configured
    Device/File not configured
    Device/File not configured
    Cluster registry integrity check succeeded
    Logical corruption check succeeded
    mvx20b:/home/gmvmxu1>cluvfy comp ocr -n all
    Verifying OCR integrity
    Checking OCR integrity...
    Checking the absence of a non-clustered configuration...
    All nodes free of non-clustered, local-only configurations
    ASM Running check passed. ASM is running on all cluster nodes
    Checking OCR config file "/etc/oracle/ocr.loc"...
    OCR config file "/etc/oracle/ocr.loc" check successful
    Disk group for ocr location "+CRS_DATA" available on all the nodes
    Disk group for ocr location "+crs_data1" available on all the nodes
    Checking OCR device "+CRS_DATA" for sharedness...
    Checking size of the OCR location "+CRS_DATA" ...
    mvx20b:Size check for OCR location "+CRS_DATA" successful...
    mvx21b:Size check for OCR location "+CRS_DATA" successful...
    Checking OCR device "+crs_data1" for sharedness...
    Checking size of the OCR location "+crs_data1" ...
    mvx20b:Size check for OCR location "+crs_data1" successful...
    mvx21b:Size check for OCR location "+crs_data1" successful...
    WARNING:
    This check does not verify the integrity of the OCR contents. Execute 'ocrcheck' as a privileged user to verify the contents of OCR.
    OCR integrity check passed
    Verification of OCR integrity was successful.
    mvx21b:/home/gmvmxu1>cluvfy comp ocr -n all
    Verifying OCR integrity
    Checking OCR integrity...
    Checking the absence of a non-clustered configuration...
    All nodes free of non-clustered, local-only configurations
    ERROR:
    PRVF-4194 : Asm is not running on any of the nodes. Verification cannot proceed.
    OCR integrity check failed
    Verification of OCR integrity was unsuccessful on all the specified nodes.
    SQL> select name,state,inst_id from gv$asm_diskgroup order by inst_id;
    NAME STATE INST_ID
    MVMXU1_DATA MOUNTED 1
    MVMXU1_REC MOUNTED 1
    CRS DISMOUNTED 1
    CRS_DATA MOUNTED 1
    CRS_DATA1 MOUNTED 1------mounted
    MVMXU1_REC MOUNTED 2
    MVMXU1_DATA MOUNTED 2
    CRS MOUNTED 2
    CRS_DATA MOUNTED 2
    CRS_DATA1 MOUNTED 2-------->mounted
    Please let me know where to look or how to add it to 2nd node.
    Thanks
    Edited by: user9097501 on Oct 21, 2010 6:37 AM
    Edited by: user9097501 on Oct 21, 2010 7:10 AM

    Issue got resolved with ML "The CRS Daemon Fails to Start with 'my hash ids don't match' in the Crsd.log [ID 855932.1] "
    Thanks

  • How do I make one window progress to another in swing

    Ive got to design a simple quizgame interface using Swing. Its got to have a player's front-end - gives a selection of questions where the user selects one of five answers, a scoring front-end - displayed after game that allows user to enter their name and a manager's front-end - used to enter questions. The thing is I only have to design the interface. I want to have a front window that leads to the managers front end, scoreboard, and game seperatley. I also want the system to report back when the players got the question wrong or right and then take them to a scoreboard. I dont know how to keep this all seperate from the normal code in the program being written by someone else. I also dont know how to make one window lead to another etc. Please can someone help. does anyone have some code I coulkd adapt for this purpose Im really stuck!!!

    Have a look at CardLayout. Rather than adding removing components, you can keep your three screens separate. Basically, you have three JPanels only one of which will be displayed at any one time. If one has textfields and you switch to another and then back, the text in the textfields will still be there.
    Here's some snippets from an application of mine:
    // set a 'container' panel to cardLayout. This will 'hold' the panels to be displayed at any one time
    private CardLayout cardDisplay;
    deck = new JPanel();
    cardDisplay = new CardLayout();
    deck.setLayout(cardDisplay);
    // add your various screens to the 'container' panel
    deck.add(logonPanel, "LogonPanel");
    deck.add(newUserPanel, "NewUserPanel");
    deck.add(bookingPanel, "BookingPanel");
    deck.add(printPanel, "PrintPanel");
    // add the 'container' panel to the contentPane
    c.add(deck, BorderLayout.CENTER);
    // switch the display, for example when a button is pressed, by using
    cardDisplay.show(deck, "NewUserPanel");
    cardDisplay.show(deck, "EnquiryPanel");

  • I dragged my notes from one iCloud account to another iCloud account and they disappeared.  How do I find them?

    I dragged my notes from one iCloud account to another iCloud account and they disappeared.  How do I find them?

    Hello reallilybart,
    Thank you for the question. You can export the calendar events from your previous iCloud account and then import them into your new iCloud account.
    First, use these steps to export your events from your original account and make note of where you save the file to:
    Export a calendar’s events
    In Calendar, click the calendar’s name.If you don’t see your calendars, click Calendars.
    Choose File > Export > Export.
    Choose a location for the file, and then click Export. The events are exported in an iCalendar (.ics) file.
    Next, quit the Calendar application, and log out of your original iCloud account in System Preferences > iCloud.  Then log in with your new iCloud account and open Calendar.  The final step is to import the file into the calendar for your new iCloud account
    Use these steps to import the calendar events:
    Import events into a calendar
    If you want, create a new calendar for the events.Add or delete a calendar
    Choose File > Import > Import.
    Locate and select the calendar file that contains the events, and then click Import.
    Choose the calendar you created or another calendar to add the events to.
    You can also drag a .ics file to Calendar. The events in the file are added to the calendar that’s highlighted in the Calendar list.
    You can find the full article here:
    Calendar: Export and import calendars
    http://support.apple.com/kb/PH11524
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Adding a window to a container: Error

    Hello there,
    Im facing a problem with my program.My program is about a Car Rental System and I am using GUI for the interface. From the main(CarRental) program,when user click one of the menu, there is another interface will appear for user to enter details.The problem is,my main (CarRental)program is running,click the first menu,then another interface open,but wen user enter details n click buttons , it is not even working. Below is my program:
    //This is main menu program
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import javax.swing.JFrame;
    public class CarRental extends JFrame implements ActionListener{
         JFrame f;
         JLabel l1,l2,l3,choice;
         JPanel p1,p2,p3,p4,p5,p6,p7,p8,p9;
         JButton btnA,btnB,btnC,btnD,btnE,btnF;
         Connection conn;
         Statement stmt;
         ResultSet rs;
         public CarRental(){
              p1=new JPanel();p2=new JPanel();p3=new JPanel();
              p4=new JPanel();p5=new JPanel();p6=new JPanel();
              p7=new JPanel();p8=new JPanel();p9=new JPanel();
              f=new JFrame("New Rental Record");
              l1=new JLabel("........::: Car Rental System :::.........");
              l2=new JLabel("*******************************************************");
              choice=new JLabel("Please select your option:");
              btnA=new JButton("[1] New Rental Record");
              btnB=new JButton("[2] Update Rental Record");
              btnC=new JButton("[3] Search Rental Record");
              btnD=new JButton("[4] Delete Rental Record");
              btnE=new JButton("[5] Display Rental record");
              btnF=new JButton("[6] Exit");
              l3=new JLabel("*******************************************************");
              f.setLayout(new GridLayout(10,1));
              f.pack();
              f.setVisible(true);
              f.setSize(350,500);
              f.setBackground(Color.white);
              p1.add(l1);f.add(p1);
              p2.add(l2);f.add(p2);
              p3.add(choice);f.add(p3);
              p4.add(btnA);f.add(p4);
              p5.add(btnB);f.add(p5);
              p6.add(btnC);f.add(p6);
              p7.add(btnD);f.add(p7);
              p8.add(btnE);f.add(p8);
              p9.add(btnF);f.add(p9);
              btnA.addActionListener(this);
              btnB.addActionListener(this);
              btnC.addActionListener(this);
              btnD.addActionListener(this);
              btnE.addActionListener(this);
              btnF.addActionListener(this);
         f.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e)
                        {System.exit(0);}});
              public void actionPerformed(ActionEvent e){
                        if(e.getSource()== btnA)
                        {     NewRecord nr=new NewRecord();}
                         else if(e.getSource()== btnB)
                        {     updateRecord ur=new updateRecord();}
                        else if(e.getSource()== btnC)
                        {     searchRecord sr=new searchRecord(); }
                        else if(e.getSource()== btnD)
                        {     deleteRecord dr=new deleteRecord(); }
                        else if(e.getSource()== btnE){
                             try{
                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                             catch(ClassNotFoundException e3) {
                                  JOptionPane.showMessageDialog(null,"ERROR:"+e3.getMessage());
                             try{
                                  conn=DriverManager.getConnection("Jdbc:Odbc:Car Rental", "", "");
                                  stmt=conn.createStatement();
                                  rs=stmt.executeQuery("Select * from Customer where CustID");
    String s=("CustID:   CustName:    CustAdd:          CustPhone:       No.of days rent:     Rate per rental: \n");
    while(rs.next())
    s=s+rs.getString(1)+"             "+rs.getString(2)+"              "+rs.getString(3)+"              "+rs.getString(4)+"                    "+rs.getString(5)+"                     "+rs.getString(6)+"\n";
                                       JOptionPane.showMessageDialog(null,s);}
    catch(SQLException e4){e4.printStackTrace();}}//end of F
    //to exit the program                    
    else if(e.getSource()== btnF){
    JOptionPane.showMessageDialog(null,"Thank you");System.exit(0);}
    else
    JOptionPane.showMessageDialog(null,"Invalid Option!");System.exit(0);
                   }//end of if statement
    public static void main(String args[]){
              CarRental cr= new CarRental();}//end of main
    }//end of main menu
    //New Rental program when user selects it
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class NewRecord extends JFrame implements ActionListener{
         JFrame f;
         Container c;
         FlowLayout layout;
         JLabel l1,l2,custId,custName,custAdd,custPhone,dayRent,rateRent;
    JTextField tid,tname,tphone,tday,trate;
                                  JTextArea tadd;
                                  JButton save,clear,exit;
                                  Connection conn;
                                  Statement stmt;
                                  ResultSet rs;
                                  JPanel p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11;
                             public NewRecord(){
                                //super("New Record");
                                  layout = new FlowLayout();
                                  c=getContentPane();
                                  c.setLayout(layout);
                                  p1=new JPanel();p2=new JPanel();p3=new JPanel();
                                  p4=new JPanel();p5=new JPanel();p6=new JPanel();
                                  p7=new JPanel();p8=new JPanel();p9=new JPanel();
                                  p10=new JPanel();p11=new JPanel();
                                  f=new JFrame();     
                                  l1=new JLabel("........::: New Rental Record :::.........");
                                  l2=new JLabel("*******************************************************");
                                  custId =new JLabel("Customer ID:");
                                  custName=new JLabel("Customer name:");
                                  custAdd=new JLabel("Customer address:");
                                  custPhone=new JLabel("Customer phone:");
                                  dayRent=new JLabel("Days of rental:");
                                  rateRent=new JLabel("Rate per rental:");
                                  tid= new JTextField(10);
                                  tname=new JTextField(10);
                                  tphone=new JTextField(10);
                                  tadd=new JTextArea(4,30);
                                  tday=new JTextField(5);
                                  trate=new JTextField(10);
                                  save=new JButton("SAVE");
                                  clear=new JButton("CLEAR");
                                  exit=new JButton("EXIT");
                                  f.setLayout(new GridLayout(11,1));
                                  f.setBackground(Color.white);
                                  f.setVisible(true);
                                  f.setSize(600,600);
                                  p1.add(l1);f.add(p1);
                                  p2.add(l2);f.add(p2);
                                  p3.add(custId);p3.add(tid);f.add(p3);     
                                  p4.add(custName);p4.add(tname);f.add(p4);
                                  p5.add(custAdd);p5.add(tadd);f.add(p5);
                                  p6.add(custPhone);p6.add(tphone);f.add(p6);                         
                                  p7.add(dayRent);p7.add(tday);f.add(p7);
                                  p8.add(rateRent);p8.add(trate);f.add(p8);
                                  p9.add(save);f.add(p9);
                                  p10.add(clear);f.add(p10);
                                  p11.add(exit);f.add(p11);
                             /*     f.add(l1);
                                  f.add(l2);
                                  f.add(custId);
                                  f.add(tid);
                                  f.add(custName);
                                  f.add(tname);
                                  f.add(custAdd);
                                  f.add(tadd);
                                  f.add(custPhone);
                                  f.add(tphone);
                                  f.add(dayRent);
                                  f.add(tday);
                                  f.add(rateRent);
                                  f.add(trate);
                                  f.add(save);
                                  f.add(clear);
                                  f.add(exit);*/
                                  c.add(f);
                                  save.addActionListener(this);
                                  clear.addActionListener(this);
                                  exit.addActionListener(this);
                                  f.addWindowListener(new WindowAdapter(){
                                  public void windowClosing(WindowEvent e)
                                       {System.exit(0);}});
                             public void actionPerformed(ActionEvent e){
                                  if(e.getSource()== exit)
                                       {System.exit(0);}
                                  if(e.getSource()== clear){
                                       tid.setText("");
                                       tname.setText("");
                                       tadd.setText("");
                                       tphone.setText("");
                                       tday.setText("");
                                       trate.setText("");}
                                  if(e.getSource()== save){
                                       try{
                                            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                       catch(ClassNotFoundException e1) {
                                            JOptionPane.showMessageDialog(null,"ERROR:"+e1.getMessage());
                                       try{
                                            conn=DriverManager.getConnection("Jdbc:Odbc:Car Rental", "", "");
                                            stmt=conn.createStatement();
                                            rs=stmt.executeQuery("Select * from Customer");
                                            while(rs.next()){
                                            tid.setText(rs.getString(1));
                                            tname.setText(rs.getString(2));
                                            tadd.setText(rs.getString(3));
                                            tphone.setText(rs.getString(4));
                                            tday.setText(rs.getString(5));
                                            trate.setText(rs.getString(6));}
                                            String s=("CustID:   CustName:    CustAdd:          CustPhone:       No.of days rent:     Rate per rental: \n");
                                            while(rs.next())
                                            s=s+rs.getString(1)+"             "+rs.getString(2)+"              "+rs.getString(3)+"              "+rs.getString(4)+"                    "+rs.getString(5)+"                     "+rs.getString(6)+"\n";
                                                 JOptionPane.showMessageDialog(null,s);
                                       catch(SQLException e2){
                                                 e2.printStackTrace();
                             public static void main(String args[]){
                                       NewRecord nr=new NewRecord();
                                  //     nr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                                       }//end of newRecord class
                                  }//ends of New rental program
    I tried to use extending to JPanel or JApplet but still the same. Any help??

    Hi,
    In the NewRecord java file, use change the
    f = new JFrame();               
    c = f.getContentPane();, after that all panel add into the container
    p1.add(l1);c.add(p1);                    
    p2.add(l2);c.add(p2);
    p3.add(custId);p3.add(tid);c.add(p3);     
    p4.add(custName);p4.add(tname);c.add(p4);
    p5.add(custAdd);p5.add(tadd);c.add(p5);
    p6.add(custPhone);p6.add(tphone);c.add(p6);          
    p7.add(dayRent);p7.add(tday);c.add(p7);
    p8.add(rateRent);p8.add(trate);c.add(p8);
    p9.add(save);c.add(p9);
    p10.add(clear);c.add(p10);
    p11.add(exit);c.add(p11);and finally remove this line below
    //c.add(f);Try to avoid add frame into the container, or else you will receive adding a window to a container error.
    Rgrds,
    Sen
    Message was edited by:
    arjensen

  • Transferring Development from One SAP system to another?

    I was wondering if it was possible to transfer an entire Package or a Transport with its development contents from one SAP system to another?
    It would be preferred if the method doesn't require connectivity, like for example to be able to export everything in a package to an XML-file that could be imported into an empty package on another system.
    It would need to handle all development parts, such as Reports, Function Modules, Classes, Special Classes (such as Exception Classes), Shared Objects and Persistent Objects (Yes, I like objects ), Unit Tests, Data Dictionary definitions for tables, table types, structures, data elements and so forth.
    It this in any way possible?

    Hi
    I believe u can only create a request containing all abap object of the package: u can do it by SE80.
    After releasing the request u need to pick up the data file and the cofile and past these files to the target system.
    So u can add and then import the your request in the queue of the development of the target system by trx STMS.
    Probably u need to ask a little help to your basis in order to copy and past the files from and to SAP server (I don't know if you've the authorizations).
    The name of datafile is like D<request number>.<system id>
    and the path
    /usr/sap/trans/<SYSTEM ID>/data
    the cofile name is K<request number>.<system id>
    and the path
    /usr/sap/trans/<SYSTEM ID>/cofile
    Max

Maybe you are looking for