Putting a panel using null layout in in a JScrollPane

Hi,
I'm trying to create a form for the screen which looks exactly like its equivalent on paper. The form has a grid of cells that can be typed into.
My approach so far has been to use a JTextPane for each cell and use absolute positioning to put these onto a JPanel with a null layout.
This has worked well so far, but the JPanel is taller than the screen so I want to put it inside a JScrollPane.
However the scrollbars don't show up.
Can someone point out what I need to implement to be able to scroll my null layout JPanel in a JScrollPane.
Thanks.

That was nice and simple. The Duke's are yours.
One problem leads to another unfortunately.
I want the form to be centered so I put it in another JPanel with BorderLayout then put that in the JScrollPane. Unfortunately it is not centred.
JPanel nullLayoutPanel = new JPanel();
nullLayoutPanel.setLayout(null);
// layout components on panel
JPanel panelToKeepFormCentered= new JPanel(new BorderLayout());
panelToKeepFormCentered.add(nullLayoutPanel, BorderLayout.CENTER);
JFrame frame = new JFrame();
frame.getContentPane().add(new JScrollPane(panelToKeepFormCentered));Hope it is clear what I'm trying to achieve.
When the JFrame is smaller than the form (the nullLayoutPanel), scrollbars should show (they do now thanks to Noah).
When the JFrame is bigger than the form, the form's JPanel should be centred in the JFrame with blank space around.
Thanks.

