Threads, swing etc...

Hi, I need to develop a software that manage the windows creation. Each windows make some operation: eg. show or manage some data or is a text editor and so on.. I need to know the general idea that is behind the design of a software of this type. I make myself more clear: I don't know the startup, if I need to make a tread manager and use a thread for each window, or use some kind of design pattern for manage this situation.
Someone has the expertise for explain this such of problem?

The systematic difference in GUI programming as opposed to a simple command line program is that it's handled as events. An event usually represents a user action (sometimes it's a timer or the like). You provide code to handle that event, which may result in a change in what is displayed. But once you've handled an event your handler code finishes and the system goes back to waiting for the next event.
In an ordinary program there's a definite sequence to be executed, in a GUI program the program spends most of it's time waiting for the user to decide what he wants to do next.
However sometimes an event launches an activity which runs for some time in the background and, when it's ready, changes the display. These activities are called "worker threads" and have more resemblance to ordinary programs.
The GUI event processing occurs as a loop on a single thread, and only one event is processed at a time. This means event handlers must finish quickly, to let other events proceed. An event that launches an action that is likely to take more than a fraction of a second should start a worker thread.

Similar Messages

  • Threading Swing, is this correct?

    Hey guys
    Ive just done a little swing window, that is thread safe... well i think it is, im asking you guys if this is the correct way to create a swing app (composition rather than inheritance) and if i add more comonents will they each (e.g JButton) need to be implemented as threads?
    any help and your experience would be great
    cheers
    This is the code for a simple window, Is it how you pros would do it?:
    import javax.swing.JFrame;
    import java.lang.*;
    public class UI implements Runnable
    private JFrame wnd = new JFrame("CLIENT");
    public void createWnd()
    wnd.setSize(400, 400);
    wnd.setDefaultCloseOperation(wnd.EXIT_ON_CLOSE);
    wnd.setVisible(true);
    public void run()
    createWnd();
    System.out.println("Thread started");
    public boolean closed()
    if((wnd.getDefaultCloseOperation()) == wnd.EXIT_ON_CLOSE)
    return true;
    return false;
    //System.out.println("pressed closed");
    public static void main(String[] args)
    UI appWindow = new UI();
    Thread t = new Thread(appWindow);
    t.start();
    if(appWindow.closed())
    t = null;
    System.out.println("Thread stopped");
    } Message was edited by:
    FatClient

    So the reason that a swing application needs to be on
    the EDT of each swing UI (and not on a user thread)
    is because thats the queue that holds keystrokes,
    mouse clicks, etc that may need the UI to be redrawn
    after an event.
    And if you had other code going on, this would not be
    interrupted/paused whilst the EDT/GUI were working to
    redraw a bit of the app - Bcause it is in a THREAD.Swing sets up the EDT (Event Dispatch Thread), and what it does is
    pretty simple: it dequeues swing events like mouse events and
    keyboard events, etc... and causes the appropriate listener methods
    to be called. So for example, ActionListener's actionPerformed methods
    are going to be called on the EDT (if you coded correctly).
    In Java you are free to create other threads, but you always have to
    be careful when multiple threads access common data. In the case
    of Swing, to keep its implementation as simple as possible, most
    Swing methods are meant to only be called from the EDT.
    Please let me know if thats why i should blindly
    listen to the JDK tutorials as if it were some sort
    of bible/Torah/Quran The Java Language Specification (JLS) is the Koran. The tutorials are the Hadith :-)

  • Threads + Swing = Confusion

    Hi all,
    I am having a problem with threads and Swing apps. I have read the tutorial 3 times and get more confused each time i try to understand how to update the gui with the other thread.
    At this point I'm just trying to do something simple (eventually i want the gui to report all the progress of the action): get a progress bar to be updated through a Thread Class. I have the gui built with a button and a progress bar. Here is the codei have for the simpleThread class
    import java.awt.*;
    import javax.swing.*;
    public class simpleThread extends Thread{
        public simpleThread(String str) {
            super(str);
        public void run() {
            for (int i = 0; i<1000000; i++) {
                final int x = i;
                Runnable getTextFieldText = new Runnable() {
                    public void run() {
                       jProgressBar1.setValue(x);
        SwingUtilities.invokeAndWait(getTextFieldText);
    }The problem i have is that the thread doesn't recognize the gui form. Any help on getting the progress bar to update with the thread would be great! Thanks! :)

    There's been too much bad code submitted to this topic to comment on it individually, but:
    1. Don't call a thread or runnable's run() method directly, if you expect it to be executed in a different thread! Call thread's start method instead.
    2. If you want code executed in the Event Dispatch Thread (EDT), pass a runnable to InvokeLater (usually preferrable to InvokeAndWait). That runnable's run method will be executed in the EDT -- there's no need to write complicated nested run methods!
    In the case of JProgressBar, I was concerned about flooding the EDT with many "invokeLater" runnables, so I penned this wee class:
    import javax.swing.*;
    public class Updater  {
         private final JProgressBar jpb;
         private boolean queued;
         private int val;
         private Runnable runnable = new Runnable() {
              public void run() {//called from EDT:
                   int _val;
                   synchronized(Updater.this) {
                        queued = false;
                        _val = val;
                   jpb.setValue(_val);
         public Updater(JProgressBar jpb) {
              this.jpb = jpb;
         public void update(int _val) {
              boolean go = false;
              synchronized(this) {
                   val = _val;
                   if (!queued) {
                        queued = true;
                        go = true;
              if (go)
                   SwingUtilities.invokeLater(runnable);
    }To use it, you would typically declare it as a field:
    private Updater updater = new Updater(yerBar);Then repeatedly call (from any thread)
    updater.update(yerValue);

  • Threads + Swing

    Hi folks,
    I found the following code here at SDN. The main purpose of this code is to execute an exe-file and to redirect its output to a java Swing JTextArea.
    This code works fine. However, if I change...
        public cCallGenerator()
            init();
            initProcess();
        }...to...
        public cCallGenerator()
            init();
            // initProcess(); NOW WE DONT START THE PROCESS HERE
        }and start initProcess() by clicking on the button, the output is NOT(!) redirected to the JTextArea. The exe file is still running.
    I guess that I simply misunderstood the concept of threads in java...
    Can anybody help me?
    Thanks a lot
    Christian
    Here is the code:
    import javax.swing.*;
    import org.dom4j.Document;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.*;
    public class cCallGenerator extends JFrame {
        private JTextArea textArea;
        private JTextField textField;
        private PrintWriter writer;
        public cCallGenerator()
            init();
            initProcess();
        public void init()
            textArea = new JTextArea(20, 80);
            textArea.setEditable(false);
            textField = new JTextField(30);
            textField.addKeyListener(new KeyAdapter()
                public void keyPressed(KeyEvent event) {
                    if (event.getKeyCode() == KeyEvent.VK_ENTER)
                        if (writer != null)
                            textArea.setText("");
                            writer.print(textField.getText() + "\r\n");
                            writer.flush();
                            textField.setText("");
            Container container = getContentPane();
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setViewportView(textArea);
            container.add(scrollPane, BorderLayout.CENTER);
            container.add(textField, BorderLayout.SOUTH);
            JButton start = new JButton("Start");
            container.add(start, BorderLayout.WEST);
                                       start.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                 try {
                                                      initProcess();
                                                 } catch(Exception e) {
                                                      JOptionPane.showConfirmDialog(null,
                                                                "The following error occured while trying to generate the configuration file: \n\n" + e.getMessage(),
                                                                "XML Error",
                                                                JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);     
                                                      System.exit(1);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            textField.grabFocus();
            setVisible(true);
        public static void main(String[] args) {
            new cCallGenerator();
        public void initProcess()
            Runtime rt = Runtime.getRuntime();
            try
                //Process p = rt.exec(new String [] {"cmd", "/C", textField.getText()});
                //textArea.setText("");
                //textField.setText("");
                Process p = rt.exec("panoratio.exe -g -c output.xml -o output.pdi");
                writer = new PrintWriter(p.getOutputStream());
                Thread thread1 = new Thread(new StreamReader(p.getErrorStream()));
                Thread thread2 = new Thread(new StreamReader(p.getInputStream()));
                thread1.start();
                thread2.start();
                System.out.println("Exit Value = " + p.waitFor());
            catch (Exception ex)
                textArea.append(ex.getMessage());
                ex.printStackTrace();
        public class StreamReader implements Runnable
            InputStream is;
            public StreamReader(InputStream is)
                this.is = is;
            public void run()
                try
                    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                    String data;
                    while ((data = reader.readLine()) != null)
                        textArea.append(data + "\n");
                    reader.close();
                catch (IOException ioEx)
                    ioEx.printStackTrace();
    }

    Thanks for your help!
    I still don't really understand why - but if I replace
                thread1.start();
                thread2.start();with
                thread2.start();
                SwingUtilities.invokeAndWait(thread1);it works. So, thanks a lot for your help.
    Bye

  • Memory Leak in a multi threaded Swing application  (ImageIcon)

    When I profile my swing application with netbeans 5.5 , I notice that after each periodically tidy up my image container (add,remove IconImage objects to a hashmap or arraylist), there gather by and by surviving objects. This leads to run out of memory after a while. Is there any other way to avoid this effect?
    Any ideas about "The JVM is notorious for caching images."
    please help..
    what I have made briefly:
    1.) Read the binary stream from the db :
    rs=stmt.executeQuery(query);
    if(rs.next()){
        int len=rs.getInt(2);
        byte [] b=new byte[len];
        InputStream in = rs.getBinaryStream(3);
        try {
                in.read(b);
                in.close();
                img=Toolkit.getDefaultToolkit().createImage(b);
         } catch (IOException e) {
                e.printStackTrace();
    stmt.close();
    rs.close();2.) hold the icon as field :
    this.icon =  new ImageIcon(img);3.) After a while I remove the object from my collection and on the
    overridden method finalize() I also call the flush() method.
    if(this.icon != null){
                this.icon.getImage().flush();
                this.icon = null;
    }The surviving objects still increase?! On the page of SUN they
    submitted a bug. But this is set on closed/fixed.
    (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4014323)
    What am I doing wrong? I also use the byte[] constructor on creating the icon and
    my java version is 1.5.0_10.

    If in your JFrame u have placed your image, before invoke the dispose()
    method put explicitly the image pointer to null and deregister all listener
    you have added to any componentI implemented your suggest and after starting a long time test, in one hour there gathered aprox. 500 surviving generations. I attach a snapshot and the java file ( http://www.box.net/public/eqznamrazd ). The used heap size swings between 3MB and 5MB. I guess this wont kill so quickly the application but anyway there is something wrong!
    Even properly closed streams, database connections etc.. Really despairing. Could one take a look to the java source?
    some snippets bellow:
    private class MyImageIcon extends ImageIcon {
            public MyImageIcon(Image img){
                super(img);
            public void removeImage(Image anImage){
                tracker.removeImage(anImage);
    private class DetailDialog extends javax.swing.JFrame {
            private String personnr;
            private MyImageIcon icon;
            public DetailDialog(String personnr,MyImageIcon icon){
                this.personnr = personnr;
                this.icon = icon;
            public void dispose() {
                if(icon != null){
                    icon.removeImage(icon.getImage());
                    icon.getImage().flush();
                    icon = null;
                super.dispose();
    private class Person extends Object {
            private MyImageIcon icon;
            private String number;
            private DetailDialog detailDialog;
            protected void destroy() {
                if(icon!=null){
                    icon.removeImage(icon.getImage());
                    icon.getImage().flush();
                    icon = null;
                if(detailDialog!=null){
                    detailDialog.dispose();
    private Image LoadImageFromDB(String personnr){
            Image img = null;
            String filename = personnr + ".jpg";
            Connection con = getMysqlConnection();
            Statement stmt;
            ResultSet rs;
            try {
                stmt = con.createStatement();
                String query = "select * from personImage where image='"+filename+"'";
                rs=stmt.executeQuery(query);
                if(rs.next()){
                    int len=rs.getInt(2);
                    byte [] b=new byte[len];
                    InputStream in = rs.getBinaryStream(3);
                    try {
                        in.read(b);
                        in.close();
                        img =
                                java.awt.Toolkit.getDefaultToolkit().createImage(b);
                    } catch (IOException e) {
                        e.printStackTrace();
                rs.close();
                rs = null;
                stmt.close();
                stmt = null;
                con.close();
                con = null;
            } catch (SQLException e) {
                e.printStackTrace();
            return img;
    public void random(){
            java.sql.ResultSet rs = null;
            java.sql.Statement stmt=null;
            java.sql.Connection con = getSybaseConnection();
            try {
                try {
                    stmt = con.createStatement();
                    rs = stmt.executeQuery(randomquery);
                    while(rs.next()){
                        Person person = new Person();
                        person.number = rs.getString("PersonNr");
                        Image img = LoadImageFromDB(person.number);
                        if(img !=null){
                            MyImageIcon ico = new MyImageIcon(img);
                            person.icon = ico;
                        person.detailDialog = new
                                DetailDialog(person.number,person.icon);
                        personList.add(person);
                        System.out.println("Container size: " +
                                personList.size());
                        counter++;
                    if(counter%20 == 0){
                        for(Person p : personList){
                            p.destroy();
                        personList.clear();
                        System.gc();//no need, but I force for this example
                        System.out.println("Container cleared, size: " +
                                personList.size());
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }finally{
                    if(rs != null){
                        rs.close();
                    }if(stmt != null){
                        stmt.close();
                    }if(con != null){
                        con.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
        }

  • Threaded swing applet

    Hi,
    I need to write an applet that shows the results of a database query on a JTable.
    The query will be executed every second (only a few registers are retrieved from a mySQL db), and if a change is detected, the JTable must be updated.
    I've been reading about Swing and threads, and I know I must be careful when workin with threads on my GUI.
    So far, I know there exists a few methods to perform what I need, but I'm not shure which one would be the best for my app.
    The methods I'm considering are:
    - invokeLater or invokeAndWait
    - timer
    - SwingWorker
    What do you guys sugest and why ?
    Thanks

    Not sure of this, but I think you need both Timer (to query DB every second) and SwingUtilities.invokeLater (because your update task must be run outside of EDT)...
    Hope this helped a little,
    Regards.

  • Thread+Swing

    Iam developing a program which involves setting up an auction bid system. The application creates threads to service clients which send in bids. There is a GUI which displays the IP address, the time of bid and the bid amount. The application threads write to a shared buffer and Iam using a swing timer to automatically generate action events to read from the shared buffer. Iam using Semaphores to syncronize the access to the shared buffer. The trouble is that the GUI seems to go "dead". I can't click on the buttons on it . Iam new to java and would appreciate any help on this

    Post the code. Your description is far to vague to be of help.

  • Thread - jdialog etc

    Hi!
    My good old problem still :(
    So in a button's actionlistener I made a much-time-needed thing. During that I want to popup a jdialog that displays 'please-wait'. I made a thread, which gets the main-frame as a parameter, so in this thread I make a dialog, the main-frame as the owner, I put it modal etc. And when the much-time-needed thing stops, then I want the dialog to be closed etc. I made after much-time-needed source to .stop() the thread, but the jdialog is still there. I hope it's clear, help me asap plz :)
    thanks,
    athalay

    .stop() shouldn't be used. It might not even work anymore. You need to create your first design in concurrency :) You will have to wait on some lock after you put the "please wait" screen. Your other Thread (could be the AWT) will then change a condition and notify.. (with notifyAll().. bad names ... another story) The waiting Thread. Past the wait loop will be the code to dispose of the dialog... sound fun? I think it is, I love concurrent designs.
    // The processing Thread (could be in an AWT event)
    new Thread(new Runnable() {
      pubic void run() {
        // I'm about to do a ton of processing
        new Thread( pleaseWait ).start();
        // I'm processing... la la la la
        // I'm done processing... la la la
        pleaseWait.endIt();  }
    // somewhere else
    pleaseWait = new Runnable() {
      boolean done = false;
      public void run() {
        // put up the dialog here
        while( !done ) {
          synchronized( this ) { // this is good for a lock :)
            wait();
        // if your here you are done... close the dialog
      public void endIt() {
        synchronized( this ) { // notice it's the same lock :)
         done = true;
         notifyAll();

  • Threads (webservices etc)

    hi,
    i'm writing webservices, portal components etc which use a custom-base-class which starts a thread and listens on a given port. so far so good. everything works fine etc etc.
    but my problem is, when i re-deploy the application or i stop it within the visual administrator's deploy feature, the webservice or portalcomponent stops successful (cant open it using the portal or the webservice navigator), but the thread is still running and i dont know why. i even abstracted the finalize() function to kill my sub-threads, but that doesnt work either.
    any help or suggestions? i just want to have my applications clean, so if i stop them, all subthreads will die... or even better, a function call.. like finalize() would ne the best damn thing for me.
    thanks,
    constantin

    hi, this is a very simple code, just to demonstrate what i want to do.
    this is a simple sap webservice, which i simply deploy and test the webservice using the "web services navigator" (function which is public to the service is "test(String)". so far so good. everything works as expected. but when i stop the web service with the deploy service using the visual administrator. the application and/or thread is still running... printing "zzz ZZZ zzz" in my debug log. even the simple checks in "run()" doesn't work. is there any work around? i COULD implement a function/service in my portal administration app which starts/stops applications using the sap deploy-service using the deploy.jar to start and stop the applications.. but let the application know that they are about to stop before, so they can shutdown their threads, open sockets etc...
    package de.wsa.test;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class Test {
         private static final Log LOG = LogFactory.getLog(Test.class);
         private TestThread thread;
         public Test() {
              LOG.debug("TEST");
              thread = new TestThread(this);
         public String test(String test) {
              LOG.debug("test");
              return test;
         protected void finalize() throws Throwable {
              LOG.debug("finalize");
              thread.setStop(true);
              super.finalize();
         public static class TestThread extends Thread {
              private static final Log LOG = LogFactory.getLog(TestThread.class);
              private Test test;
              private boolean stop = false;
              public TestThread(Test test) {
                   LOG.debug("TestThread");
                   this.test = test;
                   start();
              public void setStop(boolean stop) {
                   LOG.debug("setStop");
                   this.stop = stop;
              public void run() {
                   LOG.debug("run");
                   while (true) {
                        if (stop) {
                             LOG.warn("stop");
                             break;
                        if (Thread.currentThread().isInterrupted()) {
                             LOG.warn("Thread.currentThread().isInterrupted()");
                             break;
                        if (isInterrupted()) {
                             LOG.warn("isInterrupted()");
                             break;
                        if (test == null) {
                             LOG.warn("test == null");
                             break;
                        LOG.debug("zzz ZZZ zzz");
                        try {
                             Thread.sleep(5000);
                        } catch (Exception e) {
                             //swallow silently
    Edited by: Constantin Wildförster on Apr 23, 2010 11:46 AM

  • Stringtokenizer, swing and memory

    i lately found that the stringtokenizer eats up lots of memory, i tried to set vars to null and called sys gc quite often but they didnt seem to be of much help.
    ok, here is what i was doing: i read in a quite a big txt file, about 400k lines, and then parsed each line using stringtokenizer, everything happened in while loops, lots of objects but all small ones. i had to xmx lots of memories to it in order to run it. and it became much worse when i put it into multi threaded swing app. if you are a swing expert, or stringtokenizer expert, please shed some light.

    Dang it! Sun zapped a bunch of posts!
    Anyway, here again is a sample pgm posted earlier (which got zapped) showing some of the benefits of the finally block, for which the idiot daFei could not come up with an intelligent answer to refute it (he STILL has a beef with the finally block, claiming it is only "syntactic sugar", and still moronically implies that all methods must handle all exceptions, which is absurd in that no exceptions could ever be THROWN then!)
    import java.io.File;
    import java.io.IOException;
    class SillyQuestionException extends Exception {
      public SillyQuestionException() {
        super("That's a silly question.  Of course!");
    class Guru {
       * Responds to a question/statement.  A temporary file is created
       * during execution, and deleted upon return (unless daFei dorks
       * with the implementation!)
       * @param request the question/statement for Guru to respond to
       * @return the Guru's response
       * @throws SillyQuestionException if the Guru determines you're
       * asking a silly question,
       * to which the answer should be obviously YES
      public static String respond(String request)
        throws SillyQuestionException {
        File f = new File("daFei.is.an.idiot");
        try {
          System.out.println("  Guru is thinking...");
          f.createNewFile();
          // let's just assume we needed to write stuff to this file in
          // order to process the request...
          // now the actual end of processing
          if ("is daFei an idiot".equals(request))
            throw new SillyQuestionException();
        catch (IOException e) {
          System.out.println("Error occurred creating/writing to " +
            "temp file, but graceful recovery is possible");
          e.printStackTrace();
          return "I'll have to get back to you on that one.  " +
            "Ask me again later.";
        finally {
          // this is NECESSARY to GUARANTEE deletion of the temp file,
          // otherwise this statement would have to be duplicated at all
          // possible return points.
          System.out.println("  Guru has processed your request...");
          if (f != null)
            f.delete();
        System.out.println("  will this get printed EVERY time?  " +
          "NO IT WILL NOT!");
        return "daFei has fish turds in his brain";
    public class Demo {
      public static void main(String[] args) {
        String[] questions = {
          "what statement best describes daFei",
          "what kind of turds does daFei have in his brain",
          "is daFei an idiot",
          "won't get to this question"
        try {
          for (int i = 0; i < questions.length; ++i) {
            System.out.println("Question: " + questions);
    System.out.println("Response: " + Guru.respond(questions[i]));
    catch (SillyQuestionException e) {
    System.out.println("I have finally asked the Guru a silly " +
    "question, and will stop now");
    System.out.println("Here's what Guru had to say to the last " +
    "question: " + e);

  • How many  threads are running?

    here's the code... i am trying to understand, at each point, how many threads are running:
    I understand that one thread belongs to the caller of the start()
    & at the same time there is another thread belonging to the instances of each thread (thread1, thread2, thread 3 etc.)
    1public class ThreadTester {
    2   public static void main( String args[] )
    3   {
    4      PrintThread thread1, thread2, thread3, thread4;
    5
    6      thread1 = new PrintThread( "thread1" );
    7      thread2 = new PrintThread( "thread2" );
    8      thread3 = new PrintThread( "thread3" );
    9      thread4 = new PrintThread( "thread4" );
    10
    11      System.err.println( "\nStarting threads" );
    12
    13      thread1.start();
    14      thread2.start();
    15      thread3.start();
    16      thread4.start();
    17
    18      System.err.println( "Threads started\n" );
    19   }
    }can you tell me if i am counting the number of threads in existance correctly...
    LINE#.....CALLER...START...TOTAL THREADS
    13..............1.........1.......2
    14..............1+1......1+1.....4
    15..............2+1......2+1.....6
    16..............3+1......3+1.....8
    so by the time line 16 executes i have a total of 8 threads,
    4 threads belonging to each caller plus
    4 threads created by start()
    or is it
    LINE#.....CALLER...START...TOTAL THREADS
    13..............1........1........2
    14..............1........1+1.....3
    15..............1........2+1.....4
    16..............1........3+1.....5
    after line 16 executes does the caller thread die, thus leaving only a total of 4 threads?
    there is only one thread belonging to the caller at line 13(plus the thread it creates).
    at the start of line 14, the previous callers thread is dead & now a new thread is created that belongs to the caller on line 14... etc.

    well, i realize at the end there would be 4 threads but im trying to get my head around this explanation in the book:
    "A program launches a threads executioin by calling the threads start method, which in turn call the run method. After start launches the thread, start returns to tis caller immediately. The caller then executes concurrently with the lauched thread." there fore if i have 2 concurrent processes, are there 2 threads running????
    now having said the above, my question was:
    for each line,
    how many threads are in existance at
    line13
    line14
    line15
    line16
    thanks.

  • How can I show files in table from BlobDomain(image,Doc,pdf etc) with icons

    Hi,
    i need to display collection of files in a table, the files have been saved as BlobDomain. Db contains different types of files (like jpg,pdf,doc etc), all files should come inside the table regardless of its types,if the file type is image then the file column will show thumb icon of the same. otherwise some other icon should come.

    Vipin,
    We need more information...
    What version of JDeveloper/ADF?
    How do you tell what the file type is - do you store it in another column or something?
    What technologies are you using as the view layer (ADF Faces, Trinidad, Swing, etc)?
    What exactly does "all files should come inside the table" mean - I assume you want to use a table (in whatever view technology you are using) to display the file names (I guess) and further if the file type is an image type, you want to display a thumbnail? If you are using JSF/JSP as your view technology - you can easily write a servlet to stream the image files and use an image component (again in whatever view technology you are using) to display the images (search the forum for an example).
    But, in general, you need to spend a few minutes to phrase a proper question - much like the respondents on this forum will take a few minutes to provide a helpful answer (when enough information is given in the question).
    Best,
    john

  • DHCP_TIMEOUT in /etc/conf.d/netcfg has no effect

    I want to set DHCP_TIMEOUT to 30 for all netcfg profiles. On  this page in wiki it is suggested to set the variable in /etc/conf.d/netcfg. But this has no effect. I tried 'NETCFG_DEBUG="yes" netcfg <arguments>' and the timeout was still 10.
    How can I set DHCP_TIMEOUT for all profiles without editing every profile?

    opt1mus wrote:Could you paste into this thread your /etc/conf.d/netcfg and the debug output. It's easier for people to help with troubleshooting when actual output is to hand.
    Here it is (network names changed):
    # cat /etc/conf.d/netcfg
    # Enable these netcfg profiles at boot time.
    #   - prefix an entry with a '@' to background its startup
    #   - set to 'last' to restore the profiles running at the last shutdown
    #   - set to 'menu' to present a menu (requires the dialog package)
    # Network profiles are found in /etc/network.d
    NETWORKS=(network1 network2)
    # Specify the name of your wired interface for net-auto-wired
    WIRED_INTERFACE="eth0"
    # Specify the name of your wireless interface for net-auto-wireless
    WIRELESS_INTERFACE="wlan0"
    # Array of profiles that may be started by net-auto-wireless.
    # When not specified, all wireless profiles are considered.
    #AUTO_PROFILES=("profile1" "profile2")
    DHCP_TIMEOUT=30
    # NETCFG_DEBUG="yes" netcfg network1
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    :: network1 up                                                                                                                                                                          [ BUSY ] DEBUG: status reported to profile_up as:
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: wireless_up start_wpa wlan0 /run/network/wpa.wlan0/wpa.conf nl80211,wext
    Successfully initialized wpa_supplicant
    DEBUG: wireless_up Configuration generated at /run/network/wpa.wlan0/wpa.conf
    DEBUG: wireless_up wpa_reconfigure wlan0
    DEBUG: wpa_cli -i wlan0 -p /run/wpa_supplicant reconfigure
    DEBUG: wireless_up ifup
    DEBUG: wireless_up wpa_check
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: ethernet_up bring_interface up wlan0
    DEBUG: ethernet_up dhcpcd -qL -t 10 wlan0
    DEBUG:
    > DHCP IP lease attempt failed.
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: ethernet_down bring_interface flush wlan0
    DEBUG: wireless_down stop_wpa wlan0
    DEBUG: wpa_cli -i wlan0 -p /run/wpa_supplicant terminate
    DEBUG: profile_up connect failed

  • Player's position slider (Thread not owner)

    Hi every1,
    I've a thread that sets a slider value with the player's time in secods,but in case the slider Knob is dragged by the user the thread should wait and player's time should be set as per the value dragged by the user.
    But the wait() method is not executing instead it generates IllegalMonitorStateException: current thread not owner exception. Would you help me please?
    My code is:
    //the thread which sets the slider value as the time in second increases
    public void run() {
         while (true) {
                        if (player != null) {
               nano = player.getMediaTime().getSeconds();
              if (dura >nano) {
                  timex = (int)nano;
                        jSlider.setValue(timex);
                     try {
              Thread.currentThread().sleep(1000);
             } catch (InterruptedException ie) {
        }//the method which sets the slider as a user moves the knob of the slider
    jSlider.addChangeListener(new javax.swing.event.ChangeListener() {
                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                   try{
                      if(jSlider.getValueIsAdjusting()){
    player.setMediaTime(new javax.media.Time((double)  
    jSlider.getValue())); 
                    thr.wait();                  }
                   }catch(Exception e){e.printStackTrace();
                      System.out.println("Exception @ jSlider stateChanged : " + e.getMessage() );
            });Thanks!

    The exception is happening because the ChangeListener thread does not own the monitor on "thr" (see the api documentation for Object.wait). That can be fixed by putting it in a synchronized (this) { ... } block.
    However, I see bigger problems. First, recognize that Java is going to call your ChangeEvent code on the event handling thread, so you definitely don't want it to wait. The screen will stop repainting and the user's mouse release event won't be processed, because you will have suspended the thread that handles those things. Second, you should not modify the position of the slider from any thread other than the event handling thread, for reasons documented at [http://java.sun.com/developer/technicalArticles/Threads/swing/]. That article also shows techniques that are safe.
    I don't mean to be discouraging, just wanted to point out a couple more things so you didn't get strange behavior without knowing why! What you are attempting actually requires some multi-threading skill, so study up!
    Cheers,
    Eric

  • Objects running on threads

    Hi everyone,
    I have an engine that I have coded that provides a set of services to various applications. Currently the engine is single-threaded, meaning that if more than one person where to access the same instance of the engine there would be shared data violations. I'm sure that you know the drill...
    So, I am about the add a "UserSpace" class to the engine. Each person that logs into the engine will be assigned a user space, within which is stored information that is pertinent to them (and is isolated from all other users).
    I am familiar with using threads to perform lengthy operations (ie: making an object Runnable and calling the start() method to get things going). But I have never used threads in this way before.
    What I mean is that I want to be able to assign a thread to each user space. In other words every user will have their own unique thread just for them. Method calls on the user space do not need to be synchronized because the information within them is, by definition, not shared. If the user space has to make calls to other areas of the engine then those methods would have to be synchronized but I can deal with that.
    So how would I go about accomplishing this? Is it just a case of implementing Runnable as I normally do, calling start() and then make method calls?
    Thanks in advance for your help. :)
    Ben

    I believe you could accomplish what you wish w/3 classes. In accordance with your example and subsequent explanation, they are as follows:
    public class UserSpace {
    private Object mDataThatIsNotShared; // etc.
    public String methodOne() { /*some code */ }
    public void methodTwo(String s) { /*some code */ }
    public class Server {
    // This class would accept socket connections. For each socket
    // connection accepted, create an object of the third class called
    // ServerThread (see below):
    while (true) {
    // The line below blocks until connection:
    Socket socketAccepted=serverSocket.accept();
    ServerThread srvrThrd=new ServerThread(socketAccepted);
    srvrThrd.start();
    public class ServerThread extends Thread {
    private Socket mSocket;
    private UserSpace userSpace;
    ServerThread(Socket socket) {
    mSocket=socket;
    userSpace=new UserSpace(...); //See, each ServerThread owns its own
    public void run() {
    // Do whatever work you want w/UserSpace.
    Of course, this is way overly simplistic...Does not take into account the fact that you could have unlimited threads...i.e., your Server class needs to implement some sort of thread pool, etc.
    Does this help you?
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • SONY HDR XR150 - Camcorder is not recognized by iMOVIE

    Dear all: _I own the Sony HDR XR150 camcorder and cannot get my MAC to recognize that my camcorder is connected._ I have a Mac laptop Powerbook G4 and am running OS X version 10.4.11. I have iMOVIE 6.03 (267.2). When I am in iMOVIE the camcorder is n

  • Do You See Something Wrong With This?

    Im reading a text file through a command line along with a key word. I want to see how many times the key word appears in the text file. I used .readline() to read in one line of the text file at a time. I use StringTokenizer to separate into individ

  • OC4J_BI_Forms is not coming up in discoverer

    Hi All, Dicoverer OC4J_BI_Forms is not running. I stopped and started again also it is not coming I checked in ipm.log file. 11/08/30 18:00:02 [4] Request 2 Started. Command: start 11/08/30 18:00:02 [4] Starting Process: WebCache~WebCache~WebCache~1

  • BO XI InfoStore Service Issue - upgrading from CR 10 to BO XI

    Ours is a Java web application that works with BO 10. After we upgraded to BI XI, when I login to the CMS server (successfully) and try to get the InfoStore with this code IInfoStore iStore = (IInfoStore) es.getService("InfoStore"); I get the followi

  • MacKeeper (and other sites) keeps opening in new tabs

    HELP!! When browsing, new tabs open when I make selections in Safari. I've installed Sophus anti-virus and have scanned my laptop multiple times. Every time I scan with the anti-virus software, the software diagnoses that there where no issues detect