Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

15-10. Using your own layouts with setBounds(), etc., design the attached lycos

ID: 3595654 • Letter: 1

Question

15-10. Using your own layouts with setBounds(), etc., design the attached lycos search page applet. Plan out the coordinates for the placement and sizes of the two checkboxes, textfield, button, and image. It should look very close to the attached image showing the lycos search page. You do not have to supply the event handlers for clicking or typing. The lycos image is also attached.  Lycos (with their image and background periodically changing) can be found at http://www.lycos.com/ . Submit your code.

Hint: It works best when you draw the image in a regular paint() method (after running the super JApplet paint() method). Also, checkboxes have a background around them so you may need to set the checkboxes background to the container's background.

Applet Viewer: ex1510.class Apple YCO Web Image Search Go get it! Applet started.

Explanation / Answer

import java.awt.Color;

import javax.swing.*;

public class AppletDemo extends JApplet {

/**
* Initializes the applet NewJApplet
*/
@Override
public void init() {

getContentPane().setBackground(Color.cyan);
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

/**
* This method is called from within the init() method to initialize the
* form. WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">   
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

setBackground(new java.awt.Color(153, 255, 255));

jLabel1.setIcon(new javax.swing.ImageIcon("C:\lycos.png"));
jLabel1.setText("jLabel1");

jCheckBox1.setBackground(new java.awt.Color(153, 255, 255));
jCheckBox1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jCheckBox1.setForeground(new java.awt.Color(0, 51, 255));
jCheckBox1.setText("Web");

jCheckBox2.setBackground(new java.awt.Color(153, 255, 255));
jCheckBox2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jCheckBox2.setForeground(new java.awt.Color(0, 51, 255));
jCheckBox2.setText("Image");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 51, 255));
jButton1.setText("Search");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addGap(10, 10, 10)
.addComponent(jCheckBox2))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)))
.addContainerGap(73, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1)))
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(88, Short.MAX_VALUE))
);
}// </editor-fold>   


// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote