Java Code Examples for java.awt.event.WindowAdapter

The following are top voted examples for showing how to use java.awt.event.WindowAdapter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gwm_Crates   File: GWMCratesGUI.java   Source Code and License 7 votes vote down vote up
public GWMCratesGUI() {
    super("GWMCrates v" + GWMCrates.VERSION + " GUI");
    setSize(800, 600);
    setResizable(false);
    setLocationRelativeTo(null);
    setLayout(null);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    createObjects();
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
            int result = JOptionPane.showConfirmDialog(instance, "Do you want to close " + getTitle() + "? If you have unsaved data, it will be lost permanently!", "Close?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (result == JOptionPane.YES_OPTION) {
                instance.setVisible(false);
                instance = null;
            }
        }
    });
    setVisible(true);
}
 
Example 2
Project: smile_1.5.0_java7   File: FontChooser.java   Source Code and License 7 votes vote down vote up
/**
 *  Show font selection dialog.
 *  @param parent Dialog's Parent component.
 *  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
 *
 *  @see #OK_OPTION 
 *  @see #CANCEL_OPTION
 *  @see #ERROR_OPTION
 **/
public int showDialog(Component parent) {
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dialogResultValue = CANCEL_OPTION;
        }
    });

    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;

    return dialogResultValue;
}
 
Example 3
Project: VASSAL-src   File: TranslateWindow.java   Source Code and License 7 votes vote down vote up
protected void initComponents() {
  setTitle("Translate " + VASSAL.configure.ConfigureTree.getConfigureName((Configurable) target));
  JPanel mainPanel = new JPanel(new BorderLayout());
  /*
   * Place Language selector above Tree and Keys
   */
  mainPanel.add(getHeaderPanel(), BorderLayout.PAGE_START);
  mainPanel.add(buildMainPanel(), BorderLayout.CENTER);
  mainPanel.add(getButtonPanel(), BorderLayout.PAGE_END);
  add(mainPanel);
  pack();
  setLocationRelativeTo(getParent());
  setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
  addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
      cancel();
    }
  });
}
 
Example 4
Project: trashjam2017   File: GradientEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
Example 5
Project: Reer   File: Application.java   Source Code and License 6 votes vote down vote up
private void setupUI() {
    frame = new JFrame("Gradle");

    JPanel mainPanel = new JPanel(new BorderLayout());
    frame.getContentPane().add(mainPanel);

    mainPanel.add(singlePaneUIInstance.getComponent());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    singlePaneUIInstance.aboutToShow();

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    frame.setLocationByPlatform(true);
}
 
Example 6
Project: geomapapp   File: MapApp.java   Source Code and License 6 votes vote down vote up
protected void initLayerManager() {

		JFrame d = new JFrame();
		d.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				((JCheckBoxMenuItem)(XML_Menu.commandToMenuItemHash.get("layer_manager_cmd"))).setSelected(false);
			}
		});
		LayerManager lm;
		
		//use existing layer manager if it already exists
		if (layerManager != null) {
			lm = layerManager;
		} else {
			lm = new LayerManager();
		}
		
		lm.setLayerList( toLayerList(map.overlays) );
		lm.setMap(map);

		lm.setDialog(d);
		JScrollPane sp = new JScrollPane(lm);
		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		d.setTitle("Layer Manager");
		d.setContentPane(sp);
//		d.getContentPane().add(sp);
		d.pack();
		d.setSize(new Dimension(lm.getPreferredSize().width+20,lm.getPreferredSize().height+55));
		d.setMaximumSize(new Dimension(400,300));

		d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
		d.setLocationRelativeTo(frame);
		d.setState(Frame.NORMAL);
		d.setAlwaysOnTop(true);
		this.layerManager = lm;
		this.layerManagerDialog = d;	
	}
 
