ListSelectionListener is always called two times...

Hello,
Icreated a JTable and added a ListSelectionListener to this table. I want an action being performed each time the selection within the table changes. If I change the selection via mouse this works quite fine, but if I do so with the mouse the method in the Listener is alwas called two times...why ?
Here's a little bit of source-code, perhaps you'll get what I mean:
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
     if (lsm.isSelectionEmpty()) {}
     else { // always called 2 times...
          int selectedRow = lsm.getMinSelectionIndex();
     System.out.println("Test");
     Kunde temp = (Kunde)ShowKunde.kunden.elementAt(selectedRow);
     System.out.println(temp.getName());
          try {
               kontoTemp = new KontoTemp(temp);
               kontoTemp.setBuchungenTemp();
               tableTemp.setModel(kontoTemp);
               kontoBestand = new KontoBestand(temp);
               kontoBestand.setBuchungenBestand();
               tableBestand.setModel(kontoBestand);
               frame.repaint();
          } // try
          catch (Exception ex) {
               System.err.println(ex.getMessage());
          } // catch
          }});

Hi
you could check is the value is adjusting:
if (e.getValueIsAdjusting()) {
    return;
// your code hereviel erfolg
Phil

Similar Messages

  • Why windowClosing is called two times?

    Hi,
    I'm saving my project in JFrame windowClosing event. But it is called two times...
    How to prevent it?
    this.addWindowListener(new java.awt.event.WindowAdapter() {
         public void windowClosing(java.awt.event.WindowEvent e) {
         saveCurrentProject();
    Thanks,
    Andr�

    Thanks, problem solved.
    this.addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent e) {
    saveCurrentProject();
    System.exit(0); // <-- new line
    Andre

  • MouseClicked method was called two times

    Hi all!
    I 've written a program containing a GUI component, and I added a MouseAdapter for it and overided the mouseClicked() method.
    But as I run the program and click the mouse on that component, the mouseClicked() was called two time ( I just made an single click)
    Anyone can tell me why?
    Thanks!

    Is it true that if we add the same MouseListener
    twice, we will receive two times call to mouseXXXX()
    method?I assume there would be some kind of check like this:
    if (!listenerList.contains(candidateListener)) listenerList.add(candidateListener);to ensure that it isn't added twice, because there should never really be a situation where it would be legitimate or useful to have the same instance added as a listener more than once.

  • JTextField.focusLost is called multiple times. Why?

    I have a JTextField component called projectNum.
    On focusLost I'm trying to prevent user to leave an empty field.
    But I have a problem, because focusLost is called two times.
    Here is a code snippet:
    projectNum.addFocusListener(new FocusAdapter() {
                   public void focusGained(FocusEvent e) {}
                   public void focusLost(java.awt.event.FocusEvent e) {
                        if(!e.isTemporary()){ //only for permanent lost of focus          
                             if (validProjectNum()){
    newProject.setProjectNum(Integer.valueOf(projectNum.getText().trim()).intValue());
                           }else{
                                if(!projectNum.hasFocus()){
                                     projectNum.requestFocus();
              });Method "validProjectNum()" simply checks if JTextField is empty and
    if so, shows JOptionPane message and returns false.
    Problem is that I'm geting that message twice
    (four times if I exclude: if(!e.isTemporary()) ).
    I can't figure out who is calling focusLost the second time.
    How can I prevent it to be called only once.
    I appreciate any help or hint.
    Thanks.

    OK, but where to show a message to a user?if the textfield is empty, this line executes
    if(tf.getText().equals("")) return false;
    perhaps you could add your message as part of the
    'block' of this if statementWell, I've tried that allready (see my second post, method validProjectNum()
    does exactly that).
    Anyway, I solved the problem using focusLost and a little trick:jTextField.requestFocus();                
           jTextField.setFocusable(false);          
           JOptionPane.showMessageDialog(null, "error message");
           jTextField.setFocusable(true);  
           jTextField.requestFocus();        So as you can see, key thing is to temporary disable focus on component
    and than enable it back after JOptionPane.showMessageDialog().
    It looks like JOptionPane.showMessageDialog()
    triggers focusLost() event.
    Thanks everyone.

  • Data inserting two times in a table  when i click submit button

    Hi Experts,
    I had a problem, when i am inserting data in a table from a form at the first time when i click button it adds two times, afterwards it is adding one time only, the form and table are from same value node (table is collection cardinality : 1..n and selection cardinality is 0..n) i don't understand why it  is happening here?
    Regards,
    Pradeep Kumar

    Hi Pradeep,
    Please check the method for inserting data in a table. May be method is called two times.
    Post your code here to look into it.
    Best Regards,
    Arun Jaiswal

  • PrepareRender() called multiple times if I have HTML/Images on a JSF page

    I have extended ADFPhaseListener and also FacesPageLifecycle. I am overriding the prepareRender() method in the CustomFacesPageLifecycle.
    When I insert an image on to the page in the branding facet or add any html using verbatim tag, the prepareRender() method is called two times. I am not sure why?
    If I remove the images/html, the method is only executed once.
    If I have image/html in the page, another strange thing is that the first time all the custom lines of code gets executed in prepareRender() method. But the second time only first few lines of code in the prepareRender() method. This seems to me a very wierd behaviour.
    Any inputs from ADF product dev team?
    Thanks
    - Amit Kochar

    Hi,
    if you add the following print statement
    System.out.println("rendering "+FacesContext.getCurrentInstance().getViewRoot().getViewId());
    Then the output in my case is
    07/04/24 08:14:04 rendering /BrowsePage.jsp
    07/04/24 08:14:05 rendering /otn_logo_small.gif
    The image comes from the file system, which means it is rendered by the JSF lifecycle. If you reference the image with a URL then the lifecycle doesn't render the image but only refrences it.
    To avoid your prepare render code to be executed multiple times, just check for jsp and jspx file extensions, which will guarantee that your code only executes for JSF pages, not for loaded files.
    The reason why this happens is because the JSF filter is set to /faces , which means all files that are loaded through that path
    Frank

  • Directory being added two times in JTable rows.(JTable Incorrect add. Rows)

    hi,
    I have a problem, The scenario is that when I click any folder that is in my JTable's row, the table is update by removing all the rows and showing only the contents of my selected folder. If my selected folder contains sub-folders it is some how showing that sub-folder two time and if there are files too that are shown correctly. e.g. If I have a parent folder FG1 and inside that folder I have one more folder FG12 and two .java files then when I click on FG1 my table should show FG12 and two .java files in separate rows, right now it is showing me the contents of FG1 folder but some how FG12 is shown on two rows i.e. first row shows FG12 second row shows FG12 third row shows my .java file and fourth row shows my .java fil. FG12 should be shown only one time. The code is attached. The methods to look are upDateTabel(...) and clearTableData(....), after clearing all my rows then I proceed on adding my data to the Jtable and inserting rows. May be addRow(... method of DefaultTableModel is called two times if it is a directory I don't know why. Please see the code below what I am doing wrong and how to fix it. Any help is appreciated.
    Thanks
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.text.SimpleDateFormat;
    import java.util.*;
    public class SimpleTable extends JPanel {
         /** Formats the date */
         protected SimpleDateFormat           formatter;
    /** two-dimensional array to hold the information for each column */
    protected Object                     data[][];
    /** variable to hold the date and time in a raw form for the directory*/
    protected long                          dateDirectory;
    /** holds the readable form converted date for the directories*/
    protected String                     dirDate;
    /** holds the readable form converted date for the files*/
    protected String                     fileDate;
    /** variable to hold the date and time in a raw form for the file*/
    protected long                          dateFile;
    /** holds the length of the file in bytes */
    protected long                         totalLen;
    /** convert the length to the wrapper class */
    protected Long                         longe;
    /** Vector to hold the sub directories */
    protected Vector                     subDir;
    /** holds the name of the selected directory */
    protected String                    dirNameHold;
    /** converting vector to an Array and store the values in this */
    protected File                     directoryArray[];
    /** hashtable to store the key-value pair */
    protected static Hashtable hashTable = new Hashtable();
    /** refer to the TableModel that is the default*/
    protected DefaultTableModel      model;
    /** stores the path of the selected file */
    protected static String               fullPath;
    /** stores the currently selected file */
    protected static File selectedFilename;
    /** stores the extension of the selected file */
    protected static String           extension;
    /** holds the names of the columns */
    protected final String columnNames[] = {"Name", "Size", "Type", "Modified"};
         * Default constructor
         * @param File the list of files and directories to be shown in the JTable.
    public SimpleTable(File directoryArray[])
              this.setLayout(new BorderLayout());
              this.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
              (SimpleTable.hashTable).clear();
              data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
              formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
              //this shows the data in the JTable i.e. the primary directory stuff.
              for(int k = 0; k < directoryArray.length; k++)
                   if(directoryArray[k].isDirectory())
                        data[k][0] = directoryArray[k].getName();
                        data[k][2] = "File Folder";
                        dateDirectory = directoryArray[k].lastModified();
                        dirDate = formatter.format(new java.util.Date(dateDirectory));
                        data[k][3] = dirDate;
                        (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    
                   else if(directoryArray[k].isFile())
                        data[k][0] = directoryArray[k].getName();
                        totalLen = directoryArray[k].length();
                        longe = new Long(totalLen);
                        data[k][1] = longe + " Bytes";
                        dateFile = directoryArray[k].lastModified();
                        fileDate = formatter.format(new java.util.Date(dateFile));
                        data[k][3] = fileDate;
                        (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
    model = new DefaultTableModel();
    model.addTableModelListener( new TableModelListener(){
              public void tableChanged( javax.swing.event.TableModelEvent e )
              final JTable table = new JTable(model);
              table.getTableHeader().setReorderingAllowed(false);
              table.setRowSelectionAllowed(false);
              table.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
              table.setShowHorizontalLines(false);
              table.setShowVerticalLines(false);
              table.addMouseListener(new MouseAdapter()
    public void mouseReleased(MouseEvent e)
    //TBD:- needs to handle the doubleClick of the mouse.
    System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
    if(e.getClickCount() >= 2 &&
    (table.getSelectedColumn() == 0) &&
    ((table.getColumnName(0)).equals(columnNames[0])))
         System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
         upDateTable(table);
    upDateTable(table);
              /** set the columns */
              for(int c = 0; c < columnNames.length; c++)
                   model.addColumn(columnNames[c]);
              /** set the rows */
              for(int r = 0; r < data.length; r++)
                   model.addRow(data[r]);
              //this sets the tool-tip on the headers.
              DefaultTableCellRenderer D_headerRenderer = (DefaultTableCellRenderer ) table.getTableHeader().getDefaultRenderer();
              table.getColumnModel().getColumn(0).setHeaderRenderer(D_headerRenderer );
              ((DefaultTableCellRenderer)D_headerRenderer).setToolTipText("File and Folder in the Current Folder");
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    this.add(scrollPane, BorderLayout.CENTER);
    * Returns the number of columns
    * @return int number of columns
    public int getColumnTotal()
         return columnNames.length;
    * Returns the number of rows
    * @return int number of rows
    public int getRowTotal(Object directoryArray[])
         return directoryArray.length;
    * Update the table according to the selection made if a directory then searches and
    * shows the contents of the directory, if a file fills the appropriate fields.
    * @param JTable table we are working on
    * //TBD: handling of the files.
    private void upDateTable(JTable table)
    if((table.getSelectedColumn() == 0) && ((table.getColumnName(0)).equals(columnNames[0])))
         dirNameHold =(String) table.getValueAt(table.getSelectedRow(),table.getSelectedColumn());
                   File argument = findPath(dirNameHold);
                   if(argument.isFile())
                        CMRDialog.fileNameTextField.setText(argument.getName());
                        try
                             fullPath = argument.getCanonicalPath();                          
                             selectedFilename = argument.getCanonicalFile();                          
    CMRDialog.filtersComboBox.removeAllItems();
                             extension = fullPath.substring(fullPath.lastIndexOf('.'));
                             CMRDialog.filtersComboBox.addItem("( " + extension + " )" + " File");
                        catch(IOException e)
                             System.out.println("THE ERROR IS " + e);
                        return;
                   else if(argument.isDirectory())
                        String path = argument.getName();
                             //find the system dependent file separator
                             //String fileSeparator = System.getProperty("file.separator");
                        CMRDialog.driveComboBox.addItem(" " + path);
              subDir = Search.subDirs(argument);
              /**TBD:- needs a method to convert the vector to an array and return the array */
              directoryArray = new File[subDir.size()];
                   int indexCount = 0;
                   /** TBD:- This is inefficient way of converting a vector to an array */               
                   Iterator e = subDir.iterator();               
                   while( e.hasNext() )
                        directoryArray[indexCount] = (File)e.next();
                        indexCount++;
              /** now calls this method and clears the previous data */
              clearTableData(table);     
                   (SimpleTable.hashTable).clear();
                   data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
                   formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
                   data = null;
                   data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
                   for(int k = 0; k < directoryArray.length; k++)
                        if(directoryArray[k].isDirectory())
                             data[k][0] = directoryArray[k].getName();
                             data[k][2] = "File Folder";
                             dateDirectory = directoryArray[k].lastModified();
                             dirDate = formatter.format(new java.util.Date(dateDirectory));
                             data[k][3] = dirDate;
                             (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
                             model.addRow(data[k]);
                             model.fireTableDataChanged();
                        else if(directoryArray[k].isFile())
                             data[k][0] = directoryArray[k].getName();
                             totalLen = directoryArray[k].length();
                             longe = new Long(totalLen);
                             data[k][1] = longe + " Bytes";
                             dateFile = directoryArray[k].lastModified();
                             fileDate = formatter.format(new java.util.Date(dateFile));
                             data[k][3] = fileDate;
                             (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    }
                             model.addRow(data[k]);
                             model.fireTableDataChanged();
              table.revalidate();
              table.validate();               
    * Searches the Hashtable and returns the path of the folder or the value.
    * @param String name of the directory or file.
    * @return File     full-path of the selected file or directory.
    public File findPath(String value)
         return (File)((SimpleTable.hashTable).get(value));
    * This clears the previous data in the JTable and removes the rows.
    * @param     JTable table we are updating.
    public void clearTableData(JTable table)
         for(int row = table.getRowCount() - 1; row >= 0; --row)
                   model.removeRow(row);
              model.fireTableStructureChanged();

    java gurus any idea how ti fix this problem.
    thanks

  • Why servlet be called many times?

              I call servlet in jsp by the following way,
              /ReportServlet?reportCode='1234'.
              Servlet execute normally at first,but I find it had been called again before first
              servlet finished.
              I want to know why it be called two times.
              

              Yes,I used two frames in a signle page like this,
              <%@page contentType="text/html;charset=gb2312 "%>
              <%@page errorPage="/fxclear/common/fx_error.jsp"%>
              <%@page session="true" import="cfets_fx2001.clearing.common.record.FxsReport"%>
              <html>
              <head>
              <%
              String reportCode = null;     //&#35201;&#29983;&#25104;&#25253;&#34920;&#30340;report
              code
              try{
                   reportCode = request.getParameter("reportcode").trim();
              }catch(NullPointerException e){
                   throw new Exception("&#21457;&#32473;jsp&#26597;&#35810;&#21442;&#25968;&#38169;&#35823;");
              FxsReport report;          //&#35201;&#29983;&#25104;&#25253;&#34920;&#30340;&#25253;&#34920;&#20449;&#24687;
              String title;               //&#25253;&#34920;&#26631;&#39064;
              String dateFlag = cfets_fx2001.clearing.common.OurReport.getT0ORT1(reportCode);
              try{
                   report = new FxsReport(reportCode);
                   title = report.reportName.trim();
              }catch(Exception e){
                   title = "&#25253;&#34920;&#25171;&#21360;";
              %>
              <title>&#22806;&#27719;&#36164;&#37329;&#28165;&#31639;&#31995;&#32479;&#65293;&#65293;&#24080;&#21153;&#23376;&#31995;&#32479;&#65293;&#65293;<%=title%></title>
              <script LANGUAGE="JavaScript">
              //&#21457;&#29983;&#38169;&#35823;&#26102;&#25191;&#34892;
              function sendErrMessage(msg)
                   middle.location.href="/fxclear/common/fx_clear_error.jsp?Message="+msg;
              //&#22312;&#35201;&#29983;&#25104;pdf&#25991;&#20214;&#21069;&#25191;&#34892;
              //&#37325;&#26032;&#22312;middle frame&#35843;&#29992;servlet,&#20197;&#33719;&#21462;&#21018;&#29983;&#25104;&#30340;pdf&#25991;&#20214;
              function beginGenFile()
                   middle.document.write("&#27491;&#22312;&#29983;&#25104;&#24744;&#35201;&#30340;&#25991;&#20214;&#65292;&#36825;&#38656;&#35201;&#19968;&#20123;&#26102;&#38388;&#65292;&#35831;&#31245;&#20399;...");
                   top.document.close();
              //&#24403;pdf&#25991;&#20214;&#29983;&#25104;&#25104;&#21151;&#21518;&#25191;&#34892;
              //&#37325;&#26032;&#22312;middle frame&#35843;&#29992;servlet,&#20197;&#33719;&#21462;&#21018;&#29983;&#25104;&#30340;pdf&#25991;&#20214;
              function endGenFile()
                   middle.location.href="/ReportServlet?reportCode=<%=reportCode%>&dateFlag=<%=dateFlag%>&notrefresh=Y";
              </script>
              </head>
              <!-- <script LANGUAGE="JavaScript">
              self.moveTo(50,50);
              </script>
              -->
              <frameset framespacing="0" border="0" rows="50,101%" frameborder="0">
              <frame name="top" scrolling="no" noresize src="commonprinttitle.jsp?reportcode=<%=reportCode%>&dateFlag=<%=dateFlag%>"
              >
              <frame name="middle" src="/ReportServlet?reportCode=<%=reportCode%>&dateFlag=<%=dateFlag%>"
              scrolling="auto" >
              <noframes>
              <body background="image/fx_cfets.gif" bgproperties="fixed">
              <p>&#27492;&#32593;&#39029;&#20351;&#29992;&#20102;&#26694;&#26550;&#65292;&#20294;&#24744;&#30340;&#27983;&#35272;&#22120;&#19981;&#25903;&#25345;&#26694;&#26550;&#12290;</p>
              </body>
              </noframes>
              </frameset>
              </html>
              And I want to use frames,how to sovle it?
              

  • Have a nice day. I can't open the books linked to the Adobe ID. Always the overallocation says. But some of the books I downloaded two times. Still, it gives a warning in the form of more installations.

    Have a nice day. I can't open the books linked to the Adobe ID. Always the overallocation says. But some of the books I downloaded two times. Still, it gives a warning in the form of more installations.

    I think you should ask in the Digital Editions forum, Adobe Digital Editions

  • How to call two data blocks at a time.

    hi all
    i want to call two data blocks at a time on function when button pressed.
    how can I it?
    many thanks

    Many thanks that you people reply,
    I am working in oracle form developer 6i and database 10g.
    I have a form that have three data blocks,
    first block have text boxes and search button,and next two blocks display records on the basis of search criteria that is inserted in the first block and when is clicked on save button.
    the data that is to b displayed is from two different tables.
    i used Go_block('my_block')
    and call other block with the same method.
    kindly guide me how can i do it.
    Thanks in advance

  • Can I call two numbers at the same time on facebook?

    Can I call two numbers at the same time on facebook?

    thanks for your answer. Yes indeed HTML widgets run only full screen (snif snif). I consider this as a "distinguishing treatment".
    One solution  i read !!!!! was to create through keynote a countdown clock, to export to quicktime move and to imported at iBA predefined widgets. of course this is not the solution i need.
    So, in order to have at the same widget and run together a count down clock and a preview test (20 questions)  i must
    1)"hack" the preview widget and insert a countdown clock
    2) create a preview test using iAD.....
    thanks again
    haris

  • I am receiving updates everyday for creative cloud, always the same updates (sometimes even two time

    i am receiving updates everyday for creative cloud, always the same updates (sometimes even two times a day . Is there a way to stop that?

    Checked out that link and everything seems to be in order on this machine at this time.
    I only have CC installed on this one machine, not even my secondary machine like is permitted. it seems odd that I'm asked to re-accept the Licence Agreement as often as I am. If I had to guess, it's almost every week, if not multiple times some weeks, that all the software will decide I should have to view the licence agreement.
    Edit: I've never had any noticeable "errors" activating or anything like that. I just get asked to do it quite frequently.
    This activation screen isn't too annoying (it involves clicking one single button), but like I stated earlier, if I'm trying to launch the software by double-clicking on a PSD, AI, PPROJ, AEP, etc... that file will fail to open.
    I feel like that's probably not really a bug, but it is frustrating, since I did launch the application with the intent to edit that specific file I tried to open.
    Again, something that you guys may consider working on.
    Another annoyance is that: agreeing to the licence agreement is a per-application task, so if I see that Licence Agreement dialogue window by opening Photoshop (for example), I know that every other piece of software I have in the suite (Illustrator, Premiere, After Effects, Audition) will be showing me that screen on it's next launch. Probably deliberate for legal purposes that I can't just agree once for the whole suite, but heck, it would save me a lot of minor headaches if it was a unified agreement.

  • Calling images on website two times

    Hi,
    When I am calling the images of the contents in the website which is developped by PHP, there is no problem to display them. But i check the Access Logs of site, Only Firefox GETs the page TWO times. Other browsers GET the page for one time, but Firefox GETs two times.
    Image URL like this : http://www.mysite.com/image/name-of-the-image.jpg (With htaccess rewrite, to an image.php PHP file)
    in image.php file , Image Magick (Php Image Library) prints the image..
    Internet explorer, chrome, opera vs. is normal. Firefox gets two times on Access Log...
    What is the solution of this problem, i couldn't find a solution...

    Thanks David,
    Yes it was a problem for development. I made the headers but still not worked. Then i tried different header, now problem solved... may be needed in the future, the correct header codes like this:
    // Last Modified date for caching
    $file_last_modified = filemtime($filename);
    // Expires in two months
    $expires = time() + (60 * 24 * 60 * 60);
    header("Pragma: public");
    header("Content-type: image/jpeg");
    header("Expires: " . gmdate("D, d M Y H:i:s", $expires) . " GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s", $file_last_modified) . " GMT");
    Thanks

  • Why Update query is executing twice in this case even if called one time?

    Example 1=>
    I have unix ksh file and I am calling sql file from it.
    (table 1 contains 2 rows -
    ID      Name
    1 test't
    2 Pet's
    below sql statement is part of sql file:
    update table1 set name = replace(name,'''','''''') where instr(name,'''') > 0 ;
    2 rows updated.
    2 rows updated.
    --after this update I see name is updated to test''''t and pet''''s
    (Problem here is I see 2 rows updated two times.even if there is one row its getting updated two times)
    Example 2)
    SO I have created other ksh and sql and in that sql I have written same update and its working fine.
    update table1 set name = replace(name,'''','''''') where instr(name,'''') > 0 ;
    2 rows updated.
    --after this update I see name is updated to test''t and pet''s
    Why there are 2 updates in first example?

    Please always provide the required information (as said in the forum's stickies): at least sqldev, OS, JDK and DB versions.
    Regards,
    K.

  • Why my JInternalFrame show two times?

    /* I want to Draw a cycle on JPanel in JInternalFrame, but it Draw two times, and when I klick the JInternalFrame, it will show right.
    There are two Class, one ist TestDrawingJPanel, another ist DrawingJPanel.
    import java.awt.*;
    public class TestDrawingJPanel extends javax.swing.JFrame {
    /** Creates new form TestDrawingJPanel */
    public TestDrawingJPanel() {
    initComponents();
    DrawingJPanel drawingJPanel=new DrawingJPanel();
    jInternalFrame1.getContentPane().add(drawingJPanel,java.awt.BorderLayout.CENTER);
    drawingJPanel.start();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jInternalFrame1 = new javax.swing.JInternalFrame();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    jInternalFrame1.setBackground(java.awt.Color.white);
    jInternalFrame1.setPreferredSize(new java.awt.Dimension(300, 260));
    try {
    jInternalFrame1.setSelected(true);
    } catch (java.beans.PropertyVetoException e1) {
    e1.printStackTrace();
    jInternalFrame1.setVisible(true);
    getContentPane().add(jInternalFrame1, java.awt.BorderLayout.CENTER);
    pack();
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
    System.exit(0);
    * @param args the command line arguments
    public static void main(String args[]) {
    new TestDrawingJPanel().show();
    // Variables declaration - do not modify
    private javax.swing.JInternalFrame jInternalFrame1;
    // End of variables declaration
    import java.awt.*;
    public class DrawingJPanel extends javax.swing.JPanel implements Runnable {
    /** Creates a new instance of DrawingJPanel */
    Graphics g;
    Thread thisThread;
    public void start(){
    thisThread=new Thread(this);
    thisThread.start();
    public void paint(Graphics g){
    g.setColor(Color.black);
    g.drawArc((this.getWidth()/2)-100,(this.getHeight()/2)-100,200,200,0,360);
    public void run() {
    try{
    thisThread.sleep(100);
    }catch(Exception e){};
    repaint();

    Q1
    2 internalframes
    ANS
    remove any one of these
    jInternalFrame1.setVisible(true);
    new TestDrawingJPanel().show();

Maybe you are looking for

  • Trying to find the app preference for Final Cut Pro 7

    Upgraded from Snow Leopard to Mavericks running Final Cut ver7.03 Black Magic Design Intensity Pro card in PCIe 26 gigs RAM Normally if I had an issue in Snow Leopard, I could TRASH the FCPplist and re instate my preferences from the start. Im having

  • Font in preview document was change

    Hi All, Do anyone have this kind of scenario before where using certain printer (Epson LQ2190) as default printer, the font setting is different from the PLD? Thank KC

  • Autosys user unable to trigger the Process Chain.

    Hi all, we need to run a process chain daily, So we are inserted the PC triggering Job in Autosys, some time autosys unable to trigger the job.. Can any one please help me in this issue.... Waiting for responce... Thanks in advance,

  • Unknown indicator = severe battery drain?

    I have a 6220 Classic and recently a new indicator has appeared in the top right corner of the homescreen (alongside battery strength indicator). At the same time I'm noticing that my battery is not holding any charge, as in I have to charge it daily

  • Getting message as attachment!!

    Hi all,, I have an ABAP program where i could send mails to the recipients. But the recipients are able to receive the content of the mails only in attached pdf format. But could not get as a body content in the email. I had passed packing_list-Docum