A Dialog can be modal. When a modal Dialog is visible, it blocks user input to all other windows in the program. JOptionPane creates JDialogs that are modal. To create a non-modal Dialog, you must use the JDialog class directly.
- Open the editor for the class.   Double click on theyellow HelloWorld icon to open the editor for that class.
- Modify the code for the class.   When you open theHelloWorld Class, you will see some sample code for the class, includingan instance variable x, a constructor HelloWorld, and the method namedsampleMethod. This code may be interesting the first time you see it, butit is totally worthless. Select all of the code and delete it. Then add your code. For example, the HelloWorld program would be:
- Compile the class.   Click on the Compile button at the top of the editor. You should get the message "Class compiled - no syntax erors."
- Run the application.   Go back to the main BlueJ window. If you don'tsee it on the desktop screen, look at the bottom of the monitor screen -- there are twoBlueJ windows. Then, right click onthe yellow HelloWorld icon, and select void main(args) to run the main method.
(The "/qn" turns off the GUI, the "/L* logfile.txt" logs to a file so you can check if the install succeeded afterwards - look at the end of the file - and the "/i Greenfoot-windows-241.msi" tells it which installer package to install). If you want to customise the settings, then here's the full set of properties that you might want to tweak for a 32-bit install:
The group policy settings on Windows can restrict which drives/folders are shown in the standard Windows "save" (or "save as") and "open" dialog windows. They do not, in any other way, restrict the ability of programs being run by users to modify files in directories for which they otherwise have appropriate permission. This means that, in general, relying on these group policy settings to restrict access to particular drives/folders/files is a bad idea, although it seems that some schools do use such group policy settings (hopefully) as an additional, rather than primary, security measure.
If you're working at home, you can put all your files on a floppy disk (in which case you can follow the same instructions as the ones above), or you can put your work somewhere on your hard drive, e.g. the same directory where you installed all your CSE 142/143 software. In that case, follow the instructions above, but wherever A: appears above, substitute C:\CSE (or wherever you put installed your CSE software).
- When you start up BlueJ, it first creates a shell window, and then creates its the main BlueJ window. The shell window will never be used. You can simply minimize it (by clicking the _ in the title bar) to get it out of the way.
- If you're working at home, and you get tired of minimizing the shell window each time you run BlueJ, you can find the bluej.bat file that you installed, create a shortcut (e.g., doing right-click and then selecting Create Shortcut and then renaming the resulting shortcut to something nicer, like "Run BlueJ"), right-click on the shortcut's icon and select Properties, select the Shortcut tab (it's probably already selected), then change the Run: option from Normal window to Minimized, then click OK. To run BlueJ, click on the shortcut (not the original bluej.bat file), and BlueJ should start up without popping up that annoying empty window each time.
Writing a ClassTo define a new class: