For each lab and homework assignment throughout the semester, you will be asked to use the IDE (integrated development environment) to edit, compile, and run Java applications. For each assignment, you will be provided with a project folder containing the files used by the IDE. You only need to be concerned with the one file with a ".java" extension.
Depending on the particular IDE you are using, there could be some surprising quirks that you should be aware of. Your laboratory instructor will give you additional details about how to use the IDE.
// My First Application // Watch the colors change as you click the buttons import java.awt.*; import java.awt.event.*; public class Colors extends Panel implements ActionListener { Button backButton, textButton; Font f = new Font("Helvetica", Font.BOLD, 18); Color[] bgColors = { Color.cyan, Color.orange, Color.pink, Color.green }; Color[] txtColors = { Color.blue, Color.magenta, Color.red, Color.black }; int bgCode = 0, txtCode = 0; public Colors() { backButton = new Button("Background Color"); backButton.addActionListener(this); add(backButton); textButton = new Button("Text Color"); textButton.addActionListener(this); add(textButton); setBackground(bgColors[bgCode]); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // Who generated the event? if (source == backButton) { // Was it the Background Color button? bgCode = ++bgCode % bgColors.length; setBackground(bgColors[bgCode]); } else if (source == textButton) { // Or was it the Text Color button? txtCode = ++txtCode % txtColors.length; } repaint(); } public void paint(Graphics g) { g.setColor(txtColors[txtCode]); g.setFont(f); g.drawString("Goodbye world! Hello Java!", 30, 120); } public static void main(String args[]) { Frame f = new Frame("Colors"); f.add(BorderLayout.CENTER, new Colors()); f.setSize(325, 200); f.addWindowListener(new WindowCloser()); f.show(); } } class WindowCloser extends WindowAdapter { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); System.exit(0); } }