Lines disappearing from the frame when minimizing the window

I drew some lines on a frame but when I minimize the window , the lines disappear. I dont know why. Please help me. My code is as follows: (Sorry...I dont know how to tag the code to make it more readable)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
public class Pos extends Container {
public static void main(String args[]) {
Pos p = new Pos();
     p.getPosition();
JButton bn = new JButton("Draw Line");
int posx=0;
int posy=0;
int i=0;
int x[] = new int[4];
int y[] = new int[4];
public void getPosition() {
final JFrame frame = new JFrame("Mouse Position");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel();
label.setHorizontalAlignment(JLabel.CENTER);
          MouseListener mouseListener = new MouseListener(){
               public void mouseEntered(MouseEvent evnt){
               public void mouseExited(MouseEvent evnt){
               public void mousePressed(MouseEvent evnt){
               public void mouseReleased(MouseEvent evnt){
               public void mouseClicked(MouseEvent evnt) {
                    showMousePos(evnt);
               private void showMousePos(MouseEvent evnt) {
JLabel src = (JLabel)evnt.getComponent();
               posx = MouseInfo.getPointerInfo().getLocation().x;
               posy = MouseInfo.getPointerInfo().getLocation().y;
System.out.println("x-coordinate="+posx);
               System.out.println("y-coordinate="+posy);
               x=posx;
               y[i]=posy;
               i=i+1;
          ActionListener actionListener = new ActionListener(){
               public void actionPerformed(ActionEvent ae)
                    Object o = ae.getSource();
                    if (o==bn)
                         Graphics g= frame.getGraphics();
                         Graphics2D g2D = (Graphics2D)g;
                         g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
                         g2D.setColor(Color.red);
                         g2D.drawLine(x[0],y[0],x[1],y[1]);
                         i=0;
          label.addMouseListener(mouseListener);
          bn.addActionListener(actionListener);
frame.add(label, BorderLayout.CENTER);
          bn.setSize(10,10);
          frame.add(bn, BorderLayout.NORTH);
frame.setSize(300, 300);
frame.setVisible(true);

Graphics g= frame.getGraphics();
is your problem
which will appear like this
Graphics g= frame.getGraphics();if you highlight the code, then click the 'code' button, above the editor area
solution is to use a JPanel for your graphics, and override its paintComponent()
JPanel p = new JPanel(){
  public void paintComponent(Graphics g){
    super.paintComponent(g);
    //other graphics stuff here
};

Similar Messages

  • Firefox 8.0 occasionally disappears from task bar when minimized but keeps running

    Running Firefox 8.0 on Windows XP, have 12 tabs open. Occasionally, when I minimize Firefox, it disappears from the task bar. I know that Firefox is still running because one of the open tabs is a radio station stream on Silverlight. The only way to get Firefox back is to click a link in an email then Firefox will open in a new tab (it is my default browser)

    I am guessing it is because you minimise Firefox to the Windows Xp task bar but have ot either locked that or set it to be on top so it may disappear from view.
    When the task bar is visible left click any space area on the taskbar the popup will have options including
    * '''''lock task bar''''' if you tick that the task bar stays the same size
    * '''''properties''''' if you click on that you get other options for customising the task bar
    * also see http://en.wikipedia.org/wiki/Taskbar

  • Hello I have a problem with facebook Messenger disappeared from my desktop iPod in the AppStore it says "open" does not respond when I press it. What should I do to download it? But I do not have it in AppStore it says that I have it: (

    Hello I have a problem with facebook Messenger disappeared from my desktop iPod in the AppStore it says "open" does not respond when I press it. What should I do to download it? But I do not have it in AppStore it says that I have it: (

    - Go to Settings>General>Usage>Storage>and under apps select FBM and try to delete it.
    Next:
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings                            
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes
    - Restore to factory settings/new iOS device.                       

  • After changing batteries and up date my I Mac to 10.8.2, my BLUETOOTH disappear from my computer.  On the top line right corner the symbol says:  NOT AVAILLABLE, and the icon is not anymore int my computer's preference.  Anyone can help me here?

    After changing batteries and up date my I Mac to 10.8.2, my BLUETOOTH disappear from my computer.  On the top line right corner the symbol says:  NOT AVAILLABLE, and the icon is not anymore int my computer's preference.  Anyone can help me here?

    I've done it two or three time and I still have the same problem.  May be I do not do it properly so can you give me the right procedure.

  • I want the title on the browser to change when one of the frames changes in the Frameset.

    I am using frames (please don't tell me off!) and PHP.
    I want the title on the browser to change when one of the
    frames changes in the Frameset.
    Normally the title of the browser comes from the Frameset,
    But I am sure I have seen websites where the title changes
    depending on one of the frames... how is this done?
    C

    Then don't use frames.
    > Normally the title of the browser comes from the
    Frameset, But I am sure I
    > have seen websites where the title changes depending on
    one of the
    > frames...
    > how is this done?
    Show us one and we'll tell you.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "colinwalton" <[email protected]> wrote in
    message
    news:epuu1t$kgv$[email protected]..
    >I am using frames (please don't tell me off!) and PHP.
    >
    > I want the title on the browser to change when one of
    the frames changes
    > in
    > the Frameset.
    >
    > Normally the title of the browser comes from the
    Frameset, But I am sure I
    > have seen websites where the title changes depending on
    one of the
    > frames...
    > how is this done?
    >
    > C
    >

  • I have had a file disappear from creative cloud and then the name get reassigned to a different file.

    I have had a file disappear from creative cloud and then the name get reassigned to a different file.  How do I retrieve the missing file?

    If a file with the same name is saved again then a version is created. You can see versions from the Files page at https://creative.adobe.com/files. From the Files page click on the file to go to its page. Switch from the Details tab to the Activity tab if needed. You will see the Current Version and any past versions.

  • My 2014 version of InDesign disappeared from my dock. when I try to open it i get an error message

    my 2014 version of InDesign disappeared from my dock. when I try to open it i get an error message

    Hi [email protected],
    Please specify the error message that you are getting.
    Regards,
    Sheena

  • Would you like to change the frame rate of the project to 30 to match to m

    I just now moved some film clips from the Event Library to the Project Library and a white message window appeared saying: *MISMATCHED FRAME RATES. The frame rate of t his cli is 30 and the frame rate of the project is 25. Would you like to change the frame rate of the project to 30 to match the clip? And two radio buttons: Don't Change and Change.
    First of all, the other day I set my Sanyo VPC-HD2000A to shoot film at 1280 x 72 at 30 fps SHQ. Now I just checked and it is set at the topmost red zone960 x 540 at 30fps. The only thing I can think of to explain this is that I selected it but did not "set" it.
    Thus now I have a message asking what I noted above. Should I click CHANGE?
    WHY IS THE FRAME RATE OF THE PROJECT SET AT 25? How did I do that? What did I do that caused me to have a project that is set at 25 fps?????
    Time for another snack. 8-(
    -L
    A side issue is to find out why I set my Sanyo VPC-HD2000A at one rate (above) but now see that all the footage was shot at a different rate. Very very frustrating.

    AppleMan,
    It all began inside the settings of my Sanyo VPC-HD2000A when somehow the selection got switched from 1280 x 720 to that other setting with so-called 25fps. Also, I don't know whether the mishap occurred before or after I took my new footage.
    I edited the clips last night and now they are on my blog and channel and they seem ok but slightly fuzzy.
    I used a Sanyo VPC-HD2000A .7x wide angle lens with macro and I notice that when I zoomed in to the little sun conure, the picture blurred. I think that might be something that happens when one zooms the focus.
    Also, I was born and raised to a teenager in Hawaii, but now Southern California has me in its grip.
    -L

  • HT2443 loops are in the browser when you the loop message reads this file type is not supported

    loops are in the browser when you the loop message reads this file type is not supported

    gloucester
    In case you did not find it, the following is a copy/paste of the Announcement on Premiere Elements 19/NVIDIA GeForce
    that appears at the top of this forum.
    Premiere Elements 10 NVIDIA Video Card Driver Roll Back
    If you are a Premiere Elements 10 user whose Windows computer uses a NVIDIA GeForce video card and you are experiencing
    Premiere Elements 10 display and/or unexplained program behavior, then your first line of troubleshooting needs to be rolling
    back the video card driver version instead of assuring that it is up to date.
    Since October 2013 to the present, there have been a growing number of reports about display and unexplained workflow
    glitches specific to the Premiere Elements 10 user whose Windows computer has a NVIDIA GeForce video card. If this applies
    to you, then the “user to user” remedy is to roll back the NVIDIA GeForce video card driver as far as is necessary to get rid of
    the problems. The typical driver roll back has gone back as far as March – July 2013 in order to get a working Premiere
    Elements 10. Neither NVIDIA nor Adobe has taken any corrective action in this regard to date, and none is expected moving forward.
    Since October 2013, the following thread has tried to keep up with the Premiere Elements 10 NVIDIA reports
    http://forums.adobe.com/thread/1317675
    Older NVIDIA GeForce drivers can be found
    http://www.nvidia.com/Download/Find.aspx?lang=en-us
    A February 2014 overview of the situation as well as how to use the older NVIDIA GeForce drivers for the driver roll back can be found
    http://atr935.blogspot.com/2014/02/pe10-nvidia-video-card-roll-back.html
    ATR

  • I lose the connection when closing the CMD

    Hi guys,
    I have configured a standalone listener as following:
    C:\Program Files (x86)\Java\jre6\bin> java -Dapex.home=D:\list -Dapex.images=C:\images -jar D:\apex.war
    Afterward,
    If I close the CMD, I will lose the connection, and I have to reconfigure it again.
    If I open APEX locally , I mean by using the shortcut "Get Started With Oracle Database 11g Express Edition" , Then I will lose the connection that uses the default port of the listener, that is 8080.
    After I configured the listener I got this message on the CMD
    -- listing properties --
    PropertyCheckInterval=60
    ValidateConnection=true
    MinLimit=1
    MaxLimit=10
    InitialLimit=3
    AbandonedConnectionTimeout=900
    MaxStatementsLimit=10
    InactivityTimeout=1800
    MaxConnectionReuseCount=1000
    APEX Listener version : 1.1.2.131.15.23
    APEX Listener server info: Grizzly/1.9.18-o
    May 21, 2011 5:14:41 PM com.sun.grizzly.Controller logVersion
    INFO: Starting Grizzly Framework 1.9.18-o - Sat May 21 17:14:41 GST 2011
    INFO: http://localhost:8080/apex started.
    Using JDBC driver: Oracle JDBC driver version: 11.2.0.2.0
    Regards,

    Hi,
    I'm not sure I got your question right, but I'll try to find some solution anyway.
    If I close the CMD, I will lose the connection, and I have to reconfigure it again.That's what happens when a shell is terminated - all associated processes will stop as well. However, if you have a apex-config.xml in your apex.home you shouldn't need to configure your APEX Listener each time your start it, but it would reuse an existing configuration.
    If I open APEX locally , I mean by using the shortcut "Get Started With Oracle Database 11g Express Edition" , Then I will lose the connection that uses the default port of the listener, that is 8080.Now, if you have XE running on the same (local) machine as you have your APEX Listener running in standalone mode, you probably have a port conflict: By default, both APEX Listener in standalone mode and the Embedded PL/SQL Gateway (EPG) use port 8080. The EPG is activated as web server for APEX in XE after a fresh installation, the APEX Listener would be an alternative in that case. You can either stop the EPG, or reconfigure any of the two web servers to use a different port, if you want to run them parallel.
    To change the port used by the APEX Listener in standalone mode, you simply add another parameter to the startup: -Dapex.port=8888 and you're done.
    To change the port used by the EPG, connect as sys and run the following
    EXEC DBMS_XDB.SETHTTPPORT(8888);
    COMMIT;If you want to disable the EPG, simply set the port to *0* .
    After I configured the listener I got this message on the CMDThat's what it should look like.
    No, since your topic is "lose the connection when closing the CMD", I assume you search for an alternative. You could run the APEX Listener as a Windows service, even in standalone mode. To do this, you create a batch file, e.g.
    %JAVA_HOME%\java -Dapex.home=D:\oracle\APEX_Listener\_home -Dapex.images=D:\oracle\apex_4_0_2\images -Dapex.port=8888 -jar D:\oracle\APEX_Listener\apex_listener.1.1.2.131.15.23\apex.war >>D:\oracle\APEX_Listener\apex_listener.1.1.2.131.15.23\my_apex_listener.log 2>&1Note that you have to set JAVA_HOME as system property or replace the call with the absolute path to your JDK or make sure the JDK is in your PATH variable.
    Of course, you can and should change the other directories as well to fit to your system.
    Next, create a Windows service, e.g. using [url https://iain.cx/src/nssm/]NSSM (free) or [url http://support.microsoft.com/kb/137890]SRVANY (MS, non-free), that starts your batch as a windows service.
    The command for creating that service using NSSM could look as follows
    nssm install APEX_Listener D:\oracle\APEX_Listener\apex_listener.1.1.2.131.15.23\startup.cmdYou can edit the service properties afterwards, e.g. change the start mode from "Automatic" to "On Demand".
    I hope this answers your question. If not, please point me into the right direction.
    Thanks,
    Udo

  • I would appreciate your help on how to configure a gmail in a way  it  ask  for the password  everytime I connect?. In the only way I can configure it  I have to include the pw when configuring the account  and  after that  it do not ask for pw

    I would appreciate your help on how to configure a gmail in a way  it  ask  for the password  everytime I connect?. In the only way I can configure it  I have to include the pw when configuring the account  and  after that  it do not ask for pw  so  everyone that shares my iPad can  oppen my mail  with  no pw  required.
    Thank

    The iPad is designed to be a single user device, and there is currently no way to password protect the Mail app - even removing the account password from Settings > Mail, Contacts, Calendars will just prevent new mail being downloaded, it won't hide those that have already been downloaded. There is this work-around for the app : https://discussions.apple.com/message/13127632#13127632 . Also there might be third-party email apps that feature password protecting.

  • Phone hog links give me error message "an error occuredon the server when processing the URL

    When ever I click on the links sent from phone hog.com to earn free minutes I get the following error message. "An error occurred on the server when processing the URL. Please contact the system administrator" I have made several contacts with phone hog help and they claim it is my settings on my computer. However I contacted my internet provider TDS telecom and they indicated that this is a phone hog issue. I do not have any other problems with any other links I click on with this type of error message.

    Hello msFit,
    it's well known, that in all these cases you describe I'm not a friend of a detailed troubleshooting. To be able to be independent in all this things It is one of the reasons why I prefer an external FTP program. The difficulties with which you have to fight encourage me in this opinion, not least because we always search for experts, we don't charge a "jack of all trades".
    To manage several websites or to upload my files and sometimes for the opposite way, for a necessary download from my server or to use a "a site-wide synch", I'm using FileZilla. It simply looks easier for me to keep track of all operations precisely and generate or reflect easily the desired tree structure.
    Above all, FileZilla has a feature (translation from my German FileZilla) called "compare file list". Here it's possible to use file size or modification time as a criterion. There is also the possibility to "hide identical files", so that only these files which you want to redact remain visible.
    And even if it means you have to install a new program, I am convinced that there is an advantage. Here is the link to get it and where you can read informations about how it works:
    http://filezilla-project.org/ and http://wiki.filezilla-project.org/Tutorial#Using_the_site_manager
    Mac: Mac OS X (Use: Show additional download options)
    http://filezilla-project.org/download.php
    Of course, you also need all the access data to reach your server and for MIME issues, you should contact your web host/provider.
    Good luck!
    Hans-Günter
    P.S.
    Since I use two screens, the whole thing became even more comfortable.

  • How can I force mount a dvd that isn't even seen by Disk Utility? I can see it on the Mac when using my Windows 7 partition via Boot Camp, but not in Lion, which is how I would rather be running.

    How can I force mount a dvd that isn't even seen by Disk Utility? I can see it on the Mac when using my Windows 7 partition via Boot Camp, but not in Lion, which is how I would rather be running.

    Well if there is a EFI block, then running a program in OS X isn't going to do a lick of good.
    After all EFI was designed for Trusted Computing and Digital Rights Management, to act between the OS and hardware, can read drives, contact the Internet and everything.
    Windows doesn't use EFI, will have UEFI in Windows 8 though.

  • Error 1064 An exception occurred in the service when handling the control

    Hi all,
    I downloaded Oracle Business Intelligence 10.1.3.4.1 on windows XP successfully, once I try to start any service of Oracle BI [scheduler/server]. This error is shown *1064 An exception occurred in the service when handling the control request*.
    Could anyone help me out?
    Thanks in advance
    Maitha

    I checked the file
    [68008] Scheduler Error: [nQSError: 67042] The Scheduler Configuration is incorrect.
    [nQSError: 67004] Registry value for SchedulerScriptPath not set.
    How the issue can be resolved ?

  • Is there a way for the tracker to do key frames at the frame rate of the comp setting?

    I was doing some tracking in a 24fps project (yes my comp settings are correct) and I was really annoyed to see that the track looked to be generating key frames at 29.98fps. Of course this means crazy jittering.
    Is there a way I can change the rate that tracker generates key frames?
    Please help. I use CS3.
    Thank you in advance for your help.

    Mylenium said this:
    > Is the footage interpreted correctly? There has been some
    > discussion for CS4 about incorrect frame rate treatments in
    > pretty much all of Adobe's video-centric tools, but I'm not
    > aware of any particular issues with the tracker. Still, maybe
    > it is one of those bugs.
    redmike said this:
    > I was doing some tracking in a 24fps project (yes my comp settings
    > are correct) and I was really annoyed to see that the track looked > to be generating key frames at 29.98fps. Of course this means crazy
    > jittering.
    (I assume that you mean 29.97, not 29.98.)
    In all versions of After Effects, the motion-tracking keyframes are set at the frame rate of the footage item on which the layer is based, not at the composition's frame rate.
    Have you checked to see that your footage item is interpreted to be 24fps?
    Also, are you sure that this "jittering" that you're seeing is because of the rate of the motion-tracking keyframes?

Maybe you are looking for