You decide what problem you want to solve and write the program to solve it. It
ID: 656678 • Letter: Y
Question
You decide what problem you want to solve and write the program to solve it. It must include a written description of what the program does and instructions about how the program works in the comments section. I do not want to see a program from the text, but all of you have interests and hobbies that you could design a program that would meet the following criteria.
Comments:
Enough so another programmer will know what the program is doing without even reading your description Also, include your name, date, and program name at the top of the program
Selection structure:
Include either If/else logic or a case structure
Repetition structure:
Include either While, Do While or For loop
Array:
Any type of an array
Inheritance:
Use Inheritance and/or Interfaces
Exception:
Use try
Explanation / Answer
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import javax.swing.*;
@SuppressWarnings("serial")
public class SwcoTest extends Jframe
{
int x[]=10;
public class Test()
{
ImageIcon x11 = null;
ImageIcon x2 = null;
URL imgURL = getcl().get1.getr(imgFile);
if (imgURL ! = null)
{
i1 = new ImageIcon (imgURL);
}
else
{
System.err.println("Coulsn't find file: " + imgNoughFilename);
}
Container content = getContentPane();
Content.setLayout(new Flayout(Flayout.CENTER, 20, 20));
JLable lable = new JLable("JLable", i1, SwingConstants.CENTER);
label.setFont(new Font(Font.DIALOG, Font.ITALIC, 20));
label.setBackground (new Color (30, 300, 30));
label.setForeground(color.RED);
label.setPreferredSize(new Dimension (130, 100));
label.set ToolTipText("JLabel");
content.add(label);
jButton button = new JButton();
button.setText("Button");
button.setIcon(x2);
button.setVertivalAlignment(SwingConstants.BOTTOM);
button.setHorizontalAlignment(SwingConstants.RIGHT);
button.setVerticalTextPosition(SwingConstant.LEFT);
button.setVerticalTextPosition(SwingConstant.TOP);
button.setFont (new Font(Font.SANS_SERIF,Font, 20))
btton.setBackground(new Color(230, 240, 250));
button.setForegrount(color.green);
button.setPreferredSize(new Dimension(160, 100));
button.setToolTipText("JButton");
button.setMnemonic(KeyEvent.VK_A);
content.add(button);
JTextField textField = new JTextField("Text Field", 20);
textFileld.setFont(new Font(Font.DIALOG_INPUT,Font,20));
textField.setForeground(Color.blue);
textField.setHorizontalAlignment("JTextField.RIGHT");
textField.setToolTipText(" JTextField");
content.add(textField);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("JComponent Test");
setLocationRelativeTo(null);
setSize(510, 160);
setVisible(true);
System.out.println(lable);
system.out.println(button);
system.out.println(textField);
public static void main (String[] args)
{
SwingUtilities.invokeLater(new Runnable())
{
public void run()
{
new Test();
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.