Example 7
Project: litiengine   File: ScreenManager.java   Source Code and License 6 votes vote down vote up
public ScreenManager(final String gameTitle) {
  super(gameTitle);
  this.resolutionChangedConsumer = new CopyOnWriteArrayList<>();
  this.screenChangedConsumer = new CopyOnWriteArrayList<>();
  this.screens = new CopyOnWriteArrayList<>();

  // set default jframe stuff
  this.setResizable(false);
  this.setBackground(Color.BLACK);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
  final RenderComponent comp = new RenderComponent(Game.getConfiguration().graphics().getResolution());
  this.add(comp);
  this.renderCanvas = comp;
  this.getRenderComponent().addComponentListener(new ResizedEventListener());

  this.addWindowStateListener(this);
  this.addWindowFocusListener(this);
  this.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(final WindowEvent event) {
      // ensures that we terminate the game, when the window is being closed
      Game.terminate();
    }
  });
}
 
Example 8
Project: Pandomium   File: PandomiumTest.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    PandomiumSettings settings = PandomiumSettings.getDefaultSettings();

    Pandomium pandomium = new Pandomium(settings);
    pandomium.initialize();

    PandomiumClient client = pandomium.createClient();
    PandomiumBrowser browser = client.loadURL("https://google.pl/");

    JFrame frame = new JFrame();
    frame.getContentPane().add(browser.toAWTComponent(), BorderLayout.CENTER);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            pandomium.dispose();
            frame.dispose();
        }
    });

    frame.setTitle("Pandomium");
    frame.setSize(1720, 840);
    frame.setVisible(true);
}
 
Example 9
Project: incubator-netbeans   File: BrandingUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Opens branding editor for given project. Must be invoked from EDT.
 * @param displayName Editor's display name.
 * @param p Project to be branded.
 * @param model a branding model to use
 */
public static void openBrandingEditor(String displayName, final Project p, BrandingModel model) {
    if( !SwingUtilities.isEventDispatchThread() ) {
        throw new IllegalStateException("This method must be invoked from EDT."); //NOI18N
    }
    synchronized( project2dialog ) {
        Dialog dlg = project2dialog.get(p);
        if( null == dlg ) {
            BrandingEditorPanel editor = new BrandingEditorPanel(displayName, model);
            dlg = editor.open();
            project2dialog.put(p, dlg);
            dlg.addWindowListener( new WindowAdapter() {
                @Override public void windowClosed(WindowEvent e) {
                    synchronized( project2dialog ) {
                        project2dialog.remove(p);
                    }
                }
            });
        } else {
            dlg.setVisible(true);
            dlg.requestFocusInWindow();
        }
    }
}
 
Example 10
Project: ramus   File: AttributePreferenciesDialog.java   Source Code and License 6 votes vote down vote up
private void init(GUIFramework framework) {
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    this.setTitle(GlobalResourcesManager
            .getString("CreateAttributeDialog.Title"));
    this.engine = framework.getEngine();
    this.framework = framework;
    this.accessRules = framework.getAccessRules();
    Options.loadOptions(this);
    init();
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Options.saveOptions(AttributePreferenciesDialog.this);
        }
    });
    setMinimumSize(getSize());
}
 
Example 11
Project: incubator-netbeans   File: Terminal.java   Source Code and License 6 votes vote down vote up
private void run2() {
    //
    // Start process
    //
    ptyProcess = executor.start(program, term);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            try {
                ptyProcess.hangup();
            } catch (IllegalStateException x) {
            }
        }
    });

    // Make main window visible
    setVisible(true);

    //
    // Wait for process to exit
    //
    ptyProcess.waitFor();

    dispose();
}
 
Example 12
Project: incubator-netbeans   File: PluginManagerUI.java   Source Code and License 6 votes vote down vote up
@Override
public void addNotify () {
    super.addNotify ();
    //show progress for initialize method
    final Window w = findWindowParent ();
    if (w != null) {
        w.addWindowListener (new WindowAdapter (){
            @Override
            public void windowOpened (WindowEvent e) {
                final WindowAdapter waa = this;
                setWaitingState (true);
                Utilities.startAsWorkerThread (PluginManagerUI.this,
                        new Runnable () {
                            @Override
                            public void run () {
                                try {
                                    initTask.waitFinished ();
                                    w.removeWindowListener (waa);
                                } finally {
                                    setWaitingState (false);
                                }
                            }
                        },
                        NbBundle.getMessage (PluginManagerUI.class, "UnitTab_InitAndCheckingForUpdates"),
                        Utilities.getTimeOfInitialization ());
            }
        });
    }
    HelpCtx.setHelpIDString (this, PluginManagerUI.class.getName ());
    tpTabs.addChangeListener (new ChangeListener () {
        @Override
        public void stateChanged (ChangeEvent evt) {
            HelpCtx.setHelpIDString (PluginManagerUI.this, getHelpCtx ().getHelpID ());
        }
    });
}
 
