Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to run a "Add"-method from a method?

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to run a "Add"-method from a method?

    Hi all,


    I've a Java code (GWT):

    package com.practicum.client.out;
     
    import java.util.ArrayList;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.ui.Widget; 
    import com.google.gwt.visualization.client.DataTable;
    import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
    import com.google.gwt.visualization.client.visualizations.corechart.AxisOptions;
    import com.google.gwt.visualization.client.visualizations.corechart.ColumnChart;
    import com.google.gwt.visualization.client.visualizations.corechart.CoreChart;
    import com.google.gwt.visualization.client.visualizations.corechart.Options;
    import com.practicum.client.Product;
    import com.practicum.client.rpc.ProductService;
    import com.practicum.client.rpc.ProductServiceAsync;
     
     
    public class DataOutColumnChart {
    	private DataTable data = DataTable.create();
    	private Options options = CoreChart.createOptions();
    	private final ProductServiceAsync productService = GWT.create(ProductService.class);
     
    	public DataOutColumnChart(Runnable runnable) {
    	}
     
    	public Widget createColumnChartView() {
    		/* create a datatable */
    		data.addColumn(ColumnType.STRING, "Price");
    		data.addColumn(ColumnType.NUMBER, "EUR");
    		addData("A for Apple", 123); // THIS WORKS
    		addData("B for Boy", 123); // THIS WORKS
     
    		/* create column chart */
    		options.setWidth(400);
    		options.setHeight(300);
    		options.setBackgroundColor("#e8e8e9");
    		AxisOptions vAxisOptions = AxisOptions.create();
    	    vAxisOptions.setMinValue(0);
    	    options.setVAxisOptions(vAxisOptions);
     
    		return new ColumnChart(data, options);
    	}
     
     
    	public void getWinkels() {
    		productService.getWinkels(new AsyncCallback<ArrayList<Product>>() {
    			public void onFailure(Throwable caught) {
    			}
     
    			public void onSuccess(ArrayList<Product> result) {
    				for (Product p : result) {
    					addData("C for Candy", 123); // THIS DONT WORK?
    					System.out.println(p.getWinkel()); // THIS WORKS
    				}
    			}
    		});
    	}
     
     
    	public void addData(String winkel, int prijs) {
    		int rownr = data.addRow();
    		data.setValue(rownr, 0, winkel);
    		data.setValue(rownr, 1, prijs);
    	}
     
    }

    Can someone explain me why line 30 and 31 works,
    but line 51 not works? Simply nothing happens on line 52...

    I've tried anything...

    Thanks in advance!


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How to run a "Add"-method from a method?

    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to run a "Add"-method from a method?

    Quote Originally Posted by Junky View Post
    Java-forums.org and Javaprogrammingforums.com are two different websites....

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to run a "Add"-method from a method?

    Quote Originally Posted by pinotje View Post
    Java-forums.org and Javaprogrammingforums.com are two different websites....
    Yes they are, which makes it that much worse. Why you might ask? See the following:
    http://www.javaprogrammingforums.com...s-posting.html

Similar Threads

  1. HELP! Constructor and "toString" method...
    By federerforehand in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 7th, 2011, 04:33 PM
  2. How do I use the repaint method to "undraw"? (I am a noob)
    By racecar333 in forum AWT / Java Swing
    Replies: 3
    Last Post: October 31st, 2011, 06:40 PM
  3. "Static method cannot hide instance method from implemented Interface"
    By Gthoma2 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 21st, 2011, 03:03 AM
  4. "showMessageDialog" method in swing package
    By Delmi in forum Java Theory & Questions
    Replies: 1
    Last Post: May 13th, 2010, 02:52 PM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM