Problem in synchronized methods

i have two synchronized methods.One methods displays a JFrame.It has a button jButton1.the other method just return boolean true.
these two methods are called by another class which has more methods.What i need is to run stop processing in parent class methods untill jButton1 is clicked.Can i use synchronizing for this?
Regards
Udayani
public synchronized void go() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {                                      
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
this.getContentPane().setLayout(null);
jPanel1.setLayout(null);
read();
int i=0;
while(i<fno){
jCheckBox=new JCheckBox();
jCheckBox[i].setText(Files[i].getParent()+"\\"+Files[i].getName());
System.out.println(i);
jCheckBox[i].setBounds(new Rectangle(10,30+i*30, 200, 23));
jPanel1.add(jCheckBox[i], null);
i++;
jPanel1.setBounds(new Rectangle(0, 0, 350,100+fno*30));
this.setSize(new Dimension(350, 100+fno*30));
     this.setTitle("Selected Files");
this.setVisible(true);
jButton2.addActionListener(new selectedFiles_jButton2_actionAdapter(this));
this.getContentPane().add(jPanel1, null);
jButton1.setBounds(new Rectangle(165, 30 + fno * 30, 75, 25));
jButton1.setFont(new java.awt.Font("Dialog", 1, 12));
jButton1.setMargin(new Insets(2, 13, 2, 14));
jButton1.setText("Yes");
jLabel1.setFont(new java.awt.Font("Dialog", 1, 12));
j Label1.setText("Add more files");
jLabel1.setBounds(new Rectangle(30, 35 + fno * 30, 154, 15));
jButton2.setBounds(new Rectangle(233, 30 + fno * 30, 75, 25));
jButton2.setFont(new java.awt.Font("Dialog", 1, 12));
jButton2.setMaximumSize(new Dimension(73, 25));
jButton2.setMargin(new Insets(2, 13, 2, 14));
jButton2.setText("No");
jPanel1.add(jLabel1, null);
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
repaint();
done=true;

if you don't use threads, you don't need "synchronized" all it does is slowing down your code, without any other effects.
Either you go into threads completely (yes, it is a non-trivial topic that requires some work) or you better leave it. Simply calling methods "synchronized" has no effect on your single-threaded program.

Similar Messages

  • Synchronized method in a java class used by many interfaces

    My interface (idoc to file) is using a java class, which has one method that reads a table from a central database and after doing some calculations updates it.
    (The interface instantiate the class inside a user-defined function and calls the method there.)
    The problem is that if somebody sends 100 idocs at the same time, there can be a “dirty read”, I mean, a read just before other interface updates the table.
    We want the following:
    Interface 1:
    -          Read counter from the table (counter = 5 )
    -          Increment counter (counter = 6)
    -          Update table with that counter (table with counter = 6)
    Interface 2:
    -          Read counter from the table (counter = 6 )
    -          Increment counter (counter = 7)
    -          Update table with that counter (table with counter = 7)
    RESULT: The table has the counter = 7
    But what is happening is the following:
    -          Interface 1 reads (counter = 5)
    -          Interface 2 reads (counter = 5)
    -          Interface 1 increments counter (counter = 6)
    -          Interface 2 increments counter (counter = 6)
    -          Interface 1 updates table (table with counter = 6)
    -          Interface 2 updates table (table with counter = 6)
    RESULT: The table has the counter = 6 (WRONG)
    I made the method synchronized. What I was expecting was that only one interface (i1) could enter the method (read the table and update it) while other interfaces running at the same time would have to wait until i1 finished that method.
    My first test indicates that's not happening. Can anybody help me to find a solution?

    Hi Bhavesh,
    If the QOS is EOIO this means that the integration engine manage the call to the mapping program (and all the other blocks) inside an "internal" synchronized method.
    So this means that in this case you do not need to manage the queued access (synchronization) inside your custom java code because it is already enveloped in a queued block by XI.
    The problem that Jorge had can be easily reproduced using the sample code that follows:
    <b>class Synch Object</b>
    import java.util.Date;
    public class SynchObject {
         String strName;
         public SynchObject(String strName){
              this.strName = strName;
         public synchronized void syncWrite(String strCaller) throws InterruptedException{
              Date now;
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " " + strCaller + " entering syncWrite of " + strName);
              System.out.flush();
              Thread.sleep(1000);
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " syncWrite of " + strName + " called by " + strCaller );
              System.out.flush();
              Thread.sleep(1000);
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " " + strCaller + " leaving syncWrite of " + strName);
              System.out.println("");
              System.out.flush();
    <b>class Caller</b>
    public class Caller implements Runnable {
         String strName;
         SynchObject target;
         int intMax;
         public Caller(String strName, SynchObject target, int intMax) {
              this.strName = strName;
              this.target = target;
              this.intMax = intMax;
         public void run() {
              for(int i=0; i<intMax;i++)
                   try {
                        target.syncWrite(strName);
                   } catch (InterruptedException e) {
                        e.printStackTrace();
    <b>class Workbench</b>
    public class Workbench {
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SynchObject sObj1 = new SynchObject("syncObj1");
              SynchObject sObj2 = new SynchObject("syncObj2");
              Caller c1 = new Caller("caller1",sObj1,2);
              Caller c2 = new Caller("caller2",sObj1,2); '[*CHANGE*]
              Thread ct1 = new Thread(c1);
              Thread ct2 = new Thread(c2);
              ct1.start();
              ct2.start();
    Run the workbench class to see what happen when setting QOS EOIO (the synch object is the same).
    To see instead what happen now (missing synchronization) you have to change in Workbench class the statement
    Caller c2 = new Caller("caller2",sObj1,2); '[*CHANGE*]
    with
    Caller c2 = new Caller("caller2",sObj2,2); '[*CHANGE*]
    The reason is that every instance of the mapping program declare a new instance of the "Synchronized object" so the calls are synchronized inside the same mapping program but not between several mapping program.
    Hope this give you a better idea on this problems with java synchronization, but if you have further doubts (I know it's a little bit tricky ) feel free to ask.
    Kind Regards,
    Sergio

  • Readers Writers problem and Synchronized doubts

    I made this code for implementing some Lock because I have to permit the write/read action on shared file between different threads. I would like to let more than one thread reading at the same time and just one for the writing
    This is my code, it's in italian but in english the class name would be AccessManager
    import java.io.Serializable;
    public class GestoreAccessi implements Serializable{
    //number of reader
    private int lettori= 0;
    //flag for someone writing
    private boolean scrittura= false;
    //number of writer waiting
    private int scrittoriAttesa = 0;
    private String nome;
    //Il gestore accessi prende un nome
    public GestoreAccessi(String nom) {
    nome = nom;
    //Blocco per la lettura -- Lock for Reading
    public synchronized void lockRead() {
    try {
    //Fino a che c'e' qualcuno in scrittura o processi che aspettano per la scrittura mi metto in attesa -- If ther is some thread writing or waiting for write
    while (scrittura || scrittoriAttesa > 0) {
    wait();
    //Altrimenti aumento la variabile dei thread in lettura -- Add one thread reading
    ++lettori;
    } catch (InterruptedException ex) {
    //Fine del processo di lettura -- Finish reading
    public synchronized void unlockRead() {
    --lettori;
    // solo gli scrittori sono in attesa e uno soltanto deve essere svegliato
    if (lettori == 0) {
    notifyAll();
    //Blocco per la scrittura -- Start Writing
    public synchronized void lockWrite() {
    ++scrittoriAttesa;
    //Fino a che ci sono lettori o qualcuno che scrive aspetto -- if there are readers o someone writing
    while (lettori > 0 || scrittura) {
    try {
    wait();
    } catch (InterruptedException ex) {
    --scrittoriAttesa;
    //Altrimenti inizio il processo di lettura -- Start the process of reading
    scrittura = true;
    //Fine del processo di scrittura
    public synchronized void unlockWrite() {
    scrittura = false;
    notifyAll(); // sblocca uno o piu' lettori o uno scrittore
    Before all critical part I create a GestoreAccessi object and invoce the .lock.. method and finish the critical part the .unlock.. Do you think it's a good way to solve the problem?
    I have some doubts on the multiple reading at the same time. I read on synchronized: "First, it is not possible for two invocations of synchronized methods on the same object to interleave. When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block (suspend execution) until the first thread is done with the object.
    Second, when a synchronized method exits, it automatically establishes a happens-before relationship with any subsequent invocation of a synchronized method for the same object. This guarantees that changes to the state of the object are visible to all threads."
    It's possible to two different thread read at the same time? The .lockRead() method is synchronized: if one thread has acess in a critical part it takes the lock and no other thread would be able to have an access on the same part?! How can i do this? I have not to declare synchronized the read method?
    Please help me and sorry for my bad english!!
    Bless from Italy

    >
    I made this code for implementing some Lock because I have to permit the write/read action on shared file between different threads. I would like to let more than one thread reading at the same time and just one for the writing
    >
    Multiple threads and even applications can read the same file at the same time; it is writing that is problematic.
    There is nothing in what you posted that even shows any 'file' manipulation so no comments can be made about that.
    It looks like you took those quotes from this Java Tutorial Page on Synchronizeds Methods
    http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
    Those quotes are accurate as far as synchronizing a particular instance is concerned but that would not prevent some other code from trying to read/write the same file. But again, you code doesn't even include any file-related objects that you are trying to control access to.
    See the Java Tutorial section on 'Lock Objects'
    http://docs.oracle.com/javase/tutorial/essential/concurrency/newlocks.html

  • Nested synchronized method class

    Hi. I have a situation where there are two synchronized methods: Method A and Method B. In the course of execution, Method A calls Method B. Method B calls wait(). This causes a classical deadlock as wait() releases the monitor for Method B, but no for Method A. What are my options to work around this problem?
    Thanks in Advance,
    Paul0al

    A and B cannot synchronize on the same object because if A acquires the monitor, then B cannot obtain the same monitor without A releasing the monitor. My problem is that A and B are synchronized on different objects. A calls B and B calls wait(). A deadlock occurs because A's monitor is not released.
    Thanks,
    Paul0al

  • Optimizing synchronized method?

    A couple of other threads got me to thinking about a bit of code I commonly use. Is a synchronized method really expensive enough to make this modification warranted?
    Original method:
      private static Manager theManager = null;
      public static synchronized getManager() {
        if (theManager != null) return theManager;
        theManager = new Manager();
        return theManager;
      }Optimized version:
      private static Manager theManager = null;
      public static getManager() {
        if (theManager != null) return theManager;
        synchronized (theManager) {
          if (theManager != null) return theManager;
          theManager = new Manager();
        return theManager;
      }The intent is that since theManager gets created only rarely (i.e. once at the beginning of the session) all the subsequent invocations do not need to execute the synchronized logic. Is this worth it?

    The article states that the use of the volatile keyword fixes the problem, at least for later versions Java. Is that not right?For JDK 1.5 and above, perhaps. For JDK 1.4 and below, no.
    However, I am more interested in the solution presented by a link elsewhere in that article:
    http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom
    That method solves the problem and no synchronized keyword is needed at all.That's true. However, follow the [double-checked locking|http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html] link in that article, to actually understand what's going on. And pay particular attention to the part that says For most applications, the cost of simply making the getHelper() method synchronized is not high. You should only consider this kind of detailed optimizations if you know that it is causing a substantial overhead for an application.
    And finally: you do realize that singleton is almost never necessary, introduces tight coupling into your program, and makes it difficult to test. Right?

  • Synchronized method not preventing concurrent access

    Hi
    I have 3 classes, T (a Runnable), TRunner (instantiates and starts a thread using T), and Sync (with one synchronized method, foo).
    The problem is that foo is entered concurrently by different threads at the same time. How so?
    T.java:
    import java.util.Calendar;
    class T implements Runnable
       private String name;
       public T(String name)
         this.name = name;
       public void run()
          Thread.currentThread().setName(name);
          Sync s = new Sync();
          System.out.println(Calendar.getInstance().getTime() + ".....Running " + Thread.currentThread().getName());
          s.foo(name);
    }TRunner.java:
    class TRunner
       public static void main(String args[])
           T tx = new T("x");
           T ty = new T("y");
           T tz = new T("z");
           Thread t1 = new Thread(tx);
           Thread t2 = new Thread(ty);
           Thread t3 = new Thread(tz);
           t1.start();
           t2.start();
           t3.start();
    }Sync.java:
    import java.util.Calendar;
    class Sync
       public synchronized void foo(String threadname)
              System.out.println(Calendar.getInstance().getTime() + ":" + threadname + "....entering FOO");
              try
                   Thread.sleep(5000);
              catch (InterruptedException e)
                   System.out.println("interrupted");
              System.out.println(Calendar.getInstance().getTime() + ":" + threadname + "....leaving FOO");
    }Console output:
    C:\javatemp>java TRunner
    Mon Apr 09 15:35:46 CEST 2007.....Running x
    Mon Apr 09 15:35:46 CEST 2007:x....entering FOO
    Mon Apr 09 15:35:46 CEST 2007.....Running y
    Mon Apr 09 15:35:46 CEST 2007:y....entering FOO
    Mon Apr 09 15:35:46 CEST 2007.....Running z
    Mon Apr 09 15:35:46 CEST 2007:z....entering FOO
    Mon Apr 09 15:35:51 CEST 2007:x....leaving FOO
    Mon Apr 09 15:35:51 CEST 2007:y....leaving FOO
    Mon Apr 09 15:35:51 CEST 2007:z....leaving FOO
    C:\javatemp>Thanks in advance.

    Only for static methods. For instance methods, the lock >is the object.You are absolutely right.
    The Class object is no different from any other object. >"Entire" Class object makes no sense.What I wanted to say is that it's better to synchronize on the object we want to protect from concurrent access rather than on the entire class or instance object.
    "Efficiency" is not altered by locking on a Class object vs. >any other object.I studied that it's better to synchronize on the objects we want to protect instead of the entire instance or class object. If one declares a method as synchronized, it means that other threads won't be able to access other synchronized methods for the same object, even if the two weren't in conflict. That was explained as a performance penalty.
    >
    Or when one or more threads may modify it and one or
    more may read it.
    Yep, sure.
    >
    No, they're not.
    You are absolutely right. What I wanted to say is that local variables are unique per thread.
    >
    Local variables are unique per thread, but that's NOT
    atomicity.Sorry for any confusion
    Message was edited by:
    mtedone

  • Which object's monitor does a synchronized method acquire?

    from the Java Tutorial for concurrency programming:
    " When a thread invokes a synchronized method, it automatically acquires the intrinsic lock _for that method's object_ and releases it when the method returns. The lock release occurs even if the return was caused by an uncaught exception. "
    what exactly does this mean?
    do synchronized methods acquire the monitors for objects of type: java.lang.reflection.Method
    please consider this code:
    public class Foo {
      private int counter = 0;
      public synchronized void incriment() { counter++; }
      public synchronized void decriment() { counter--; }
    Foo f = new Foo();
    Class[] sig = new Class[0];
    Method m = f.getClass().getMethod("incriment", sig);
    // ok. so "m" is the relevant method object.
    f.incriment(); // <-- is the monitor for "m" ,
                          // or the monitor for "f", acquired?
    .......my reading of the Concurrency Tutorial is that synchronized methods use the monitors of java.lang.reflection.Method objects?
    and thus, Foo is not thread safe, right?
    however, this simple change makes Foo thread-safe?
    public class Foo {
      private volatile int counter = 0; // "volatile"
      public void incriment() { counter++; }
      public void decriment() { counter--; }
    }thanks.
    Edited by: kogose on Feb 23, 2009 7:13 PM

    tensorfield wrote:
    jverd wrote:
    tensorfield wrote:
    kogose wrote:
    what exactly does this mean?It means you're complicating things.
    If a method is synchronized, it is. You don't need to go beyond that. The method is synchronized.Not true. You have to know what it means for a method to be synchronized. Often people come in with the erroneous impression that it somehow prevents you from using or accessing the object in any other thread.It's very simple. If a synchronized method is called at the same time from many threads only one call will be executed at a time. The calls will be lined up and performed one after the other in sequence.
    AND because synchronization is on a per object basis, when one synchronized method is being called from one thread, all synchronized methods of that same object are blocked for calling from other threads.
    Simple as that.No, it's not that simple, and as stated, that is not correct. In particular, you didn't mention that for an instance method, all the various threads have to be trying to call instance methods on the same object in order for execution to be sequential.
    You really can't understand Java's syncing without understanding how it relates to locks, and what it means for a method to be synchronized in terms of which lock it acquires.
    Edited by: jverd on Feb 25, 2009 2:47 PM

  • Calling static synchronized method in the constructor

    Is it ok to do so ?
    (calling a static synchronized method from the constructor of the same class)
    Please advise vis-a-vis pros and cons.
    regards,
    s.giri

    I would take a different take here. Sure you can do it but there are some ramifications from a best practices perspective. f you think of a class as a proper object, then making a method static or not is simple. the static variables and methods belong to the class while the non-static variables and methods belong to the instance.
    a method should be bound to the class (made static) if the method operates on the class's static variables (modifies the class's state). an instance object should not directly modify the state of the class.
    a method should be bound to the instance (made non-static) if it operates on the instance's (non-static) variables.
    you should not modify the state of the class object (the static variables) within the instance (non-static) method - rather, relegate that to the class's methods.
    although it is permitted, i do not access the static methods through an instance object. i only access static methods through the class object for clarity.
    and since the instance variables are not part of the class object itself, the language cannot and does not allow access to non-static variables and methods through the class object's methods.

  • 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 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 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);

  • Problems using GET method in JSP

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET method in JSP?
    If anyone have solutions, please let me know.
    thanks.

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in
    windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is
    good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET
    method in JSP?
    If anyone have solutions, please let me know.
    thanks.This problem appears, when one use UTF-16 encoding in JSP - am I right?
    If so there are two solutions:
    1) Temporary: Use "UTF-8" - or any other 8 bit encoding scheme and
    encode Korean symbols with "&1234;" kind of escapes - though it
    may not work
    2) Absolute: get my piece of code, which I have managed to write
    just a month ago resolving absolutely similar problem with UTF-16
    in code using Chinese/Russian/English encodings
    But I wouldn't say that it's costs 10 DDs :) - it's much more
    expensive... So try 1st variant if it wouldn't help - let me know.
    I'll figure :)
    Paul

Maybe you are looking for

  • Please HELP, "iTunes has stopped working" error after connecting iPod video

    People please help me out!  I have a Razer Blade gaming laptop with Windows 8 64bit. I have an iPhone 5, iPad 2 and an iPod video (80GB).  I had some weeks from not connecting the iPod to my computer, but this morning that I did so I can upload some

  • Fetching SSIS error message into Audit table using SP

    Hi Experts, I want to fetch SSIS Error Info along with Task Name into Audit table 'Error_Info' column. This is nvarchar(max) datatype, i wrote below Stored Procedure for this (Column names passing dynamically in SP) CREATE PROC [dbo].[usp_AuditErrorH

  • Tricky upload file problem

    Hi, I have created a page to allow people to upload a file, OR just insert the url of the file. I am getting errors when I choose the option not upload the file. The first page has two input fields, one is text and the other is file - they both go to

  • Bb classic cant connect to bb server

    sorry i cant find how to continue my previous post message. the problem still exist, cant connect to bb server. my pin {REMOVED} THANKS Mod Edit: Edited post to remove personal information to comply with the Community Guidelines and Terms and Conditi

  • Sync Log

    I've set my Itunes 10.1 to sync one my photo folder Into this folder there are 158 files .jpg When i click sync button, itunes work for 1 minute and does'nt show any errors but on my Iphone 4 there are'nt new pic files ! Itunes save a log file to und