Example 13
Project: openjdk-jdk10   File: TableExample2.java   Source Code and License 6 votes vote down vote up
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
Example 14
Project: Proyecto-DASI   File: VisualizacionJfreechart.java   Source Code and License 6 votes vote down vote up
public void showJFreeChart(int coordX, int coordY){
        //Mostrar el chart
        ChartPanel chartPanel = new ChartPanel(chart1);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);           
                
        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);               
        
        addWindowListener(
        		new WindowAdapter(){
        		        public void WindowClosing (WindowEvent e){
                           System.out.println("No quiero cerrar la ventana !!!\n");
        		        }	
        		}
        );

        
        this.pack();
//        RefineryUtilities.centerFrameOnScreen(this);
        
        this.setLocation(coordX, coordY);
        
        this.setVisible(true);    	    	
    }
 
Example 15
Project: Progetto-N   File: GuiInputSale.java   Source Code and License 6 votes vote down vote up
/**
 * Nel momento in cui viene chiuso il programma prima della fine del processo di inizializzazione
 */
public void imprevisto(){
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            int i = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler uscire?");
            if(i==JOptionPane.YES_OPTION){
                try {
                    createDb.DropSchema();
                    dispose();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(rootPane, "Impossibile raggiungere il Database!");
                }  
            }else
                setDefaultCloseOperation(GuiNome.DO_NOTHING_ON_CLOSE);
        }
    });
}
 
Example 16
Project: AquamarineLake   File: MainFrame.java   Source Code and License 6 votes vote down vote up
public MainFrame()
{
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setPreferredSize(new Dimension(640, 480));

    cap = new VideoCapture(0);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            cap.release();
            System.exit(0);
        }
    });

    p = new DrawPanel();
    add(p);

    setVisible(true);
}
 
Example 17
Project: brModelo   File: JFontChooser.java   Source Code and License 6 votes vote down vote up
/**
 *  Show font selection dialog.
 *  @param parent Dialog's Parent component.
 *  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
 *
 *  @see #OK_OPTION 
 *  @see #CANCEL_OPTION
 *  @see #ERROR_OPTION
 **/
public int showDialog(Component parent)
{
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter()
    {
        public void windowClosing(WindowEvent e)
        {
            dialogResultValue = CANCEL_OPTION;
        }
    });

    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;

    return dialogResultValue;
}
 
Example 18
Project: openjdk-jdk10   File: MultiMonPrintDlgTest.java   Source Code and License 6 votes vote down vote up
private void executeTest() {

        GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int x = 0;
        Frame f = null;
        for (x = 0; x < gd.length; x ++) {
            if (gd[x] != defDev) {
                secFrame = new Frame("Screen " + x + " - secondary", gd[x].getDefaultConfiguration());
                f = secFrame;
            } else {
                primaryFrame = new Frame("Screen " + x + " - primary", gd[x].getDefaultConfiguration());
                f = primaryFrame;
            }
            Button b = new Button("Print");
            b.addActionListener(this);
            f.add("South", b);
            f.addWindowListener (new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    ((Window) we.getSource()).dispose();
                }
            });
            f.setSize(200, 200);
            f.setVisible(true);
        }
    }
 
Example 19
Project: Open-DM   File: LoadSchedulePanel.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    // just test this panel.
    LoadSchedulePanel p = new LoadSchedulePanel(null, LoadSchedule.getDefaultLoadSchedule(),
            true);
    JFrame f = new JFrame();
    f.add(p);
    f.pack();
    f.setLocation(100, 800);
    f.setSize(new Dimension(800, 500));
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}
 
Example 20
Project: AgentWorkbench   File: AgentSelector.java   Source Code and License 6 votes vote down vote up
/**
 * This method initializes this.
 */
private void initialize() {
	
	this.setSize(720, 500);
	this.setTitle("Auswahl - Agenten");
	this.setIconImage(GlobalInfo.getInternalImage("AgentGUI.png"));
	this.setModal(true);
	this.setContentPane(getJContentPane());
	this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	this.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent evt) {
			canceled = true;
			setVisible(false);
		}
	});
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
	int top = (screenSize.height - this.getHeight()) / 2; 
    int left = (screenSize.width - this.getWidth()) / 2; 
    this.setLocation(left, top);	
 
    // --- Translate -----------------------------
	this.setTitle(Language.translate("Auswahl - Agenten"));
	jLabelSearchCaption.setText(Language.translate("Suche"));
	jButtonOk.setText(Language.translate("Hinzuf├╝gen"));
	jButtonCancel.setText(Language.translate("Abbrechen"));
}
 
Example 21
Project: AgentWorkbench   File: OntologyInstanceDialog.java   Source Code and License 6 votes vote down vote up
/**
	 * This method initialises this dialog.
	 */
	private void initialize() {
		
		this.setSize(600, 500);
		this.setModal(true);
		this.setTitle(Language.translate("Ontologie-Klassen initialisieren"));
		this.setContentPane(getJContentPane());
		
//		this.setAlwaysOnTop(true);
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent evt) {
				setCancelled(true);
				setVisible(false);
			}
		});
		// --- Set the IconImage ----------------------------------
		if (OntologyVisualisationConfiguration.getApplicationIconImage()!=null) this.setIconImage(OntologyVisualisationConfiguration.getApplicationIconImage());
		
		// --- Dialog zentrieren ------------------------------------
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
		int top = (screenSize.height - this.getHeight()) / 2; 
	    int left = (screenSize.width - this.getWidth()) / 2; 
	    this.setLocation(left, top);	
	    
	}
 
Example 22
Project: ACHelper   File: NewContestDialog.java   Source Code and License 6 votes vote down vote up
NewContestDialog(MainFrame parent) {
    super(parent, true);
    this.parent = parent;
    setTitle("Enter contest URL to parse");
    setContentPane(rootPanel);
    hourSpinner.setModel(new SpinnerNumberModel(0, 0, 23, 1));
    minuteSpinner.setModel(new SpinnerNumberModel(0, 0, 59, 1));
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            closeDialog();
        }
    });
    scheduleButton.addActionListener(event -> schedule());
    parseButton.addActionListener(event -> startParsing());
    abortButton.addActionListener(event -> abort());
    pack();
    setupShortcuts();
}
 
Example 23
Project: jmt   File: JSIMMain.java   Source Code and License 6 votes vote down vote up
/**
 * Sets resultWindow to be shown. This method is used by pollerThread
 * @param rsw window to be set as current ResultsWindow
 */
public void setResultsWindow(JFrame rsw) {
	this.resultsWindow = rsw;
	if (rsw instanceof ResultsWindow) {
		// Sets action for toolbar buttons
		((ResultsWindow) rsw).addButtonActions(SIM_START, SIM_PAUSE, SIM_STOP);
	} else {
		SHOW_RESULTS.setEnabled(true);
	}
	// Adds a listener that will unselect Show results button upon results window closing
	rsw.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			SHOW_RESULTS.setSelected(false);
		}
	});
}
 
Example 24
Project: jmt   File: LDEditingWindow.java   Source Code and License 6 votes vote down vote up
LDEditingWindow(Frame owner, LDEditor ldEditor) {
	super(owner, false);
	this.ldEditor = ldEditor;
	if (owner == null) {
		throw new IllegalArgumentException("owner must not be null!");
	}
	// only height is fixed
	setSize(CommonConstants.MAX_GUI_WIDTH_LDEDITING, CommonConstants.MAX_GUI_HEIGHT_LDEDITING);
	//setUndecorated(true);
	//setResizable(false);
	this.owner = owner;
	setTitle("LD Editor");
	help = ((ExactWizard) owner).getHelp();

	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

	/* closing=cancel */
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			LD_CANCEL.actionPerformed(null);
		}
	});

	initComponents();
}
 
