Problems with invokeing method

Hey,
I'm trying to create an splash screen before my app starts but i have alot of troubles with this. Here is my code:
package classes;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import clientmanager.Delta;
* A Splash window.
*  <p>
* Usage: MyApplication is your application class. Create a Splasher class which
* opens the splash window, invokes the main method of your Application class,
* and disposes the splash window afterwards.
* Please note that we want to keep the Splasher class and the SplashWindow class
* as small as possible. The less code and the less classes must be loaded into
* the JVM to open the splash screen, the faster it will appear.
* <pre>
* class Splasher {
*    public static void main(String[] args) {
*         SplashWindow.splash(Startup.class.getResource("splash.gif"));
*         MyApplication.main(args);
*         SplashWindow.disposeSplash();
* </pre>
* @author Werner Randelshofer
* @version 2.2.1 2006-05-27 Abort when splash image can not be loaded.
public class SplashWindow extends Window {
     * The current instance of the splash window.
     * (Singleton design pattern).
    private static SplashWindow instance;
     * The splash image which is displayed on the splash window.
    private Image image;
     * This attribute indicates whether the method
     * paint(Graphics) has been called at least once since the
     * construction of this window.<br>
     * This attribute is used to notify method splash(Image)
     * that the window has been drawn at least once
     * by the AWT event dispatcher thread.<br>
     * This attribute acts like a latch. Once set to true,
     * it will never be changed back to false again.
     * @see #paint
     * @see #splash
    private boolean paintCalled = false;
     * Creates a new instance.
     * @param parent the parent of the window.
     * @param image the splash image.
    private SplashWindow(Frame parent, Image image) {
        super(parent);
        this.image = image;
        // Load the image
        MediaTracker mt = new MediaTracker(this);
        mt.addImage(image,0);
        try {
            mt.waitForID(0);
        } catch(InterruptedException ie){}
        // Abort on failure
        if (mt.isErrorID(0)) {
            setSize(0,0);
            System.err.println("Warning: SplashWindow couldn't load splash image.");
            synchronized(this) {
                paintCalled = true;
                notifyAll();
            return;
        // Center the window on the screen
        int imgWidth = image.getWidth(this);
        int imgHeight = image.getHeight(this);
        setSize(imgWidth, imgHeight);
        Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation(
        (screenDim.width - imgWidth) / 2,
        (screenDim.height - imgHeight) / 2
        // Users shall be able to close the splash window by
        // clicking on its display area. This mouse listener
        // listens for mouse clicks and disposes the splash window.
        MouseAdapter disposeOnClick = new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                // Note: To avoid that method splash hangs, we
                // must set paintCalled to true and call notifyAll.
                // This is necessary because the mouse click may
                // occur before the contents of the window
                // has been painted.
                synchronized(SplashWindow.this) {
                    SplashWindow.this.paintCalled = true;
                    SplashWindow.this.notifyAll();
                dispose();
        addMouseListener(disposeOnClick);
     * Updates the display area of the window.
    public void update(Graphics g) {
        // Note: Since the paint method is going to draw an
        // image that covers the complete area of the component we
        // do not fill the component with its background color
        // here. This avoids flickering.
        paint(g);
     * Paints the image on the window.
    public void paint(Graphics g) {
        g.drawImage(image, 0, 0, this);
        // Notify method splash that the window
        // has been painted.
        // Note: To improve performance we do not enter
        // the synchronized block unless we have to.
        if (! paintCalled) {
            paintCalled = true;
            synchronized (this) { notifyAll(); }
     * Open's a splash window using the specified image.
     * @param image The splash image.
    public static void splash(Image image) {
        if (instance == null && image != null) {
            Frame f = new Frame();
            // Create the splash image
            instance = new SplashWindow(f, image);
            instance.setVisible(true);
            // Note: To make sure the user gets a chance to see the
            // splash window we wait until its paint method has been
            // called at least once by the AWT event dispatcher thread.
            // If more than one processor is available, we don't wait,
            // and maximize CPU throughput instead.
            if (! EventQueue.isDispatchThread()
            && Runtime.getRuntime().availableProcessors() == 1) {
                synchronized (instance) {
                    while (! instance.paintCalled) {
                        try { instance.wait(); } catch (InterruptedException e) {}
     * Open's a splash window using the specified image.
     * @param imageURL The url of the splash image.
    public static void splash(URL imageURL) {
        if (imageURL != null) {
            splash(Toolkit.getDefaultToolkit().createImage(imageURL));
     * Closes the splash window.
    public static void disposeSplash() {
        if (instance != null) {
            instance.getOwner().dispose();
            instance = null;
     * Invokes the main method of the provided class name.
     * @param args the command line arguments
    public static void invokeMain(String className, String[] args) {
        try {
            //Class.forName(className).getMethod("main", new Class[] {String[].class}).invoke(null, new Object[] {args});
        } catch (Exception e) {
            InternalError error = new InternalError("Failed to invoke main method");
            error.initCause(e);
            throw error;
}But when i run my application i get this:
Exception in thread "main" java.lang.InternalError: Failed to invoke main method
        at classes.SplashWindow.invokeMain(SplashWindow.java:199)
        at clientmanager.Main.main(Main.java:14)
Caused by: java.lang.ClassNotFoundException: Delta
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at classes.SplashWindow.invokeMain(SplashWindow.java:197)
        ... 1 moreAnd i don't know why i get that error. Can anybody help me?
Thanks alot!
Sincerely,
NightFox

this i have created in java 2d
the code: -
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
public class Draw2 extends Frame
     Shape s[] = new Shape[5];
     public static void main(String args[])
          Draw2 app = new Draw2();
     public Draw2()
          super("Draw2");
          add("Center", new MyCanvas());
          setSize(600, 400);
          show();
     class MyCanvas extends Canvas
          public void paint(Graphics graphics)
               Graphics2D g = (Graphics2D) graphics;
               for (int i=0; i<=5; i++)
                    g.draw(new Ellipse2D.Double(20+(60*i), 50.0, 50, 50));
               for (int i=0; i<=5; i++)
                    g.draw(new Ellipse2D.Double(20+(50*i), 100.0, 50, 50));
               for (int i=0; i<=5; i++)
                    g.draw(new Ellipse2D.Double(20+(40*i), 150.0, 50, 50));
               for (int i=0; i<=5; i++)
                    g.draw(new Ellipse2D.Double(20+(30*i), 200.0, 50, 50));
               for (int i=0; i<=5; i++)
                    g.draw(new Ellipse2D.Double(20+(20*i), 250.0, 50, 50));
}hope this helps
thanks
Pradyut
http://pradyut.tk

Similar Messages

  • I have problem with pay method

    I have problem with pay method. My card declined. I change card and I have the same problem. What can i do? Why declined my card again?

    Contact iTunes store support: https://ssl.apple.com/emea/support/itunes/contact.html.

  • Problem with traverse method

    Hi, I am having this problem:
    I made a CustomItem, a TextField, now I overloaded the traverse method, so if the keycode is Canvas.UP or Canvas.DOWN then return false else return true.
    The problem is that when I press the left or rigth button it also returns false and not true.
    and there is another problem with traverse, before returning false or true I set a boolean and call to repaint to draw it on some way if its selected or not, the paint method is being called but it just dont draw as desired.
    protected void paint(Graphics g, int ancho, int alto) {
              System.out.println ("Dentro del paint, seleccionado="+seleccionado);
              try {
                   g.drawString(label, 0, 0, Graphics.TOP|Graphics.LEFT);
                   if (!seleccionado) {
                        g.setColor(120, 120, 120);
                   g.drawRect(0, 4, tama�oTexto+8, 25);
                   if (seleccionado) {
                        g.setColor(255, 255, 255);
                        g.fillRect(1, 5, (tama�oTexto+8-1), 23);
                   g.setColor(0, 0, 0);
                   if (!seleccionado) {
                        g.setColor(80, 80, 80);
                   g.drawString(texto, 4, 7, Graphics.TOP|Graphics.LEFT);
                   if (seleccionado) {
                        int cursorX=Font.getDefaultFont().charsWidth((texto.substring(0, idLetraActual)).toCharArray(), 0, texto.substring(0, idLetraActual).length())+4;
                        g.drawChar('|', cursorX, 7, Graphics.TOP|Graphics.LEFT);
              } catch (Exception E){
                   E.printStackTrace();
         }the traverse method set the seleccionado variable and calls to repaint but instead of being false the paint method is drawing it as true (most of times).

    I have a problem with findByxxx() method.. in
    Container managed bean.
    i have
    Collection collection =
    home.findByOwnerName("fieldValue");
    specified in my Client Program, where ownerName is the
    cmp fieldname..
    and
    public Collection findByOwnerName(String ownerName)
    throws RemoteException, FinderException
    defined in my home interface.
    i have not mentioned the findBy() method anywhere else
    (Bean class). You have to describe the query in the deployment descriptor.
    >
    Even if i have a same "fieldValue" in the database
    (Oracle), which i specified in findBy() method, iam a
    result of owner Not found, which is not the case as i
    have that owner name.
    for the same application if i use findByPrimaryKey(),
    it is working..
    Can any one please post me the solution.

  • Problem with prerender method

    Hi,
    I have a problem with the method prerender. A month ago, I started to develop a web project using Sun Studio Creator and a few page beans that i used extended the Abstract Page Bean, so I overrided the prerender and customized it.
    The problem is that, now i'm using eclipse and the configuration files of the project has changed and the prerender method never execute.
    I want to know why it is happening. Maybe the project is "bad-configurated"?
    Thanks

    The code of java bean doesn't change, the only thing that has changed is the configuration files (faces-config.xml, web.xml, etc).
    I put a breakpoint in the prerender method but the lifecycle doesn�t execute this method.
    After serveral changes, I wrote this code in the method prerender :
    int i=0;
    i = 1;
    And the prerender method doesn't execute.
    I'm a bit lost,
    thanks

  • Problem with affinetransformOp method...

    I have a serious problem with filter method
    I Want to make a image flipping or some other filtering by using
    AffineTransformOp
    but it printouts an erro like this
    cannot resolve symbol
    op.filter (img, flipped)
    (the error pointer shows ".after the op")
    a code from my one of the filters
    BufferedImage flipped = new BufferedImage(img.getHeight(), img.getWidth(),BufferedImage.TYPE_INT_RGB);
    AffineTransform trans = new AffineTransform(0, 1, 1, 0, 0, 0);
    AffineTransformOp op = new AffineTransformOp(trans, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    op.filter(img, flipped); //img is my buffered image source
    I used some other ways like (img, null) but always give out error.
    thanks..

    Did you declare "img" as BufferedImage or something else?
    What is the full error message?

  • Problem with WindowClosing() method

    Hello everyone,
    I have some problem with WindowClosing() method, in which I gave options
    to quit or not. Quit is working fine but in case of Cancel, its not returning to
    the frame. Can anyone help me ....Here is my code
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    public class TestFrame extends JPanel
         public static void main(String[] args)
              JFrame frame = new JFrame("Frame3");
              WindowListener l = new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        int button = JOptionPane.showConfirmDialog(null,"OK to Quit","",JOptionPane.YES_NO_OPTION, -1);
                        if(button == 0)     {
                             System.exit(0);
                                   else
                                              return;
              frame.addWindowListener(l);
              frame.setSize(1200,950);     
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
    }

    Maybe try
    int button = JOptionPane.showConfirmDialog(yourframe,"OK to
    Quit","",JOptionPane.YES_NO_OPTION, -1);

  • Problem with getPrimaryKeys method in DatabaseMetaData

    I'm using the above mentioned method to get primary keys from a DB2 database. I estimate that 95% of the time it performs as expected, but there are 7 tables in my database, that as far as I can see, are no different to any others and it fails to work with these. Looking at the tables in the DB2 control centre shows them all having keys, no different to any of the other tables. Also of note is that the tables it fails on are next to each other, it fails on tables 68 and 69, 135 and 136 and 200,201 and 202. Just wondering if anyone else has seen this problem before and if they found any solutions for it?
    Just ran through the program again and it's failed on a completely different set of tables, they're all sequential as well, could this be a problem with my connection to the db?
    Edited by: jnaish on Aug 14, 2008 7:38 AM

    post the ddl and code i guess
    i doubt this is related to your connection
    Also of note is that the tables it fails on are next to each other, i can't imagine that would be a problem, but sounds like it'd be easy for you to prove your theory with a simple test

  • Problem with Vector method addElement

    I am new to Java. I am using JDK 1.3. I am writing a program that will convert a text file to a binary file that stores a Vector object. I have narrowed my problem to the method that reads the text file and creates my vector. Each element in my vector stores an integer and a string variable. The reading of the text file works find and the creation of my record works find. It seems that the storing of the record in the vector is not working. When I print the first 10 elements of the vector, it have the same record(the last record of my text file). What is wrong with the method below? I am also appending the result of running my program.
    private static void readTextFile(File f) {
    try {
    FileReader fileIn = new FileReader(f);
    BufferedReader in = new BufferedReader(fileIn);
    String line;
    int i;
    SsnLocationRecord recordIn = new SsnLocationRecord();
    int ctr = 0;
    while (true) {
    line = in.readLine();
    if (line == null)
    break;
    ctr += 1;
    i = line.indexOf(" ");
    recordIn.putAreaNumber(Integer.parseInt(line.substring(0,i).trim()));
    recordIn.putLocation(line.substring(i+1).trim());
    records.addElement(recordIn);
    if (ctr < 11)
    System.out.println(recordIn);
    in.close();
    } catch (IOException e) {
    System.out.println ("Error reading file");
    System.exit(0);
    for (int i = 0; i < 11; i++)
    System.out.println((SsnLocationRecord) records.elementAt(i));
    RESULTS:
    C:\Training\Java>java ConvertTextFileToObjectFile data\ssn.dat
    0 null
    3 New Hampshire
    7 Maine
    9 Vermont
    34 Massachusetts
    39 Rhode Island
    49 Connecticut
    134 New York
    158 New Jersey
    211 Pennsylvania
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    C:\Training\Java>

    First of all it would be better if you did a priming read and then checked line == null in the while statement instead of the way you have it.
    ctr++ will also accomplish what ctr +=1 is doing.
    you need to create a new instance of SsnLocationRecord for each line read. What you are doing is overlaying the objects data each time you execute the .putxxxx methods. The reference to the object is placed in the vector. The actual object is still being updated by the .putxxx methods (NOTE : THIS IS THE ANSWER TO YOUR MAIN QUESTION).
    you close should be in a finally statement.
    To process through all the elements of a Vector create an Enumeration and then use the nextElement() method instead of the elementAt is probably better. (Some will argue with me on this I am sure).
    Also, on a catch do not call System.exit(0). This will end your JVM normally. Instead throw an Exception (Runtime or Error level if you want an abnormal end).

  • Problem with GetLineData Method

    Hi
    I have a program to save each row of a A/R Invoice as one A/R Invoice document.
    In the program, I read each line of data from matrix with GetLineData Method, and set the data to business object, and add the document at a global transaction.
    Adding the first line of document works fine, but the second line has a problem. There is no response in the  the GetLineData Method.
    Does anybody have any idea?
    The code looks like the following:
    Private Sub MakeSalesInvoice(ByRef BubbleEvent As Boolean)
         Dim i As Integer                                             
           Try
                If Not (SBO_COMPANY.InTransaction) Then
                    Call SBO_COMPANY.StartTransaction()
                End If
                oMatrix = oForm.Items.Item("38").Specific                 
                For i = 1 To oMatrix.RowCount - 1
                    oMatrix.GetLineData(i)                //here, there is no response when i >=2
                    subSetInvoiceH()
                    subSetInvoiceL()
                    If InvoiceH.Add() <> 0 Then
                       Exit Sub
                    End If
                    InvoiceH = Nothing
                    InvoiceL = Nothing
                    InvoiceLA = Nothing
                Next
                If SBO_COMPANY.InTransaction Then
                    SBO_COMPANY.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
                End If
                BubbleEvent = False
                oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE
                oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE
            Catch ex As Exception
                If SBO_COMPANY.InTransaction Then
                    SBO_COMPANY.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
                End If
            End Try
       End Sub
       Private Sub subSetInvoiceH()
       //code to set A/R Invoice header data to SAPbobsCOM.Documents
       End Sub
       Private Sub subSetInvoiceL()
      //code to set A/R Invoice line data to SAPbobsCOM.Documents_Lines
       End Sub
    Can someone help me?
    Thanks in advance.

    Thanks for the response.
    I tried GetLineData(i-1), but got error "Row - Invalid index" message.
    I think the index of the datasource has no problem in my program since i set -1 when i get the data from datasource.
    The following is the code when setting data to the business objects.
    Private Sub subSetInvoiceH()
            Dim nCount As Integer
            Dim oDBDataSource As SAPbouiCOM.DBDataSource
            oDBDataSource = oDBDataSources.Item("OINV")
            nCount = oDBDataSource.Size - 1
            InvoiceH = SBO_COMPANY.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
            With InvoiceH
                If oDBDataSource.GetValue("CardCode", nCount) <> "" Then
                    .CardCode = oDBDataSource.GetValue("CardCode", nCount)
                Else
                    .CardCode = ""
                End If
                If oDBDataSource.GetValue("DocDate", nCount) <> "" Then
                    .DocDate = oDBDataSource.GetValue("DocDate", nCount).Insert(4, "/").Insert(7, "/")
                Else
                    .DocDate = "0"
                End If
            End With
        End Sub
    Mika

  • Problem with binarySearch method

    In the code below I've got a problem with my binarySearach method in the IntegerList.java file. When I look at my IntegerTest file, Eclipse give me this message next to my method call for the binarySerch (case 6): (the method binarySearch int[] , int) in the type integerList is not applicable for the arguments (int). So what the heck have I done wrong? I know it's a lot of code to look at but felt you'll need to see both classes to make heads or tales out of this.
    Thanks in advance.
    import java.util.Scanner;
    public class IntegerList //implements Comparable
         int [] list; // values in the list
         //Constructor -- takes an integer and creates a list of that
         //size.  All elements default to value 0.
         public IntegerList(int size)
              list = new int[size];
         //randomize -- fills the array with randomly generated integers
         //between 1 and 100, inclusive
         public void randomize()
              int max = list.length;
              for (int i=0; i < list.length; i++)
                   list[i] = (int) (Math.random() * max) +1;
         //fillSorted -- fills the array with sorted values
         public void fillSorted()
              for (int i =0; i <list.length; i++)
                   list = i + 2;
         //print -- prints array elements with indices, one per line
         public String toString()
              String s = "";
              for (int i = 0; i <list.length; i++)
                   s += i + ":\t" + list[i] + "\n";
              return s;
         //linearSearch -- takes a target value and returns the index
         //of the first occurrence of target in the list. Returns -1
         //if target does not appear in the list
         public int linearSearch (int target)
              int location = -1;
              for (int i = 0; i < list.length && location == -1; i++)
                   if (list [i] == target)
                        location = i;
                   return location;
         //sortIncresing -- uses selection sort
         public void sortIncreasing()
              for (int i =0; i < list.length -1; i++)
                        int minIndex = minIndex(list, i);
                        swap (list, i, minIndex);
    private void swap(int[] list, int index, int min)
    int temp =list [index];
    list [index] = list [min];
    list [min] = temp;
    // private int minIndex(int[] list, int index)
    public int minIndex(int[] list, int lastIndex) {
    int min=list[lastIndex];
    for (int i=lastIndex+1; i<list.length; i++)
    if (list[i]<min)
    lastIndex=i;
    return lastIndex;
    public void sortDecreasing()
              for (int i =0; i > list.length -1; i++)
                        int minIndex = minIndex(list, i);
                        swap (list, i, minIndex);
    public static int binarySearch (int [] list, int val)
    int min = 0, max = list.length, mid =0;
    boolean found = false;
    while (!found && min <= max)
    mid = (min + max) / 2;
    if (list [mid]== val)
    found = true;
         //if the mid point contains the value being searched for
         //then we are done
    else
    if (list[mid]< val)
    max = mid -1;
    else
    min = mid+1;
    if (found)
    return list[mid];
    else
    return -1;
    return val;
    }//end class
    //now for the IntegerListTest class
         //File: integerListTest.java
         //Purpose: Provide a menu-driven tester for the IntegerList class.
         import java.util.*;
         public class IntegerListTest
              static IntegerList list = new IntegerList(10);
              static Scanner scan = new Scanner(System.in);
         // main -- creates an initial list, then repeatedly prints
         // the menu and does what the user asks until they quit
         public static void main(String [] args)
              printMenu();
              int choice = scan.nextInt();
              while (choice != 0)
                        dispatch(choice);
                        printMenu();
                        choice = scan.nextInt();
         // dispatch -- takes a choice and does what needs doing
         public static void dispatch(int choice)
              int loc;
              int val;
              long time1, time2;
              long totalTime;
              switch (choice)
                        case 0:
                             System.out.println("Bye!");
                             break;
                        case 1:
                             System.out.println(list);
                             break;
                        case 2:
                             System.out.println("How big should the list be?");
                             list = new IntegerList (scan.nextInt());
                             System.out.println("List is created.");
                             break;
                        case 3:
                             list.randomize();
                             System.out.println("List is filled with random elements.");
                             break;
                        case 4:
                             list.fillSorted();
                             System.out.println("List is filled with sorted elements.");
                             break;
                        case 5:
                             System.out.print("Enter the value to look for: ");
                             val = scan.nextInt();
                             time1 = System.currentTimeMillis();
                             loc = list.linearSearch(val);
                             time2 = System.currentTimeMillis();
                             totalTime = time1 - time2;
                             System.out.print(totalTime);
                             if (loc != -1)
                                  System.out.println("Found at location " + loc);
                             else
                                  System.out.println("Not in list");
                             break;
                        case 6:
                             System.out.print("Enter the value to look for: ");
                             val = scan.nextInt();
                             loc = list.binarySearch(val);
                             if (loc != -1)
                                  System.out.println("Found at location " + loc);
                             else
                                  System.out.println("Not in list");
                             break;
                        case 7:
                             list.sortIncreasing();
                             System.out.println("List has been sorted.");
                             break;
                        case 8:
                             list.sortDecreasing();
                             System.out.println("List has been sorted.");
                             break;
                        default:
                             System.out.println("Sorry, invalid choice");
         // printMenu -- prints the user's choices
         public static void printMenu()
              System.out.println("\n Menu ");
              System.out.println(" ====");
              System.out.println("0: Quit");
              System.out.println("1: Print the list");
              System.out.println("2: Create a new list of a given size");
              System.out.println("3: Fill the list with random ints in range 1-length");
              System.out.println("4: Fill the list with already sorted elements");
              System.out.println("5: Use linear search to find an element");
              System.out.println("6: Use binary search to find an element " +
                                  "(list must be sorted in increasing order)");
              System.out.println("7: Use selection sort to sort the list into " +
                                  " increasing order");
              System.out.println("8: Use insertion sort to sort the list into " +
                                  " decreasing order");
              System.out.println("\nEnter your choice: ");

    Ah... But now that I have looked at it some more, I have noticed that the array of int is created in your IntegerList class...
    so you want to change your binarySearch() method...
    from...
    public static int binarySearch (int[] list,int val)to
    public int binarySearch (int val)now it will search the list declared in your constructor...
    and also note that static is remove to eliminate the non-static reference from static context error...
    so in IntegerList.java, that method signature should look like this...
    public int binarySearch (int val)// take only one arguement and...
    // check against internal int [] listand you call it like this...
    loc = list.binarySearch(val);// not changednow all you have to do it get your list populated with random integers for the rest to work... I leave that to you...
    - MaxxDmg...
    - ' He who never sleeps... '

  • Problem with getState() method in Thread class

    Can anyone find out the problem with the given getState() method:
    System.out.println("The state of Thread 1: "+aThread.getState());
    The Error message is as follows:
    threadDemo.java:42: cannot resolve symbol
    symbol : method getState ()
    location: class incrementThread
    System.out.println("The state of Thread 1: "+aThread.getState())
    ^
    1 error

    the api doc shows Since: 1.5
    You do use Java 5...if not... it's not available.

  • Problem with a method

    I have a problem with the getRGB(int x, int y) method of the BufferedImage class :
    I've load an image in it :
    1:// b is my bufferedimage clas and myimage is an image
    2:b.getGraphics().drawImage(myimage, 0, 0, this);
    3:// g is the graphics object of my paint method
    4:g.drawImage(b, 634, 225, null);
    5:// This write -16777216 and 10, 10 is a black point
    6:System.out.println(b.getRGB(10, 10));
    I think the problem is at the second line. But i'm not sure. Can somebody help ?

    That's probably not what you meant. You can do a binary and:int r = (hex & 0x00FF0000) >> 16;
    int g = (hex & 0x0000FF00) >> 8;
    int b = (hex & 0x000000FF);

  • Problem with flush method

    Hello, I'm new in java development, and I'm french with a student English, sorry if that I say is strange is the expressions.
    I have a problem with network streams and serialization.
    I want to establish a connection between 2 apps, on 2 different computers. For the development, the tests are local (IP : 127.0.0.1)
    The problem : I send 4 bytes and I flush after, and I receive 6 bytes. To know what is transmitting on the connection, I override the OutputStream class.
    I think that the flush() method produces 2 bytes but i don't think how.
    I put you the codes follow :
    Thanks for any help.
    The sender function :
    // This function is called when the user want to send data to another user.
    // This piece of function establishing the connection between 2 users.
    public int startListeningForNFT(String senderUserName, int indexOfSender) {
          System.out.println(senderUserName + " demande à " + this.userName + " de démarrer la procédure de réception.");
          /* Cette fonction est l'interface ente le serveur et le client2,
           * elle retourne le port  et l'IP que le client2 le lui a renvoyé. */
          /* This function send an Integer which will trig a reception function in the receiver
             This function is called in a Thread. */
          try {
             this.oos.writeObject(44);
             this.oos.flush();
             System.out.println("On a bien envoyé OBJ2AskerInfos sur le port " + portToListen);
             byte b = this.ois.readByte();
             System.out.println("Byte = " + b);
             b = this.ois.readByte();
             System.out.println("Byte = " + b);
             b = this.ois.readByte();
             System.out.println("Byte = " + b);
             b = this.ois.readByte();
             System.out.println("Byte = " + b);
             b = this.ois.readByte();
             System.out.println("Byte = " + b);
          catch (IOException e) { e.printStackTrace(); }
          return Constantes.PORT_DATA;
       }The receiver function :
    public class ClientClient implements WindowClient {
       // This 3 attributes are initalized correctly.
       private Socket comSocket;
       private String comPort;
       private String userName;
       public ClientClient() {
          try {
          comSocket = new Socket(ipToJoin, Integer.parseInt(comPort));
          oos = new ObjectOutputStream(new DebugOutputStream(comSocket.getOutputStream()));
          ois = new ObjectInputStream(comSocket.getInputStream());
          oos.writeObject(userName);
          oos.flush();
          ThreadInputListener til = new ThreadInputListener();
          til.start();
          catch (UnknownHostException e) { e.printStackTrace(); }
          catch (ClassNotFoundException e) { e.printStackTrace(); }
          catch (IOException e) {
             e.printStackTrace();
             JOptionPane.showMessageDialog(null, ("Auncun serveur n'a été trouvé sur l'adresse indiquée :\n" + ipToJoin), "Erreur", JOptionPane.ERROR_MESSAGE);
       public class ThreadInputListener extends Thread {
          @SuppressWarnings("unchecked")
          public void run() {
             try {
                while(true) {
                   Object receivedObject = ois.readObject();
                   // Si l'objet reçu est un OBJ2InfosOnAsker => Renvoyer le port.
                   // If received Object is an integer
                   if(receivedObject instanceof Integer) {
                      System.out.println(userName +" a bien reçu l'objet OBJ2InfosOnAsker...");
                      System.out.println(userName +" a bien reçu int." + receivedObject);
                      System.out.println("On lance les 4 int :");
                      // Send 4 bytes to the sender (control bytes, just for solve the problem)
                      oos.writeByte(7);
                      oos.writeByte(8);
                      oos.writeByte(9);
                      oos.writeByte(10);
                      oos.flush();
                      System.out.println("...et a bien envoyé le port");
             catch (IOException e) {
                // ArrayList<HostClient> temp = new ArrayList<HostClient>();
                // temp.add(new HostFictiveClient(userName));
                // fenetreprincipale.updateClientList(temp);
                fenetreprincipale.addDiscution("Vous avez été déconnecté du serveur.");
             catch (ClassNotFoundException e) { e.printStackTrace(); }
       }The override function of OutputStream :
       public class DebugOutputStream extends OutputStream {
          private OutputStream os;
          public DebugOutputStream(OutputStream os) {
             super();
             this.os = os;
          @Override
          public void write(int b) throws IOException {
             System.out.println("ClientClient envoie " + b + " soit " + ((char)b));
             os.write(b);
    }The sender function says :
    Host demande à User1 de démarrer la procédure de réception.
    On a bien envoyé OBJ2AskerInfos sur le port 3001
    Byte = 4
    Byte = 0
    Byte = 7
    Byte = 8
    Byte = 9And the receiver function says :
    User1 a bien reçu l'objet OBJ2InfosOnAsker...
    User1 a bien reçu int.44
    On lance les 7 int :
    ClientCLient envoie 119 soit w       //
    ClientCLient envoie 4 soit          // Both of this lines are stranges
    ClientCLient envoie 7 soit
    ClientCLient envoie 8 soit
    ClientCLient envoie 9 soit      
    ClientCLient envoie 10 soit
    ...et a bien envoyé le port

    Minimus wrote:
    Ok, but this layer has maid just to print in the eclipse console the bytes written on the stream, With or without this function, the flush() operation generate 2 bytes, I don't know why.
    When I want to send manually the byte '7', the result of both lines :
       oos.writeByte(7);
    oos.flush();is that my writeByte and my flush send 3 bytes :
    Byte val = 119 charcode = w
    Byte val = 1 charcode =
    Byte val = 7 charcode =
    Only the 'Byte val = 7 charcode = ' line is good.
    Why the flush generate 2 unknown bytes at this code position ?Actually, it's (might be) writing more than two bytes. Run this:
    public class OOSTest {
       public static void main(String[] args) throws Throwable {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ObjectOutputStream oos = new ObjectOutputStream(baos);
          oos.writeByte(7);
          oos.close();
          byte[] bytes = baos.toByteArray();
          System.out.println(Arrays.toString(bytes));
          //prints "[-84, -19, 0, 5, 119, 1, 7]"
    }The explanation is in the Javadoc for ObjectOutputStream:
    Primitive data, excluding serializable fields and externalizable data, is written to the ObjectOutputStream in block-data records. A block data record is composed of a header and data. The block data header consists of a marker and the number of bytes to follow the header. OOSs should only be used when the OIS is being used properly on the other end. If you don't want this header, use a DataOutputStream. Is there an actual problem or are you just confused about the extra bytes? If there is a problem in reading, my guess is that you're somehow not reading from your OIS symmetrically with your OOS. Can you post a complete, compilable example that demonstrates the behaviour? There's obviously an issue somewhere, I just haven't spotted it yet.
    If there wasn't an actual problem in reading, well: there's your explanation.
    Edited by: endasil on 26-Oct-2009 10:55 AM

  • Problem with forward method of jsp

    am having problem with the requestDispatcher.forward method in my jsp + wml , the forward method gets executed but the new page is not displayed in the wap browser,
    code snippet
    small.jsp
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
    <%@ page language="java" %>
    <%@ page contentType="text/vnd.wap.wml; charset=UTF-8" %>
    <%@ page import="java.lang.*,java.io.*,java.util.*,java.util.Vector,java.util.Properties "%>
    <%
    System.out.println("in small");
    RequestDispatcher rd = request.getRequestDispatcher("small1.jsp");
    rd.forward(request,response);
    %>
    small1.jsp
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
    <%@ page language="java" autoFlush="false"%>
    <%@ page contentType="text/vnd.wap.wml; charset=UTF-8" %>
    <%@ page import="java.net.*,java.lang.*,java.io.*,java.util.*,java.util.Vector,java.util .Properties"%>
    <%
    String sm = "small1";
    System.out.println("in small1");
    %>
    <wml>
    <card id="two">
    <p>
    <small><%=sm%></small>
    </p>
    </card>
    </wml>
    i get the following output in the log
    in small
    in small1
    but i dont get to see the small1.jsp' content , also the response.sendRedirect method works fine ,,
    pls give me the soln
    Thnk u in advance

    thank u very for the repl this is the message which i get in the nokia wap browser...
    cannot load small1.jsp(HTTP Error 500 Server Error)
    and i use IBM WebSphere as the web server....
    and i have found that using response.reset in the small2.jsp overcomes this problem but the card title and the anchor tag is not displayed !!!!
    what could be this problem?

  • Problems with invoke call in browser (SAP Business Connector)

    Hallo,
    I have a problem with the invoke call in a browser to test a build flow in the SAP Business Connector:
    I build a flow which receives a XML file, converts it into a record, then adds some mandatory data to the segment "EDI_DC40", then reconverts it into XML. After that, the XML gets converted into SAP IDOC format. Then I send it via ALE service to the connected SAP System.
    The flow works so far if I test it with the "send XML file" function in "Test" menu. But when I test it via a call in the browser, it doesn´t work. The mandatory data in "EDI_DC40" is there, but the Business connector does not recognize the data which comes with the XML for this segment ("MESTYP" and "SNDPRN") - so it can not be transfered to the SAP system. It causes a routing rule error, because sender and message type is unknown.
    Does anybody has experiences with that? Is there a difference between browser call and the test function "send xml file"?
    Thanks in advance for your help!
    Kai

    Hi,
    Just debug your SAP BC service in which you are calling the RFC and check if proper values are getting mappend to your input variables of RFC.
    If that is correct than there wont be much chances of problem in BC.
    \[removed by moderator\]
    Regards,
    Siddhesh S.Tawate
    Edited by: Jan Stallkamp on Jul 1, 2008 4:32 PM

Maybe you are looking for

  • Checkbox in the title of JTabbedPane

    How can I add a check box to the title of the JTabbedPane, so that I can check-uncheck these tabs. Or is there a workaround/anothe idea that will allow me to have similar functionality. TIA, - Manish

  • Landscape & Portrait in Fluid Grid Layouts

    I am quite excited about Fluid Grid Layouts and have seen a few videos on Adobe TV and You Tube. Can anyone tell me if it takes in to account Tablets and Phones being turned into Landscape view from Portrait.

  • Record counter question

    Right now, my report looks like: Category           invoice number             invoice counter       A - 100---- 1 Result - 1       B - 100---- 1 Result - 1 Overall Result - 1 I know the overall result is correct, however the sum of category's result

  • Same event - Multiple commands

    Hi, Here's what I'm trying to achieve. I've an application where some events need to be added to an undo-redo queue. I'm trying to register two commands for the same event by initiating multiple controllers. So that one command does what the event is

  • Consumption of Semi-Finished Goods is showing more

    Hi, Consumption of Semi-Finished Goods is showing 1,671,226,661.14 which is very very HUGE. Our yearly turnover itself 200 Crores. But for April month alone it is showing 1,671,226,661.14. I am not able to findout the cause for this issue. Can anyone