Problem to close Frame(not JFrame)

I ese the following method:
class MyWindowAdaptr extends WindowAdapter{
     SampleFr1 sampleFr1;
     public MyWindowAdaptr(SampleFr1 sampleFr1){
     this.sampleFr1=sampleFr1;
     public void WindowClosing(WindowEvent we){
          System.exit(0);
          //dispose();
          sampleFr1.setVisible(false);
}But my frame window is not closing.....plz HELP!!!!!

Try this:
class MyWindowAdaptr{
     SampleFr1 sampleFr1;
     public MyWindowAdaptr(SampleFr1 sampleFr1){
     this.sampleFr1=sampleFr1;
sampleFr1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sampleFr1.setVisible(true);
}

Similar Messages

  • Problem to close a Frame(not) JFrame...

    public void windowClosing(WindowEvent e) {
    System.exit(0);
    I use this method but my frame window is not closing...Plz help

    if u extends JFrame then add this code
      addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e) {
                    if(JOptionPane.showConfirmDialog(null,"Are you sure to  exitt!","Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE)==0){
                        dispose();
                        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        System.exit(0);
                    }else{
                        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            });

  • Problem with .gif frames not disappearing

    Hi-
    I'm pretty new to photoshop. Lately I've been messing around with editing and gifs and have been sporadic success achieving what I set out to do. I'm looking for help with a fairly specific problem that seems to pop up again and again. The problem is that when I attempt to make gifs. with a transparent background, the gif frames do not disappear properly once the file is moved out of photoshop.
    For example: I came across the following .gif yesterday and decided that I want to try to edit for a surreal effect.
    http://imgur.com/NJlpA.gif (I hope that link works)
    I wanted to cut out the beginning of the animation where the man is on the motorcycle and make it so that the man just rolls back and forth on the ground (weird I know).
    I successfully deleted the frames that I no longer wanted and duplicated the frames of animation that I wanted to play again so that the image would loop seamlessly. I then went through frame by frame, and corresponding layer by layer, to remove the white background. I used the quickwand tool. It took a long time but the gif was playing in photoshop as I wanted i to, a man writhing back and forth on the ground for no apparent reason. Siiiiiiick.
    So I did the whole save for web and devices thing, saved it as a .gif and then I put it on the interwebs and it turned out I had created this monstrosity:
    http://imgur.com/60CHc.gif
    Please, please, please, someone tell what I'm doing wrong. I feel like I've done the exact same proceedure to other gifs and have had them turn out perfectly. What am I missing???  Please note that the problem isn't that I accidentally made layers active for frames I didn't want them active for. I checked.
    Okay, thanks in advance to anyone who might be able to offer some advice.
    Sean

    Hello, and thanks for the timely response-
    Unfortunately, I only had a save of the "finished" version of the gif which now includes the unwanted frames. However, I went back and followed the same process, made a shorter version of the gif (which suffers from the same problem), and took a screenshot of that.
    http://imgur.com/8e8g1.png
    Also included is the preview screen which shows some of the settings that were in use (could be helpful?).
    http://imgur.com/8e8g1&bOThel
    And, finally, the shorter, still defective, gif.
    http://imgur.com/Ggnw7
    Thanks,
    Sean

  • Has anyone else encountered a problem with poster frames not recognising a video's pixel aspect ratio

    I'm discovering a strange effect with some of the .mp4 videos I've upload into iBooks Author. They're Pal SD 4:3 .movs with a 16:9 pixel aspect ratio and they play out fine on the iPad. However the iBooks software seems to be ignoring the pixel aspect ratio of the poster frame. This leads to the situation.
    1) When I drag my video into iBooks author all looks good - the video is 16:9 and if I choose to set a poster frame (or leave it at default) it looks 16:9 in the iBooks Author.
    2) I preview my book and it opens in iBooks on the iPad. But now the poster frame aspect ratio is 4:3
    3) I click on the video to start playing and it immediately jumps to 16:9 aspect ratio and plays out fine.
    4) If it scroll down a couple of pages and then scroll back the video poster frame has now reset itself to 4:3
    This sounds like a bug to me. Anyone else had it? Do you know if it's possible to report bugs without having a Developer licence?
    Thanks for any help
    Rob

    While there is no formal bug reporting method similar to what devs have w/apps, iBA does have a 'Provide iBooks Author Feedback' menu item.

  • Text frames not supported and images can't be imported when trying to open word document, can this be fixed?

    trying to open a word document in pages, no images, diagram r tables are seen, states problems are text frames not supported and that images can not be imported. the document opens fine in mircosoft office. can this be fixed or do i need to buy microsoft office for the imac, thanks andrea

    Pages isn't a perfect converter of Word documents. They are differently coded. Some documents opens well but some don't.
    You could try opening the document in LibreOffice, a free clone of MS Office.

  • When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    mostafa182 wrote:
    ... how I can solve this problem?
    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414
    If you try all these steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

  • I have a problem that I can not load or even close the download in iTunes, it turns out I have hanging in the mode, and because of that I can't download from AppStore, because it turns out that the other programs I have on standby. What do I do? Thank you

    I have a problem that I can not load or even close the download in iTunes, it turns out I have hanging in the mode, and because of that I can't download from AppStore, because it turns out that the other programs I have on standby. What do I do? Thank you.

    If there are multiple apps trying to download at once, only one can download at a time and the rest say "Waiting" until it is then their turn. Try this. Double tap the icon of the Waiting app, and it should resume the download.
    If that doesn't work:
    •  Log out of your iTunes store account.  Go to Settings > Store > Sign Out Then press the Home button.
    • Then press and hold the Home and Sleep buttons simultaneously and don't release them when it brings up the Turn Off screen; keep holding them until the Apple logo appears.
    • After restart, the Waiting should be gone.
     Cheers, Tom

  • Disabling the Close Button of JFrame or Frame

    Dear Friends,
    can anybody please help out to solve the problem i am having in disabling the close button of Jframe . Or try for hiding the close button from the screen
    thanks kalyan

    to disable the close button
    myFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)

  • Problem with submit button of jframe

    hi all
    i am having problems with the submit button. once the submit button is clicked the values should be updated to an array of objects. it is doing this. the problem is i want the current frame to close once i click submit button. i have a GUI at the background and once i click something this frame appears asking for details for th user to input. but i want only the current form to close, not the whole progrmy code is shown below
    thanks in advance
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class TextForm extends JPanel {
    public JTextField[] fields;
    public MainInteractiveMap mainClass;
    public TextForm(MainInteractiveMap m)
    mainClass= m;
    public TextForm(String[] labels, char[] mnemonics, int[] widths, String[] tips)
    super(new BorderLayout());
    JPanel labelPanel= new JPanel(new GridLayout(labels.length,1));
    JPanel fieldPanel= new JPanel(new GridLayout(labels.length,1));
    add(labelPanel, BorderLayout.WEST);
    add(fieldPanel, BorderLayout.CENTER);
    fields= new JTextField[labels.length];
    for(int i=0; i< labels.length;i+=1)
    fields[i] = new JTextField();
    if (i<tips.length)fields.setToolTipText(tips[i]);
    if (i<widths.length)fields[i].setColumns(widths[i]);
    JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
    lab.setLabelFor(fields[i]);
    if (i<mnemonics.length)lab.setDisplayedMnemonic(mnemonics[i]);
    labelPanel.add(lab);
    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p.add(fields[i]);
    fieldPanel.add(p);
    public String getText(int i){
    return (fields[i].getText());
    public void printForm()
    String[] labels = {"Location","No of Bedrooms","No of Bathrooms", "Garage","last selling price","current selling price"};
    char[] mnemonics ={'L','B','b','G','L','C'};
    int[] widths = {15,1,1,4,9,9};
    String[] desc = {"Location","No of Bedrooms","No of Bathrooms", "Garage","last selling price","current selling price"};
    final TextForm form = new TextForm(labels,mnemonics,widths,desc);
    JButton submit = new JButton("Submit");
    submit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e){
    String location;
    final int sellingPrice;
    final int numOfRooms;
    final int marketPrice;
    final int numOfBathrooms;
    final int numOfGarages;
    location=form.getText(0);
    sellingPrice=Integer.parseInt(form.getText(1));
    numOfRooms=Integer.parseInt(form.getText(2));
    marketPrice=Integer.parseInt(form.getText(3));
    numOfBathrooms=Integer.parseInt(form.getText(4));
    numOfGarages=Integer.parseInt(form.getText(5));
    mainClass.Testing(location);
    System.out.println(numOfGarages);
    System.exit(0);
    JFrame f = new JFrame("Input details of House");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(form, BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.add(submit);
    f.getContentPane().add(p, BorderLayout.SOUTH);
    f.pack();
    f.setVisible(true);
    regards

    you just need to change (at end of actionPerformed())
    System.exit(0);
    to
    [whateverFrame].dispose();
    easier to show a simple demo
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      public void buildGUI()
        JButton btn1 = new JButton("Open new Frame");
        final JFrame f1 = new JFrame("#1");
        f1.getContentPane().add(btn1);
        f1.pack();
        f1.setLocationRelativeTo(null);
        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f1.setVisible(true);
        btn1.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            JButton btn2 = new JButton("Close/Return");
            final JFrame f2 = new JFrame("#2");
            f2.getContentPane().add(btn2);
            f2.pack();
            f2.setLocationRelativeTo(null);
            f2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//do not want to close with 'X'
            f1.setVisible(false);
            f2.setVisible(true);
            btn2.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent ae){
                f2.dispose();
                f1.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • Problem with jDialog in a JFrame

    Hello to everyone...i'm newby java GUI developer, and i've got a problem with a JDialog within a JFrame...
    I made a JFrame which creates a new customized JDialog in his contructor, like this:
    MioJdialog dlg = new MioJdialog(this, true);
    dlg.setVisible(true);
    ...The "MioJdialog" class store his JFrame parent under a private attribute, in this way:
    class MioJdialog {...
    private Frame parent;
    public MioJdialog (Frame parent, boolean modal){
        this.parent=parent;
    ....}and here's the problem: when i try to close the parent JFrame with a command like this:
    parent.dispose();
    ( in order to close the whole window), sometimes happens that the JFrame is still visible on the screen...and i don't know why...
    got some hints?
    thanks to everyone!
    Edited by: akyra on Jan 14, 2008 4:36 AM
    Edited by: akyra on Jan 14, 2008 4:37 AM
    Edited by: akyra on Jan 14, 2008 4:37 AM

    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html
    Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Problem with file descriptors not released by JMF

    Hi,
    I have a problem with file descriptors not released by JMF. My application opens a video file, creates a DataSource and a DataProcessor and the video frames generated are transmitted using the RTP protocol. Once video transmission ends up, if we stop and close the DataProcessor associated to the DataSource, the file descriptor identifying the video file is not released (checkable through /proc/pid/fd). If we repeat this processing once and again, the process reaches the maximum number of file descriptors allowed by the operating system.
    The same problem has been reproduced with JMF-2.1.1e-Linux in several environments:
    - Red Hat 7.3, Fedora Core 4
    - jdk1.5.0_04, j2re1.4.2, j2sdk1.4.2, Blackdown Java
    This is part of the source code:
    // video.avi with tracks audio(PCMU) and video(H263)
    String url="video.avi";
    if ((ml = new MediaLocator(url)) == null) {
    Logger.log(ambito,refTrazas+"Cannot build media locator from: " + url);
    try {
    // Create a DataSource given the media locator.
    Logger.log(ambito,refTrazas+"Creating JMF data source");
    try
    ds = Manager.createDataSource(ml);
    catch (Exception e) {
    Logger.log(ambito,refTrazas+"Cannot create DataSource from: " + ml);
    return 1;
    p = Manager.createProcessor(ds);
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Failed to create a processor from the given url: " + e);
    return 1;
    } // end try-catch
    p.addControllerListener(this);
    Logger.log(ambito,refTrazas+"Configure Processor.");
    // Put the Processor into configured state.
    p.configure();
    if (!waitForState(p.Configured))
    Logger.log(ambito,refTrazas+"Failed to configure the processor.");
    p.close();
    p=null;
    return 1;
    Logger.log(ambito,refTrazas+"Configured Processor OK.");
    // So I can use it as a player.
    p.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.RAW_RTP));
    // videoTrack: track control for the video track
    DrawFrame draw= new DrawFrame(this);
    // Instantiate and set the frame access codec to the data flow path.
    try {
    Codec codec[] = {
    draw,
    new com.sun.media.codec.video.colorspace.JavaRGBToYUV(),
    new com.ibm.media.codec.video.h263.NativeEncoder()};
    videoTrack.setCodecChain(codec);
    } catch (UnsupportedPlugInException e) {
    Logger.log(ambito,refTrazas+"The processor does not support effects.");
    } // end try-catch CodecChain creation
    p.realize();
    if (!waitForState(p.Realized))
    Logger.log(ambito,refTrazas+"Failed to realize the processor.");
    return 1;
    Logger.log(ambito,refTrazas+"realized processor OK.");
    /* After realize processor: THESE LINES OF SOURCE CODE DOES NOT RELEASE ITS FILE DESCRIPTOR !!!!!
    p.stop();
    p.deallocate();
    p.close();
    return 0;
    // It continues up to the end of the transmission, properly drawing each video frame and transmit them
    Logger.log(ambito,refTrazas+" Create Transmit.");
    try {
    int result = createTransmitter();
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Error Create Transmitter.");
    return 1;
    } // end try-catch transmitter
    Logger.log(ambito,refTrazas+"Start Procesor.");
    // Start the processor.
    p.start();
    return 0;
    } // end of main code
    * stop when event "EndOfMediaEvent"
    public int stop () {
    try {   
    /* THIS PIECE OF CODE AND VARIATIONS HAVE BEEN TESTED
    AND THE FILE DESCRIPTOR IS NEVER RELEASED */
    p.stop();
    p.deallocate();
    p.close();
    p= null;
    for (int i = 0; i < rtpMgrs.length; i++)
    if (rtpMgrs==null) continue;
    Logger.log(ambito, refTrazas + "removeTargets;");
    rtpMgrs[i].removeTargets( "Session ended.");
    rtpMgrs[i].dispose();
    rtpMgrs[i]=null;
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Error Stoping:"+e);
    return 1;
    return 0;
    } // end of stop()
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
    Logger.log(ambito,refTrazas+"\nControllerEvent."+evt.toString());
    if (evt instanceof ConfigureCompleteEvent ||
    evt instanceof RealizeCompleteEvent ||
    evt instanceof PrefetchCompleteEvent) {
    synchronized (waitSync) {
    stateTransitionOK = true;
    waitSync.notifyAll();
    } else if (evt instanceof ResourceUnavailableEvent) {
    synchronized (waitSync) {
    stateTransitionOK = false;
    waitSync.notifyAll();
    } else if (evt instanceof EndOfMediaEvent) {
    Logger.log(ambito,refTrazas+"\nEvento EndOfMediaEvent.");
    this.stop();
    else if (evt instanceof ControllerClosedEvent)
    Logger.log(ambito,refTrazas+"\nEvent ControllerClosedEvent");
    close = true;
    waitSync.notifyAll();
    else if (evt instanceof StopByRequestEvent)
    Logger.log(ambito,refTrazas+"\nEvent StopByRequestEvent");
    stop =true;
    waitSync.notifyAll();
    Many thanks.

    Its a bug on H263, if you test it without h263 track or with other video codec, the release will be ok.
    You can try to use a not-Sun h263 codec like the one from fobs or jffmpeg projects.

  • Disabling default close button in JFrame

    hi,
    in JFrame there are by default 'minimize', 'maximize' and 'close' button. is it possible to disable or not to show the 'close' button'
    regards,
    tom

    If you want to control the closing of the frame you can use
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)If you are interested in listening whether this button was clicked (for example as an alternative to a "Close" button you can register a WindowListener and handle the windowClosing(...) event
    About disabling/hiding - maybe you will have to subclass the frame header UI class, which is L&F specific.
    HTH
    Mike

  • Problem with  getLayout() on a JFrame

    Hello,
    Thank you for reading my post and trying to help me.
    Something is a bit unclear to me. I create a JFrame object and give it a GridLayout as in the following:
            JFrame frame = new JFrame();
            frame.setLayout(new GridLayout(3, 2, 15, 15));I pass this JFrame object to another class constructor and save it as a private variable of type JFrame, and at some point I want to be able to return this GridLayout so I call getLayout() in a method of that class: GridLayout currentLayout = (GridLayout) frame.getLayout();.
    I typecast the returned member because it is a LayoutManager, a class that GridLayout implements. When I run this code, I get a runtime error saying getLayout() returned a BorderLayout and I cannot typecast it to a GridLayout.
    This is where I am confused. As I passted a GridLayout to setLayout() before, how come getLayout() gives me back a BorderLayout please? Is there anyway to get the GridLayout back rather than store it as a variable please (the use of this GridLayout is very rare, which is why I would like to avoid keeping a variable for it) ?
    I really appreciate your help and thank you for helping me.

    Jary316 wrote:
    Thank you, it is a bit strange they chose it to work this way but it explains it.Not really when you read on why they do this: [http://java.sun.com/docs/books/tutorial/uiswing/components/toplevel.html]
    It increases the flexibility and power of Swing.

  • Help!  I have an iMac 24" OSX version 10.6.8 my iphoto is having problems.  It will not open properly.  All I get is the little wheel going around and around.  My iphoto is iphoto'11 version 9.2.3(629.52)  What should I do to make it work properly?

    Help!   I have an iMac 24" OSX version 10.6.8.  My iphoto is having problems.  It will not open properly.  All I get is the little wheel going around and around.  My iphoto is:  iphoto'11 version 9.2.3(629.52).  What do I need to do to remedy this?  I recently installed InstallMac.  I don't want this on my computer.  I don't know how to get it off.  I'm afraid that is what scrogged my iphoto.  Can anyone tell me how to correct this situation?

    Re: iPhoto:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In early versions of Library Manager it's the File -> Rebuild command. In later versions it's under the Library menu.)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  
    Regards
    TD

  • This is possible to hide the Close button in JFrame

    As title
    If can, please let me know how

    You can tell the frame not to decorate with JFrame.setFrameUndecorated() {or something like that,
    look it up in the API}, or you can specify your own decorations. I'm guessing that you really don't
    want to do either of those, though.

Maybe you are looking for

  • I cannot open archieved pst file in outlook 2010, can someone help me

    Сan some one help me to open my pst file which I had cut copied while moving on to new Laptop, now I cannot open this file in outlook 2010. I tried repairing the file using scanpst and other demo version from kernel and other software... most of them

  • Table for Vendor Master Email ID

    Hello, Can you please tell me the table where Vendor Email ID is stored and also how to connect it from LFA1-ADRNR in ECC 6.0? Thanks, Venu

  • Title Bar hieght of TitledPane

    How can I increase the height of the Title bar in a TitledPane? It seems to increase when I increase the font size, but what if I just want to make it taller?

  • "Slow menus" - what's the problem?

    Hi Swing people, Here is my first experiment with menus. For some reason they seem "slow" compared to menus in other apps. Is this because of me (and my bad programming) or is Java menus just "slow"? Also, I'm running OS X and would like my menus to

  • Defining document type for STR

    HI I have created plant 1411. In the step in need to follow there is one step which is as below "Ensure order type for STO (Assign doc type, one step procedure and delivery tolerance) and STR (MRP group - OPPR) config between 1411 and 1401 is YSCO (1