Similar Messages

  • Using null Layout - Problems

    Hullo - I've written a little app that, because of the nature of what it does, prettymuch requires the use of null layout. It works well enough, but there are a few points where it does strange things that I don't understand. I haven't been able to find any good docs anywhere for how exactly layout/rendering works. The Swing tutorial, for example, almost completely ignores the topic.
    Basically, I set the layout to null, add my components, use setBounds...but then nothing happens. In order for anything to be visible, I have to call pack() before I call show(). What is pack? What does it do? How can Sun's null layout examples work even though most of them don't use it?
    Second, if I create JFrame of a certain size, and add a component that goes off the bottom of the JFrame (on purpose), then expand the size of the JFrame to reveal the bottom part of that component, it doesn't paint - there's just a grey area. No amount of repaint() pack() or anything will cause it to show. The only way I've found to do it is to make the JFrame larger to begin with, add the component so that it's visible, then resize to the smaller size, which is kind of ugly and clunky.
    I basically do not understand why Swing is doing the things it does; why it paints sometimes and not other times, where it paints, when it paints, where it shows objects, how it packs them, etc. I would be very grateful if someone could englighten me!

    Hullo - I've written a little app that, because of the
    nature of what it does, prettymuch requires the use of
    null layout. It works well enough, but there are a
    few points where it does strange things that I don't
    understand. I haven't been able to find any good docs
    anywhere for how exactly layout/rendering works. The
    Swing tutorial, for example, almost completely ignores
    the topic.
    Basically, I set the layout to null, add my
    components, use setBounds...but then nothing happens.
    In order for anything to be visible, I have to call
    pack() before I call show(). What is pack? What
    does it do? How can Sun's null layout examples work
    even though most of them don't use it?
    Second, if I create JFrame of a certain size, and add
    a component that goes off the bottom of the JFrame (on
    purpose), then expand the size of the JFrame to reveal
    the bottom part of that component, it doesn't paint -
    there's just a grey area. No amount of repaint()
    pack() or anything will cause it to show. The only
    way I've found to do it is to make the JFrame larger
    to begin with, add the component so that it's visible,
    then resize to the smaller size, which is kind of ugly
    and clunky.
    I basically do not understand why Swing is doing the
    things it does; why it paints sometimes and not other
    times, where it paints, when it paints, where it shows
    objects, how it packs them, etc. I would be very
    grateful if someone could englighten me!Okay, I think you should call setVisible(true); instead of pack then show. Pack basically organizes the components so they take up the least amount of room, and then it shrinks the frame to as small as it will go without hiding any components. It think if you call revalidate() instead of repaint(), should solve your problem.
    The other thing to do, is (hehe) make your own components

  • Using CardLayout and Null Layout

    I used search on the forums and found one person that asked the exact question I'm needing answered. But, he didn't get any responses either.
    I have a JFrame(myJFrame) which has a JPanel(myJpanel). myJpanel uses a CardLayout. I then have another class that extends JPanel(TestJpanel). TestJpanel uses a null layout. I am not able to get the TestJpanel to show correctly with the show(). method. However, if I change the layout of TestJpanel to anything else, presto it works. Has anyone uses null panels as the panels for a cardlayout panel?

    if you do setLayout(null) the component will leave all layout up to you. You can then use setSize(), setLocation(), and setBounds() on all children to position them however you'd like

  • How do I use different Layouts?

    I am trying to make a program that runs in a window like this:
    http://www.exyt-web.com/Window.gif
    The problem I'm having is with the layout.
    How do I have more than one layout ?
    For example - as you can see in the image (hyperlink above) I wish to have a border layout with a JFrame at the North position and then in the South position I want to have buttons laid out in a FlowLayout.
    Also with my radio buttons I want these in a GridLayout(3, 0) layout.
    I made up some example code to test using different layouts - but it seems one layout always overrides the other...
    import java.awt.*;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class LayoutTest extends JFrame
        public LayoutTest()
            setTitle("Hello World");
            Container contents = getContentPane();
            Container contents2 = getContentPane();
            contents.setLayout(new FlowLayout());
            contents.add(new JLabel("<FILTER [Type a th|    ]>"));
            contents.add(contents2);
            contents.add(new JLabel("< Filter Button >"));
            contents.add(new JLabel("<  Add Button   >"));
            contents2.setLayout(new GridLayout());
            contents2.add(new JLabel("< Button 1 >"));
            contents2.add(new JLabel("< Button 2 >"));
            contents2.add(new JLabel("< Button 3 >"));
            contents2.add(new JLabel("< Button 4 >"));
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();
        } // HelloWorld
        public static void main(String [] args)
            LayoutTest theLayoutTest = new LayoutTest();
            theLayoutTest.show();
        } // main
    } // class HelloWorldI know this obviously doesn't work but I hoped it would show what I was trying to do.
    I also tried creating a new 'contents2' and then adding it into 'contents'
    e.g. contents.add(contents2); My current code for the window I'm trying to create so far is:
    import java.awt.*;
    import javax.swing.*;
    public class Menus extends JFrame
        public static void Menus()
            // Creates a new JFrame, with the title specified in quotation marks.
            JFrame frame = new JFrame("Film Database");
            // Sets the default close operation of the frame.
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // Creates a new menu bar for the frame.
            JMenuBar menuBar = new JMenuBar();
            // Creates a new menu for the menu bar.
            JMenu menu = new JMenu("File");
            addFrameContents(frame, menuBar, menu);
            // Sets the new menu bar on the frame
            frame.setJMenuBar(menuBar);
            frame.pack();
            frame.setVisible(true);
        } // HelloWorld
        public static void addFrameContents(JFrame frame, JMenuBar menuBar, JMenu menu)
            // Adds the menu to the menu bar.
            menuBar.add(menu);
            // Creates a new item for the menu with a small icon.
            JMenuItem menuLoad = new JMenuItem("Load", new ImageIcon("C:/load.gif"));
            // Adds the new item to the menu.
            menu.add(menuLoad);
            JMenuItem menuSave = new JMenuItem("Save", new ImageIcon("C:/save.gif"));
            menu.add(menuSave);
            JMenuItem menuQuit = new JMenuItem("Quit", new ImageIcon("C:/quit.gif"));
            menu.add(menuQuit);
            // Creates a new container.
            Container contents = frame.getContentPane();
            // Sets a new layout for contents, in this case FlowLayout.
            contents.setLayout(new GridLayout(2, 0));
            // Adds new JLabels to the container.
            contents.add(new JLabel("< JLabel 1 >"));
            contents.add(new JLabel("< JLabel 2 >"));
            contents.add(new JLabel("< JLabel 3 >"));
            contents.add(new JLabel("< JLabel 4 >"));
            JLabel thisLabel = new JLabel("Hello");
            thisLabel.setLayout(new FlowLayout());
            JLabel thisLabel2 = new JLabel("Hello2");
            thisLabel2.setLayout(new FlowLayout());
            contents.add(thisLabel);
            contents.add(thisLabel2);
        public static void main(String [] args)
            Menus();
        } // main
    } // class HelloWorldAny help on how I can use two separate layouts in the same frame would be great!
    Regards,
    Tom

    doing this:
    Container contents = getContentPane();
    Container contents2 = getContentPane();
    does not create 2 different containers. It's just creating 2 variables that refer to the same container. There is only 1 content pane in a window/frame. A container can only have 1 layout.
    If you want to have 2 layouts, you create 2 panels with separate layouts and put what you want in each panel, and put both panels in the content page.

  • Difference between null layout and absolutelayout

    hello
    I would like to know the difference between the null layout and the absolutelayout
    thank you in advance

    http://www.google.com/search?q=absolutelayout
    Next time, please use the search yourself.Do I have to consider this as answer Yes.
    notice that I asked for the difference between both
    of the layout and not about
    absolutelayout only Third link, advertised by
    "I think AbsoluteLayout does more than just setting Layout to null. AbsoluteLayout may even accomodate for changes in font sizes etc. ..."
    already should give you something to think about.
    Furthermore, the search shows that there are several different classes named AbsoluteLayout (ADF, SWT, BUI, samskivert...), and you didn't specify which one you're talking about.
    Still think this wasn't an answer?
    I guess I should stop assuming that you have a brain of your own.

  • MX432 All-in-one printer: left side of printed subject is being cut off when using 'normal' layout.

    Because 'normal' and 'fit to page' layouts cut off left side of printed material I'm using 'borderless' layout but that doesn't give me the paper size option I need.  Any hints on how to save the left side of paper and how to change paper size in borderless layout.  Any hints in print preview wherein I can print just 'one or two'  of multiple pages without having to return to the set-up page?

    Hi vitaminsg,
    You can set it so that "Fit to Page" printing is the default setting.  To do this, use the following steps:
    1.  Click Start.
    2.  Click Control Panel.
    3.  Click Printers and other Hardware.
    4.  Click Printers and Faxes.
    5.  Right click the PIXMA MX432 and click Printing Preferences.
    6.  Click the Page Setup Tab.
    7.  Select Fit to Page under Page Layout, then press OK.
    This should now be the default setting for all programs.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Using 'Preview Layouts' on specific objects

    Hi everyone,
    I would want to know if it is possible to import CR layouts in SBO, and use it with the menu "Preview Layouts" on personalized objects.
    When I try to import a CR layout with the Report And Layout Manager of SBO, I choose my RPT file, check the Layout radio button, and open the List Of Documents. But in this list, there are no items which correspond to my specific objects, so I can't link my report and my objects, and when I open a record of my object, the menu "File -> Preview Layouts" is disabled.
    So my question is : is it possible to create new Document Types to be able to link my layout and my objects? Or any other solution which can allow me to use "Preview Layouts" on my specific objects?
    Thanks.

    Hello Charly,
    There is a way to add layout on User object. Using a piece of code, you can add your report in the table RDOC putting it in a BLOB field
    SAPbobsCOM.ReportLayoutsService rptService = (SAPbobsCOM.ReportLayoutsService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService);
    SAPbobsCOM.ReportLayout newReport = (SAPbobsCOM.ReportLayout)rptService.GetDataInterface(SAPbobsCOM.ReportLayoutsServiceDataInterfaces.rlsdiReportLayout);
    newReport.Author = oCompany.UserName;
    newReport.Category = SAPbobsCOM.ReportLayoutCategoryEnum.rlcCrystal;
    newReport.Name = "APRS";
    newReport.TypeCode = "TypeCode";
    SAPbobsCOM.ReportLayoutParams newReportParam = rptService.AddReportLayout(newReport);
    newType = rptTypeService.GetReportType(newTypeParam);
    newType.DefaultReportLayout = newReportParam.LayoutCode;
    rptTypeService.UpdateReportType(newType);
    SAPbobsCOM.BlobParams oBlobParams = (SAPbobsCOM.BlobParams)oCompany.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams);
    oBlobParams.Table = "RDOC";
    oBlobParams.Field = "Template";
    SAPbobsCOM.BlobTableKeySegment oKeySegment = oBlobParams.BlobTableKeySegments.Add();
    oKeySegment.Name = "DocCode";
    oKeySegment.Value = newReportParam.LayoutCode;
    FileStream oFile = new FileStream("D:\\DEV\\Layouts\\Demo.rpt", System.IO.FileMode.Open);
    int fileSize = (int)oFile.Length;
    byte[] buf = new byte[fileSize];
    oFile.Read(buf, 0, fileSize);
    oFile.Dispose();
    SAPbobsCOM.Blob oBlob = (SAPbobsCOM.Blob)oCompany.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlob);
    oBlob.Content = Convert.ToBase64String(buf, 0, fileSize);
    oCompany.GetCompanyService().SetBlob(oBlobParams, oBlob);
    Then you have to associate your form to the reportType using this line of code in your form's constructor:
    oForm.reportType = "ReportType"
    Hoping that can help you
    Best regards

  • Adding buttons in null layout...

    Hi...,
    I am new to Java and I would like to know how null layout can be implemented in a frame and how to add buttons on in anull layout. Any help would be appreciated.

    You can use the setBounds() of the components you want to place on your form. Like this:
    public class Test extends JFrame
         JButton    button1 = new JButton("1");
         JButton    button2 = new JButton("2");
         JButton    button3 = new JButton("3");
         JTextField text1   = new JTextField();
         JTextField text2   = new JTextField();
         JTextField text3   = new JTextField();
         public void Test()
             Container contentPane = getContentPane();
                contentPane.setLayout(null);
                button1.setBounds(252,25,85,26); //x,y,width,height
             button2.setBounds(252,55,85,26);
             button3.setBounds(252,85,85,26);
             text1.setBounds(60,25,168,24);
             text2.setBounds(60,55,168,24);
             text3.setBounds(60,85,168,24);
             contentPane.add(button1);
             contentPane.add(button2);
             contentPane.add(button3);     
             contentPane.add(text1);
             contentPane.add(text2);          
             contentPane.add(text3);          
                setVisible(true);
                setSize(400,300);
           public static void main(String args[])
                new Test();
    }

  • Adding a image in webcenter spaces using Image Layout Component

    Hi,
    i was trying to add a image in webcenter spaces using Image Layout Component , The following steps i did
    I placed some images in Webcenter server location .(c:/images)
    put the folder location in Image Source ( Image Layout Component Properties) as file://c:/images/top_image.jpg
    But the image did not display in WC. if i put some web url its working fine, so i just wonder whether we can point to a file location as the image source.
    Please reply me asap.
    Thanks,
    Swagatika

    I use this to add an image that I have saved in the applet folder
    Image image;
    public void init() {
    image = getImage(getDocumentBase(), "auburn.jpg");
    and I get this error when I try to run it in Jbuilder:
    java.lang.NullPointerException
         at java.applet.Applet.getDocumentBase(Applet.java:125)
         at JavaProject.<init>(JavaProject.java:103)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at java.lang.Class.newInstance0(Class.java:308)
         at java.lang.Class.newInstance(Class.java:261)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
         at sun.applet.AppletPanel.run(AppletPanel.java:298)
         at java.lang.Thread.run(Thread.java:534)
    What could be the problem?

  • Sandbox Solution to create a Publishing page using page layout.

    How to create a Sandbox Solution to create a Publishing page using page layout.

    Hi Sriram,
    You can use the below code
    using (SPSite site = new SPSite(url))
    using (SPWeb web = site.OpenWeb())
    web.AllowUnsafeUpdates = true;
    SPList wiki = web.Lists["Pages"];
    String urlWiki = wiki.RootFolder.ServerRelativeUrl.ToString();
    PublishingSite pubSite = new PublishingSite(web.Site);
    string pageLayoutName = "Layoutname.aspx";
    string layoutURL = web.Url + "/_catalogs/masterpage/" + pageLayoutName;
    PageLayout layout = pubSite.PageLayouts[layoutURL];
    PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
    string pageName ="home.aspx";
    PublishingPage newWikiPage = null;
    newWikiPage = publishingWeb.GetPublishingPages().Add(pageName, layout);
    newWikiPage.Title ="";
    newWikiPage.Update();
    web.AllowUnsafeUpdates = false;
    A'Kumar

  • Please help me out with problems i am facing using Grid Layout

    i can't figure out what's wrong !!
    But the following codw doesn't make a grid of 5 x 4 rather it makes a grid of 5x2
    same thing is happening when i am using a grid in my other applications... the no. of columns are not correctly executed..
    import javax.swing.*;
    import java.awt.*;
    public class GridDemo extends JFrame
        public GridDemo() {
        JButton b1 = new JButton("b1");
        JButton b2 = new JButton("b2");
        JButton b3 = new JButton("b3");
        JButton b4 = new JButton("b4");
        JButton b5 = new JButton("b5");
        JButton b6 = new JButton("b6");
        JButton b7 = new JButton("b7");
        JButton b8 = new JButton("b8");
        JButton b9 = new JButton("b9");
        JPanel f = new JPanel();
        f.setLayout(new GridLayout(5, 4));
        f.add(b1);
        f.add(b2);
        f.add(b3);
        f.add(b4);
        f.add(b5);
        f.add(b6);
        f.add(b7);
        f.add(b8);
        f.add(b9);
        JFrame f1 = new JFrame();
        f1.add(f);
        f1.setVisible(true);
        f1.setSize(400, 400);
        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public static void main(String s[])
        new GridDemo();
    }

    If you want the simplest experience out of layouts, you can try the custom layout I made. It uses the versatility of SpringLayout, but can actually be understood by humans. It has easily been my favorite creation b/c it has made my life SO much easier.
    Here is the code:
    import javax.swing.SpringLayout;
    import java.awt.Container;
    import java.awt.Component;
    public class CoordinateLayout extends SpringLayout
         //Container Variable
         Container cont;
         //Constructor
        public CoordinateLayout(Container ct)
             //Extend SpringLayout
             super();
             //Set Layout to Container
             ct.setLayout(this);
             //Initialize Container Variable
             cont = ct;
        //Method to Add Components -- (0,0) is top left of container
        public void addComponent(Component comp, int x, int y)
             //Adds Component to Container
             cont.add(comp);
             //Set both x and y SpringLayout contraints
             super.putConstraint(SpringLayout.WEST, comp, x, SpringLayout.WEST, cont);
              super.putConstraint(SpringLayout.NORTH, comp, y, SpringLayout.NORTH, cont);
    }And here is a basic program that just creates a frame and uses my layout to place the items. If you have any questions, feel free to ask.
    import javax.swing.*;
    import java.awt.*;
    public class CoordinateLayoutTest
        public static void main(String[] args)
             //Create Frame and Panel
             JFrame mainFrame = new JFrame("TEST");
             JPanel first = new JPanel();
             //Create Layout and send it the Panel
             CoordinateLayout layout = new CoordinateLayout(first);
             //Create components
             JLabel l1 = new JLabel("First Name:");
             JTextField b1 = new JTextField(10);
              JLabel l2 = new JLabel("Last Name:");
              JTextField b2 = new JTextField(10);
              JLabel l3 = new JLabel("Home City:");
              JTextField b3 = new JTextField(10);
              JLabel l4 = new JLabel("Home State:");
              JTextField b4 = new JTextField(10);
              JLabel l5 = new JLabel("Account Number:");
              JTextField b5 = new JTextField(10);
              //Add components
              layout.addComponent(l1,5,5);
              layout.addComponent(b1,105,5);
              layout.addComponent(l2,5,35);
              layout.addComponent(b2,105,35);
              layout.addComponent(l3,5,65);
              layout.addComponent(b3,105,65);
              layout.addComponent(l4,5,95);
              layout.addComponent(b4,105,95);
              layout.addComponent(l5,5,125);
              layout.addComponent(b5,105,125);
              //Simplify adding components by creating JLabels when you use them
             JTextField b1 = new JTextField(10);
              JTextField b2 = new JTextField(10);
              JTextField b3 = new JTextField(10);
              JTextField b4 = new JTextField(10);
              JTextField b5 = new JTextField(10);
              layout.addComponent(new JLabel("First Name:"),5,5);
              layout.addComponent(b1,105,5);
              layout.addComponent(new JLabel("Last Name:"),5,35);
              layout.addComponent(b2,105,35);
              layout.addComponent(new JLabel("Home City:"),5,65);
              layout.addComponent(b3,105,65);
              layout.addComponent(new JLabel("Home State:"),5,95);
              layout.addComponent(b4,105,95);
              layout.addComponent(new JLabel("Account Number:"),5,125);
              layout.addComponent(b5,105,125);
             //Finish creating Frame
             mainFrame.setSize(300,300);
             mainFrame.setContentPane(first);
             mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             mainFrame.setVisible(true);
    }

  • Using NULL and NOT NULL in prompted filters

    Dear all,
    While trying to grap the concept of prompted filters in sap bo web intelligence, I had a question whether why we cannot use NULL and NOT NULL while creating a prompted filters in our report.

    HI,
    'Is Null' and 'Not Null' are the predefined functions in webi which only eliminate the null values or considering only null values.
    'Is Null' and 'Not Null' are itself predefined functions that why you are not getting  prompts.
    Null values are standard across the databases so this is defined  as a function in webi to specific eliminate the null values.
    If something is not standard then there is option in the webi to use different operator with static values or with prompts.
    More more information on Null see the Null wiki page.
    Null (SQL) - Wikipedia, the free encyclopedia
    Amit

  • Using null value of item

    Hi All,
    I use this part-of-code in pl/sql statement in a 'where' clause in order to filter records to those that took place between some hours range:
    ..... and to_char(STARTDATE,'HH24:MI:SS') between NVL(:P3_HOURS_FROM,'00:00:00') and NVL(:P3_HOURS_TO,'23:59:59')
    P3_HOURS_FROM & P3_HOURS_TO are combo box items with LOV (0:00,0:30,1:00 ....etc that returns 00:00:00,00:30:00,1:00:00 respectively). I use a null value which is displayed as '--:--'.
    when i choose some hour range the rsults are correct. the problem is when i choose null values. there is no results to the report, probably (i guess) because it somehow translate the (null) time value to the same value (and it's obvious that between same time values there isn't any result).
    so i guess i use 'null' value in an inappropriate way.
    Can u tell me what do i do wrong???

    Are you sure you are returning NULL and just displaying '--:--' in your LOV?
    If the state of your LOV is becoming '--:--' then this does not equal null in PL/SQL land.
    I presume you are also submitting after changing your LOVs?
    You can check the state of your items by clicking the session state in the developers toolbar at the bottom. See what your items are being set and report back!
    Ben

  • Using null to replace values

    I'm a newbie! Can you tell me how can replace existing values in a variable. My plot in the program is to have the price of products in my right hand then transfer that to the cart and then to cashier lady. I have to make sure and know that when I transfer the price from my right hand to the value cart the right hand should no value, then when from cart to the cashier the cart should have no value. The code below is not yet finish. I'm just testing it on one product. I just to know the transferring concept. Can I use null?
    This my are codes:
    the customer class
    public class customer{
         String fullName,walletName;
         double wallet,money;
         public void sayName(){
              System.out.println(fullName + " is inside the grocery");
         public String giveFullName(){
              return fullName;
         public void sayWalletBrand(){
              System.out.println("Let me see how much money I got from my " + walletName + " wallet\n");
         public void contentWallet(double money){
              wallet = money;
         public void lookWallet(){
              System.out.println("Show that wallet has the value " + wallet);
              System.out.println();
    the product class:
    public class product{
         String description;
         double price,rightHand;
         public double containRightHand(){
              rightHand = price;
              System.out.println(rightHand);
              System.out.println();
              return rightHand;
         public void showDescription(){
              System.out.println("Show product description " + description);
         public void showPrice(){
              System.out.println("Show the product price value " + price);
              System.out.println();
    the cart class:
    public class cart extends product{
         double contents[] = new double[2];
         product doritos,apple;
         //Movement method from rightHand to cart
         public double getProduct1(product doritos){
              contents[0] = doritos.containRightHand();
              return contents[0];
         public double getProduct2(product apple){
              contents[1] = apple.containRightHand();
              return contents[1];
         public void showProduct1(){
              System.out.println("Show that contents[0] has the value "+ contents[0]);
         public void showProduct2(){
              System.out.println("Show that contents[1] has the value "+ contents[1]);
    the cashier class:
    public class cashier{
         customer cashierLady;
         public void tellNameCashier(customer cashierLady){
              System.out.println("Shows the name of the cashier lady named " + cashierLady.giveFullName());
    the main:
    public class grocery{
         public static void main(String []arg){
              customer Peter, Lady;
              Peter = new customer();
              Peter.fullName = "Raymond Malicdem";
              Peter.walletName = "Seiko";
              Peter.wallet = 1000.0;
              Peter.sayName();
              Peter.sayWalletBrand();
              Peter.contentWallet(1000.0);
              Peter.lookWallet();
              product Doritos = new product();
              Doritos.description = "Junk Food";
              Doritos.price = 60.0;
              Doritos.showDescription();
              Doritos.showPrice();
              Doritos.containRightHand();
              cart product1 = new cart();
              product1.getProduct1(Doritos);
              product1.showProduct1();
              Lady = new customer();
              Lady.fullName = "Christine";
              cashier lady = new cashier();
              lady.tellNameCashier(Lady);

    Variables of object (class) types may be set to null, meaning they point to no object.
    Variables of fundamental types (int, byte, char, long, double, float, boolean, etc.) can not be set to null. Maybe you can set your numeric types to 0 and boolean to false, to indicate nothingness.

  • Using null for parameterized "newInstance(Object [])" method in Object[].

    I have a really serious problem. I am creating instances of specific classes by using reflection techniques. I am reading a flat file, finding class from its name and creating it by using its parameterized constructor. Example:
    line 1: Dummy("A",Dummy2("B"),12,,"C");
    I create an instance of Dummy with parameters "A", an instance of Dummy2 object with value "B", 12 (I use here Integer as wrapper), null (There is no wrapper for null :( ) and "C".
    I find constructor by using findConstructors() and looking their parameter counts, creating an object array with given values and calling:
    constructorIFoundBefore.newInstance(objectArrayIPrepared);
    But!!!
    Because I use null directly, I got this message:
    java.lang.IllegalArgumentException: argument type mismatch
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at reader.parser.ObjectCreator.createObjectFromObjectItem(ObjectCreator.java:192)
         at reader.parser.ObjectCreator.createObjectFromParseItem(ObjectCreator.java:112)
         at reader.parser.ObjectCreator.createObject(ObjectCreator.java:78)
         at reader.analyzer.FileAnalyzer.analyzeAndCreateObjects(FileAnalyzer.java:95)
         at reader.ReverseReader.main(ReverseReader.java:43)
    I will be very glad if you help me.
    Thanks a lot!
    Gokcer

    I said something wrong. Sorry. While invoking a method (or a constructor) we need an object array which are equivalent to parameters. For example to call a method or constructor for class A;
    class A {
    int age;
    String name;
    public A(int age, String name){
    this.age = age;
    this.name = name;
    public set(int age, String name){
    this.age = age;
    this.name = name;
    we use in any place
    A a1 = new A(12,"Gokcer");
    A a2 = new A(15,null);
    To achieve this by using reflection techniques, we must find constructor with two parameters of class A. At this point "BetterMethodFinder" will give great help.
    After finding right constructor, we must create an object array to tell the constructor parameters (age and name). At this point we need an object array which stores our parameters. Code must be like this.
    Object []params = new Object[2]; // we have two parameters.
    params[0] = new Integer(12); // we can't use params[0]=12
    // because 12 is not an object. (It is a
    // primitive type)
    params[1] = "Gokcer";
    Now create the new object.
    A a1;
    a1 = constructorWeFound.newInstance(params);
    While creating param[], we could also use:
    Object []params = new Object[2] {new Integer(12),"Gokcer"};
    While creating a2, we can use "null" directly for second parameter.
    params = new Object[2] = {new Integer(15), null};
    or
    Object []params = new Object[2];
    params[0] = new Integer(15);params[1] = null;
    Thanks again everyone who replied me.
    My sincerely...

Maybe you are looking for

  • Change of Financial Year End

    Hi Experts We have been advised that we will be changing our financial year (currently July to June) to tie in with our new acqusition companies fiscal year, which runs from January to December.This will be done with effect from end June 2012. Conseq

  • HP dvd640v Lightscribe Device

    I have an external HP dvd640v Lightscribe writer. I initially installed it onto a Windows 7 Startup OS, which I then upgraded to Windows 7 Professional. The device was running fine until yesterday when for some reason (maybe after a system auto updat

  • Additional Fields of an infotype in a overview screen??

    Dear Alls, I have a question. I m using recruitment module, i have added field in previous employment infotype 0023 but i want to maintain multiple data in this infotype. but this addiotional field is not diaplay in overview screen while it is in inf

  • Block corruption in Free Space

    Hi, Environment:- Oralce 10.2.0 Windows platform I am facing problem of Logical block corruption. RMAN validate block corruption (DBVerify as well) But no entry in Alert log file. When I check Which segment has block corruption I found that block cor

  • Find location of substrings the hard way

    In order to find the location of a substring in a string I tend to use this method: set ptrFind to (offset of "get in "target" as string) this results in ptrFind = 3 However, I'm at a loss when it gets more complex like when I want to find the locati