1. Create a Java application that will change the appearance of a string as shown in the picture.
2. The program will include a panel, label, checkboxes, radio buttons, and list.
3. To change color, set up 4 radio buttons in a button group. The colors are Black, Red, Green, and Blue to be selected. The default color is Black.
4. To change the font size, set up a list. The sizes are 18, 26, 38, and 56 to be selected. The default font is Verdana and 18 point.
5. To change the font style, set up 2 check boxes. The font styles are None, Bold or/and Italic to be selected. The default font style is None or Plain.
6. The sample string will be printed in the location (50, 300).
Thanks! :)
So here in this program as you have mentioned we have used the radio button for the color and check box for the font style and the list for font size.
Step-1
Program code:
import java.awt.*;
import java.awt.event.*;
public class Ex2 extends Frame implements ItemListener
{
Checkbox c1,c2,c3,c4,bold,italic; //intialize
variable
List l1=new List(4); //list for font size
Panel p=new Panel();
Label lab=new Label("SAMPLE"); // label of
string
CheckboxGroup color=new CheckboxGroup();
Ex2()
{
setLayout(null);
setSize(500,500); //size of
frame
l1.setBounds(310,60, 75,75); //size and location of list
l1.add("18");
l1.add("26");
l1.add("38");
l1.add("56");
l1.addItemListener (this);
add(l1);
c1=new
Checkbox("Black",true,color); //set checkbox for black color
c1.setBounds(10,30,100,20);
c2=new
Checkbox("Red",false,color);//set checkbox for red color
c2.setBounds(110,30,100,20);
c3=new
Checkbox("Blue",false,color);//set checkbox for blue color
c3.setBounds(210,30,100,20);
c4=new
Checkbox("Green",false,color);//set checkbox for green color
c4.setBounds(310,30,100,20);
bold=new Checkbox("Bold",false);
//set checkbox for bold font style
bold.setBounds(20,90,100,20);
italic=new
Checkbox("Italic",false); //set checkbox for italic font
style
italic.setBounds(120,90,100,20);
//adding all checkbox to
frame
add(bold);
add(italic);
add(c1);
add(c2);
add(c3);
add(c4);
//set layout and add label for
panel
p.setLayout(null);
p.add(lab);
lab.setBounds(0,0,300,50); //set
location for label
p.setBounds(10,140,400,400);
add(p);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
c4.addItemListener(this);
setVisible(true);
}
//set color,style and size for font
public void itemStateChanged(ItemEvent e)
{
Graphics g=getGraphics();
int var1=0;
if(c1.getState()==true)
{
lab.setForeground(Color.black);
}
if(c2.getState()==true)
{
lab.setForeground(Color.red);
}
if(c3.getState()==true)
{
lab.setForeground(Color.blue);
}
if(c4.getState()==true)
{
lab.setForeground(Color.green);
}
if(l1.getSelectedItem()=="18")
{
var1=18;
}
if(l1.getSelectedItem()=="26")
{
var1=26;
}
if(l1.getSelectedItem()=="38")
{
var1=38;
}
if(l1.getSelectedItem()=="56")
{
var1=56;
}
if(bold.getState()==true)
{
lab.setFont(new
Font("Verdana", Font.BOLD, var1));
}
if(italic.getState()==true)
{
lab.setFont(new
Font("Verdana", Font.ITALIC, var1));
}
if(bold.getState()==false
&& italic.getState()==false)
{
lab.setFont(new
Font("Verdana", Font.PLAIN, var1));
}
}
public static void main(String[] args) {
new Ex2();
}
}
Step-2
Output:
Step-3
Conclusion
So, here in the program i have mention the comments for each and every step
1. Create a Java application that will change the appearance of a string as shown in...
Java Using NetBean Write a program that can dynamically change the font of a message. The font name or font size can be chosen from combo boxes. The font name can be Dialog, DialogInput, Monospaced, Serif, or SansSerif. The font style can be selected as PLAIN, BOLD and/or ITALIC. Font myFont = new Font("Serif", Font.PLAIN, 12); message.setFont(myFont);
I need the whole and correct code Form1.cs Form1.Designer.cs Form2.cs Form2.Designer.cs program.cs everything in details Create C# project of type "Windows Forms Application titled your name: 1. Change the form title to "YourName_Smart Convertor". (2 points) 2. Change the background color of the form to Cornsilk.(2 points) 3. Change the form size to 470 X350 (2 points) 4. Add a picture to the form as shown in the figure below. (2 points) 5. Adjust the picture size to be as...
Simple java questions Q2.java: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Q2 extends JFrame { public static void createAndShowGUI() { JFrame frame = new JFrame("Lab"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("Sans-serif", Font.BOLD, 20); JLabel label = new JLabel("Enter a word"); label.setFont(font); JTextField textField = new JTextField(10); textField.setFont(font); JButton button = new JButton("Enter"); button.setFont(font); Font font1 = new Font("Sans-serif", Font.BOLD, 30); JCheckBox sansSerif = new JCheckBox("Sans-serif"); sansSerif.setFont(font1); JCheckBox serif= new JCheckBox("Serif"); serif.setFont(font1); Font font2 = new Font("Sans-serif", Font.ITALIC, 15); JRadioButton...
1. Why would you want to store usernames and passwords in the Web.Config file? 2. Create an ASP.NET page that uses a GridView to display the books from the Books table and a RadioButtonList of all the authors to allow the user to filter the books displayed. (Be sure to set the RadioButtonList's AutoPostBack property to True.) Make sure that the RadioButtonList displays only unique author names. In addition, because on the initial page load, the RadioButtonList will not have...
Using the following Java Class.... public class MicroWave { // Represent possible microwave heat selections private final int LOW = 1; private final int MEDIUM = 2; private final int HIGH = 3; // specifies the microwave heat selection(default is MEDIUM) private int heatSelection; // specifies whether the microwave is on private boolean on; private String color; public MicroWave(int heatSelection, boolean on, String color) { this.heatSelection = heatSelection; this.on = on; this.color = color; } ...
Create an external style sheet named Lab05.css. In this style sheet put the following styles: At the top of the style sheet, add the line: @charset "utf-8"; Add this comment: /* Lab 5 External Style Sheet - Brandon */ Style the h1 element with a background color of lightgreen and center the text. Style the p element with a blue text color and yellow background color. Style the p element of class .firstclass with a green text color. Style the...
Question 10 1 pts What will be the output of the following code: Scolors-arrayC" red", "green", "blue", "yellow"; foreach (Scolors as Svalue)t echo "$value<br />"; O red, green, blue, yellow O Nothing will appear red red green blue yellow Question 9 1 pts The following code block creates what kind of form input: <select name="age"> <option <option <option <option <option value-"0-17">Under 18</option> value="18-25">Between 18 and 25</option> value="26-45">Between 26 and 45</option> value="46-60">Between 46 and 60</option> value="60+">Over 60</option> </select> O Checkboxes Dropdown...
Game Development: Uno For this assignment you will be creating the game of Uno (See the accompanying pdf for the instructions of the game). Your version will adhere to all the rules except that only the next player can issue a challenge against the previous player in regards to penalties, and your games must have at least three (3) players and at most nine (9) players. To begin, you must create the class Card which contains: Private string field named...
1. Provide code to create a selection list named orderDay containing the values and option text SAT and SUN placed in the Weekend option group, and the option text MON, TUE, WED, THU, and FRI placed in the Weekday option group. 2. Provide code to create two radio buttons for the compType field with the values PC and Mac. Make PC the default value. 3. Kelsey has written the following code to create a data field for users to select...