first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
#BlueJ class context
comment0.params=
comment0.target=ImageViewer()
comment0.text=\n\ Create\ an\ ImageViewer\ show\ it\ on\ screen.\n
comment1.params=event
comment1.target=void\ actionPerformed(java.awt.event.ActionEvent)
comment1.text=\n\ Receive\ notification\ of\ an\ action.\n\ @param\ event\ Details\ of\ the\ action.\n
comment2.params=
comment2.target=void\ makeFrame()
comment2.text=\n\ Create\ the\ Swing\ frame\ and\ its\ content.\n
comment3.params=frame
comment3.target=void\ makeMenuBar(javax.swing.JFrame)
comment3.text=\n\ Create\ the\ main\ frame's\ menu\ bar.\n\ @param\ frame\ \ \ The\ frame\ that\ the\ menu\ bar\ should\ be\ added\ to.\n
numComments=4

View File

@@ -0,0 +1,78 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* ImageViewer is the main class of the image viewer application. It builds
* and displays the application GUI.
*
* To start the application, create an object of this class.
*
* @author Michael Kölling and David J. Barnes.
* @version 0.2
*/
public class ImageViewer
implements ActionListener
{
private JFrame frame;
/**
* Create an ImageViewer show it on screen.
*/
public ImageViewer()
{
makeFrame();
}
/**
* Receive notification of an action.
* @param event Details of the action.
*/
public void actionPerformed(ActionEvent event)
{
System.out.println("Menu item: " + event.getActionCommand());
}
// ---- swing stuff to build the frame and all its components ----
/**
* Create the Swing frame and its content.
*/
private void makeFrame()
{
frame = new JFrame("ImageViewer");
makeMenuBar(frame);
Container contentPane = frame.getContentPane();
JLabel label = new JLabel("I am a label. I can display some text.");
contentPane.add(label);
// building is done - arrange the components and show
frame.pack();
frame.setVisible(true);
}
/**
* Create the main frame's menu bar.
* @param frame The frame that the menu bar should be added to.
*/
private void makeMenuBar(JFrame frame)
{
JMenuBar menubar = new JMenuBar();
frame.setJMenuBar(menubar);
// create the File menu
JMenu fileMenu = new JMenu("File");
menubar.add(fileMenu);
JMenuItem openItem = new JMenuItem("Open");
openItem.addActionListener(this);
fileMenu.add(openItem);
JMenuItem quitItem = new JMenuItem("Quit");
quitItem.addActionListener(this);
fileMenu.add(quitItem);
}
}

View File

@@ -0,0 +1,14 @@
Project: imageviewer, version 0.2
Authors: David Barnes and Michael Kölling
This project is part of the material for the book
Objects First with Java - A Practical Introduction using BlueJ
Sixth edition
David J. Barnes and Michael Kölling
Pearson Education, 2016
It is discussed in chapter 13.
To use this project, create an instance of class ImageViewer.
For details, refer to the book chapter.

View File

@@ -0,0 +1,29 @@
#BlueJ package file
objectbench.height=76
objectbench.width=683
package.editor.height=364
package.editor.width=575
package.editor.x=70
package.editor.y=80
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.editor.height=543
readme.editor.width=810
readme.editor.x=53
readme.editor.y=23
target1.editor.height=714
target1.editor.width=892
target1.editor.x=53
target1.editor.y=36
target1.height=60
target1.name=ImageViewer
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=120
target1.x=180
target1.y=120