Example 25
Project: jmt   File: DefaultsEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize parameters of the window (size, title)... Then calls <code>initComponents</code>
 * @param target target application (JMODEL or JSIM)
 */
protected void initWindow(int target) {
	this.target = target;
	// Sets default title, close operation and dimensions
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setTitle("Editing Default Parameters...");
	int width = 840, height = 600;

	// Centers this dialog on the screen
	Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
	setBounds((scrDim.width - width) / 2, (scrDim.height - height) / 2, width, height);
	// If user closes this window, act as cancel and reloads saved parameters
	addWindowStateListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			Defaults.reload();
		}
	});
	initComponents(target);
}
 
Example 26
Project: Progetto-C   File: GradientEditor.java   Source Code and License 6 votes vote down vote up
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
Example 27
Project: Equella   File: SecurityTree.java   Source Code and License 6 votes vote down vote up
public void showDialog(Component parent)
{
	dialog = ComponentHelper.createJDialog(parent);
	dialog.setTitle(CurrentLocale.get(
		"com.tle.admin.security.tree.securitytree.title", Driver.instance().getInstitutionName())); //$NON-NLS-1$
	dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	dialog.setModal(true);
	dialog.setContentPane(content);

	dialog.addWindowListener(new WindowAdapter()
	{
		@Override
		public void windowClosing(WindowEvent e)
		{
			attemptToCloseWindow();
		}
	});

	ComponentHelper.percentageOfScreen(dialog, 0.9f, 0.9f);
	ComponentHelper.centreOnScreen(dialog);

	dialog.setVisible(true);
}
 
Example 28
Project: call-IDE   File: LoginFrame.java   Source Code and License 6 votes vote down vote up
/**
   * Creates new form loginFrame
   */
  public LoginFrame() {
      initComponents();
      stdRdButton.setActionCommand("Student");
      insRdButton.setActionCommand("Instructor");
      client = new Client();
      boolean conCheck = client.connectServer();
      if(!conCheck) {
          dispose();
      }
      else {
          this.setVisible(true);
      }
      addWindowListener(new WindowAdapter() {
	@Override
	public void windowClosing(WindowEvent e) {
		client.closeConnection();
	}
});
      
  }
 
Example 29
Project: call-IDE   File: ConsoleCore.java   Source Code and License 6 votes vote down vote up
/**
 * Description: dispatches the console from its current place properly.
 */
public static void  dispatch(JScrollPane scrollPane, JTextPane cons,
                             JTabbedPane outputTabs, Component tabComp, JFrame frame,
                             Boolean consoleOut, Attachable mainFrame) {
    frame.setSize(600, 400);
    frame.setLocationRelativeTo( (Component) mainFrame);
    frame.setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    scrollPane.setViewportView(cons);
    frame.add(scrollPane);
    
    if (frame.getWindowListeners().length > 0)
        frame.removeWindowListener(frame.getWindowListeners()[0]);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            mainFrame.attachConsole();
        }
    });
    frame.setVisible(true);
}
 
