-2

I have been out for a while, not that i am a good programmer. But when i made an application window in eclipse (new--- other---WindowBuilder--swing designer--application window)

this is the code it generates

 import javax.swing.JFrame;

public class AddTournamentToRankingGUI {

 private JFrame frame;
  public static void main(String[] args) {
  EventQueue.invokeLater(new Runnable() {
   public void run() {
    try {
     AddTournamentToRankingGUI window = new AddTournamentToRankingGUI();
     window.frame.setVisible(true);
    } catch (Exception e) {
     e.printStackTrace();
    }
   }
  });
 }

 public AddTournamentToRankingGUI() {
  initialize();
 }

 private void initialize() {
  frame = new JFrame();
  frame.setBounds(100, 100, 680, 814);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
  }

I tried to resize in eclipse, no problem. then i hit run and hit the close button and tried to resize the GUI in eclipse again. This is where i cannot resize the window. only after a restart i can resize it in eclipse until i run the app again.

I have tried to add code to complete exit the application, but same result. This is the code i used

import javax.swing.JOptionPane;
import javax.swing.JFrame;

/*Some piece of code*/
frame.addWindowListener(new java.awt.event.WindowAdapter() {
    @Override
    public void windowClosing(java.awt.event.WindowEvent windowEvent) {
        if (JOptionPane.showConfirmDialog(frame, 
            "Are you sure you want to close this window?", "Close Window?", 
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){
            System.exit(0);
        }
    }
});

Am i missing something here?

Makoto
  • 104,088
  • 27
  • 192
  • 230
cc2k
  • 351
  • 1
  • 2
  • 12
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, _a specific problem or error_ and _the shortest code necessary_ to reproduce it **in the question itself**. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – Joe C Dec 20 '18 at 20:47
  • I havent used any other cose, only resize the gui, run the app, tried resizing and i was failing. i will add the extra code i added to try to resolve it, but it had the same result. – cc2k Dec 20 '18 at 20:49
  • Let me put it this way: unless you can give us a code sample (25 lines max) which demonstrates this, we cannot help you. – Joe C Dec 20 '18 at 20:50
  • added the code i used, hopefully this is what you ment. As nothing else i have done. except searching for this problem ofcourse. – cc2k Dec 20 '18 at 20:54
  • How and when are you attempting to resize the frame? – Joe C Dec 20 '18 at 20:54
  • I have tried resizing with success before i run the app, with drag and drop in the GUI window, after run this did not work anymore. – cc2k Dec 20 '18 at 20:55
  • Are you trying to resize it while the dialog is open? If so, you cannot do that. – Joe C Dec 20 '18 at 20:59
  • Nope, i have closed the app, then i try to resize the window. that part does not work – cc2k Dec 20 '18 at 20:59
  • That makes no sense. If the app is closed, there should be no window. – Joe C Dec 20 '18 at 21:00
  • oke, we are misscommunicating i see, the resizing is in the eclipse GUI screen, not the app itself as it is indeed closed. all the resizing i mention is in eclipse. – cc2k Dec 20 '18 at 21:02
  • If you want to answer your question, post a separate answer - don't add "Solved" to the title. – Makoto Dec 20 '18 at 23:21
  • thank you, i was searching for a solved button, thx. – cc2k Dec 20 '18 at 23:23

1 Answers1

0

I am stupid... i thought the move cursor was the resize cursor, so that is why it did not work obviously..

cc2k
  • 351
  • 1
  • 2
  • 12