Complete the method below: Public int biggest Number InArray (int [] array) { //This method finds the largest integer value in the array //passed to the method and returns that value Create a class that is referenced in the following line of code: button.addActionlistener (new ButtonListener ()): Complete the method below: Public JPanel buildRadioButtonPanel () { //This method creates a JPanel adds two radio buttons named //”choice 1″ and “choice 2” with “choice 1” initially selected. //The panel is returned to the calling method // }
Expert Answer
36.)
int arr[] = new int[5];
System.out.println(“Enter elements of array:”);
for(int uu = 0; uu < n; uu++)
{
arr[uu] = s.nextInt();
}
maximum = arr[0];
for(int uu = 0; uu < n; uu++)
{
if(maximum < arr[uu])
{
maximum = arr[uu];
}
}
System.out.println(“Maximum value:”+maximum);
}
38.)
import javax.swing.*;
public class RadioBtn {
JFrame jf;
RadioBtn(){
jf=new JFrame();
JRadioButton rb1=new JRadioButton(“A) Male”);
JRadioButton rb2=new JRadioButton(“B) Female”);
rb1.setBounds(75,50,100,30);
rb2.setBounds(75,100,100,30);
ButtonGroup btn=new ButtonGroup();
btn.add(rb1);
btn.add(rb2);
jf.add(rb1);
jf.add(rb2);
jf.setSize(300,300);
jf.setLayout(null);
jf.setVisible(true);
}
public static void main(String[] args) {
new RadioBtn();
}
}
37.)
package changingcolor;
/**
*
* @author Akshay Bisht
*/
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ChangeColor extends JPanel implements ActionListener {
private JButton yloBtn = new JButton(“Yellow”);
private JButton bluBtn = new JButton(“Blue”);
private JButton redBtn = new JButton(“Red”);
private JButton greenBtn = new JButton(“Green”);
private JButton orangeBtn = new JButton(“Orange”);
public ChangeColor() {
add(yloBtn);
add(bluBtn);
add(redBtn);
add(greenBtn);
add(orangeBtn);
yloBtn.addActionListener(this);
bluBtn.addActionListener(this);
redBtn.addActionListener(this);
greenBtn.addActionListener(this);
orangeBtn.addActionListener(this);
}
public void actionPerformed(ActionEvent evt) {
Object src = evt.getSource();
Color col = getBackground();
if (src == yloBtn)
col = Color.yellow;
else if (src == bluBtn)
col = Color.blue;
else if (src == redBtn)
col = Color.red;
else if (src == greenBtn)
col = Color.green;
else if (src == orangeBtn)
col = Color.orange;
setBackground(col);
repaint();
}
public static void main(String[] args) {
JFrame jf = new JFrame(“Background Changer”);
jf.setSize(640, 480);
jf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container cont = jf.getContentPane();
cont.add(new ChangeColor());
}
}