Example 30
Project: jaer   File: ApsFrameExtractor.java   Source Code and License 6 votes vote down vote up
public ApsFrameExtractor(final AEChip chip) {
    super(chip);
    apsDisplay = ImageDisplay.createOpenGLCanvas();
    apsDisplay.addMouseMotionListener(new MouseInfo(apsDisplay));
    apsFrame = new JFrame("APS Frame");
    apsFrame.setPreferredSize(new Dimension(400, 400));
    apsFrame.getContentPane().add(apsDisplay, BorderLayout.CENTER);
    apsFrame.pack();
    apsFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            setShowAPSFrameDisplay(false);
        }
    });
    apsDisplayLegend = apsDisplay.addLegend("", 0, 0);
    final float[] displayColor = new float[3];
    displayColor[0] = 1.0f;
    displayColor[1] = 1.0f;
    displayColor[2] = 1.0f;
    apsDisplayLegend.color = displayColor;
    initFilter();

    setPropertyTooltip("invertIntensity", "Inverts grey scale, e.g. for raw samples of signal level");
    setPropertyTooltip("preBufferFrame", "Only display and use complete frames; otherwise display APS samples as they arrive");
    setPropertyTooltip("logCompress", "Should the displayBuffer be log compressed");
    setPropertyTooltip("logDecompress", "Should the logComressed displayBuffer be rendered in log scale (true) or linearly (false)");
    setPropertyTooltip("displayContrast", "Gain for the rendering of the APS display");
    setPropertyTooltip("displayBrightness", "Offset for the rendering of the APS display");
    setPropertyTooltip("extractionMethod",
            "Method to extract a frame; CDSframe is the final result after subtracting signal from reset frame. Signal and reset frames are the raw sensor output before correlated double sampling.");
    setPropertyTooltip("showAPSFrameDisplay", "Shows the JFrame frame display if true");
    chip.addObserver(this);

}
 
Example 31
Project: Progetto-N   File: GuiInformationSale.java   Source Code and License 6 votes vote down vote up
/**
 * Quando chiudo il programma o il db smette di funzionare
 */
public void imprevisto(){
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            int i = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler uscire?");
            if(i==JOptionPane.YES_OPTION){
                try {
                    CreateDb createDb = new CreateDb();
                    createDb.DropSchema();
                    dispose();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(rootPane, "Impossibile raggiungere il Database!");
                }  
            }else
                setDefaultCloseOperation(GuiNome.DO_NOTHING_ON_CLOSE);
        }
    });
}
 
Example 32
Project: sumo   File: Picking.java   Source Code and License 6 votes vote down vote up
Picking()
{
  Frame frame = new Frame("Picking Example");
  GLCapabilities capabilities = new GLCapabilities(null);
  GLCanvas drawable = new GLCanvas(capabilities);
  final Renderer renderer = new Renderer();
  drawable.addGLEventListener(renderer);
  drawable.addMouseListener(renderer);
  drawable.addMouseMotionListener(renderer);
  frame.add(drawable);
  frame.setSize(400, 400);
  final Animator animator = new Animator(drawable);
  frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent e) 
      {
        animator.stop();
        System.exit(0);
      }
    });
  frame.setVisible(true);
  animator.start();	
}
 
Example 33
Project: OpenJSharp   File: Font2DTest.java   Source Code and License 6 votes vote down vote up
private void loadComparisonPNG( String fileName ) {
    try {
        BufferedImage image =
            javax.imageio.ImageIO.read(new File(fileName));
        JFrame f = new JFrame( "Comparison PNG" );
        ImagePanel ip = new ImagePanel( image );
        f.setResizable( false );
        f.getContentPane().add( ip );
        f.addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                ( (JFrame) e.getSource() ).dispose();
            }
        });
        f.pack();
        f.show();
    }
    catch ( Exception ex ) {
        fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
        ex.printStackTrace();
    }
}
 
Example 34
Project: VASSAL-src   File: RegionGrid.java   Source Code and License 6 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
  PropertiesWindow w = openWindows.get(target);
  if (w == null) {
    w = new PropertiesWindow(dialogOwner,false,target,helpWindow);
    w.addWindowListener(new WindowAdapter() {
      public void windowClosed(WindowEvent e) {
        openWindows.remove(target);
        owner.setDirty(
            !region.getName().equals(origRegion.getName()) ||
            !region.getOrigin().equals(origRegion.getOrigin()));
        owner.repaint();
      }
    });
    openWindows.put(target,w);
    w.setVisible(true);
  }
  w.toFront();
}
 
Example 35
Project: java-open-nl   File: ONLSettings.java   Source Code and License 6 votes vote down vote up
public static void onJFrameClose_Disconnect(JFrame frame) {
	if(frame != null) {
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				if(Server.isHosting() || Client.isConnected()) {
					if(Server.isHosting()) {
						Server.shutdown("");
					}else {
						Client.disconnect();
					}
				}
			}
		});
	}else {
		System.out.println("Can't add Window Event on a null JFrame.");
	}
}
 
Example 36
Project: Open-DM   File: InitialImportFilePanel.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    // just test this panel.
    CopyJob copyJob = new CopyJob();
    copyJob.setListFile(new File("/home/bioakimidis/ibm/readme.txt"));
    InitialImportFilePanel p = new InitialImportFilePanel(copyJob);

    JFrame f = new JFrame();
    f.add(p);
    f.pack();
    f.setLocation(100, 800);
    f.setSize(new Dimension(700, 500));
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);

}
 
Example 37
Project: jdk8u-jdk   File: Font2DTest.java   Source Code and License 6 votes vote down vote up
private void loadComparisonPNG( String fileName ) {
    try {
        BufferedImage image =
            javax.imageio.ImageIO.read(new File(fileName));
        JFrame f = new JFrame( "Comparison PNG" );
        ImagePanel ip = new ImagePanel( image );
        f.setResizable( false );
        f.getContentPane().add( ip );
        f.addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                ( (JFrame) e.getSource() ).dispose();
            }
        });
        f.pack();
        f.show();
    }
    catch ( Exception ex ) {
        fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
        ex.printStackTrace();
    }
}
 
Example 38
Project: Dise-o-2017   File: ControladorGestionarTipoImpuesto.java   Source Code and License 6 votes vote down vote up
public void mostrarPantallaModificacionEmpresa(Object object,String cuitEmpresa){
    DTOTipoImpuesto dtoTi = obtenerTipoImpuesto((int) object);
    if (dtoTi != null) {
        IUGestionarTipoImpuestoModificarEmpresa pantallaModificarEmpresa = new IUGestionarTipoImpuestoModificarEmpresa(cuitEmpresa);
        pantallaModificarEmpresa.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // Evito que se cierre al presionar x
        pantallaModificarEmpresa.setVisible(true); // La hago visible
        // Modifico la operaci├│n de cierre para volver a la pantalla principal
        pantallaModificarEmpresa.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        pantallaModificarEmpresa.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent ev) {
                iniciar();
            }
        });
        pantallaModificarEmpresa.setNombre_actual(dtoTi.getNombreDTOTipoImpuesto());
        pantallaModificarEmpresa.setTextfield_nombre(dtoTi.getNombreDTOTipoImpuesto());
        pantallaModificarEmpresa.setCheckbox_esEditable(dtoTi.isEsMontoEditableDTOTipoImpuesto());
        if (dtoTi.getFechaHoraInhabilitacionDTOTipoImpuesto() == null) {
            pantallaModificarEmpresa.setCheckbox_Habilitar(true);
        } else {
            pantallaModificarEmpresa.setCheckbox_Habilitar(false);
        }
    }
}
 
Example 39
Project: QN-ACTR-Release   File: JSIMMain.java   Source Code and License 6 votes vote down vote up
/**
 * Sets resultWindow to be shown. This method is used by pollerThread
 * @param rsw window to be set as current ResultsWindow
 */
public void setResultsWindow(JFrame rsw) {
	this.resultsWindow = rsw;
	if (rsw instanceof ResultsWindow) {
		// Sets action for toolbar buttons
		((ResultsWindow) rsw).addButtonActions(SIM_START, SIM_PAUSE, SIM_STOP);
	} else {
		SHOW_RESULTS.setEnabled(true);
	}
	// Adds a listener that will unselect Show results button upon results window closing
	rsw.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			SHOW_RESULTS.setSelected(false);
		}
	});
}
 
Example 40
Project: Open-DM   File: InitialSelectedItemsPanel.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) throws DatabaseException {
    // just test this panel.
    InitialSelectedItemsPanel p = new InitialSelectedItemsPanel(new CopyJob());
    // Object[] items = new Object[] {"This", "is", "a", "test", "of", "the", "emergency",
    // "broadcast", "system"};
    // p.setItems(items);

    JFrame f = new JFrame();
    f.add(p);
    f.pack();
    f.setLocation(100, 800);
    f.setSize(new Dimension(700, 500));
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}