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,104 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Class CaseConverter - A simple applet that takes input from a text field
* and converts to upper or lower case in response to user button selection.
* Works well with a width of 300 and height of 120.
*
* Aug 2004: Updated from Applet to JApplet (mik)
*
* @author Bruce Quig
* @author Michael Kolling
*
* @version 2004-08-04
*/
public class CaseConverter extends JApplet
implements ActionListener
{
private JTextField inputField;
private final String UPPERCASE = "UPPERCASE";
private final String LOWERCASE = "lowercase";
private final String CLEAR = "Clear";
/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// GUI elements are added to the applet's content pane, so get it for us.
Container contentPane = getContentPane();
// set a layout with some spacing
contentPane.setLayout(new BorderLayout(12,12));
// add the title label
JLabel title = new JLabel("Case Converter - A BlueJ demo applet");
contentPane.add(title, BorderLayout.NORTH);
// create the center part with prompt and text field and add it
JPanel centerPanel = new JPanel();
JLabel prompt = new JLabel("Enter a string:");
centerPanel.add(prompt);
inputField = new JTextField(16);
centerPanel.add(inputField);
contentPane.add(centerPanel, BorderLayout.CENTER);
// make a panel for the buttons
JPanel buttonPanel = new JPanel();
// add the buttons to the button panel
JButton uppercase = new JButton(UPPERCASE);
uppercase.addActionListener(this);
buttonPanel.add(uppercase);
JButton lowercase = new JButton(LOWERCASE);
lowercase.addActionListener(this);
buttonPanel.add(lowercase);
JButton clear = new JButton(CLEAR);
clear.addActionListener(this);
buttonPanel.add(clear);
// add the buttons panel to the content pane
contentPane.add(buttonPanel, BorderLayout.SOUTH);
}
/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
return "Title: Case Converter \n" +
"Author: Bruce Quig \n" +
"A simple applet that converts text to upper or lower case. ";
}
/**
* ActionListener Interface method.
* Called when action events occur with registered components that
* can fire action events.
* @param ae the ActionEvent object created by the event
*/
public void actionPerformed(ActionEvent evt)
{
String command = evt.getActionCommand();
// if clear button pressed
if(CLEAR.equals(command))
inputField.setText("");
// uppercase button pressed
else if(UPPERCASE.equals(command))
inputField.setText(inputField.getText().toUpperCase());
// lowercase button pressed
else if(LOWERCASE.equals(command))
inputField.setText(inputField.getText().toLowerCase());
}
}

View File

@@ -0,0 +1,9 @@
BlueJ example project "appletdemo"
Copyright (c) Bruce Quig, Michael K<>lling, Monash University, 1999-2000
This project is distributed with the BlueJ distribution as an example of an
applet.
To start this applet, choose "Run Applet" from the class's popup menu and
click OK in the following dialogue.

View File

@@ -0,0 +1,17 @@
#BlueJ package file
package.editor.height=234
package.editor.width=358
package.editor.x=20
package.editor.y=42
package.numDependencies=0
package.numTargets=1
target1.appletHeight=250
target1.appletWidth=250
target1.height=60
target1.modifiers=0
target1.name=CaseConverter
target1.numberAppletParameters=0
target1.type=AppletTarget
target1.width=110
target1.x=90
target1.y=80