Archive for April 23rd, 2008
4.10
1.import javax.swing .JOptionPane;
public class Name
public static void main (String[ ] args){
string inputStr = JOptionPane.ShowInputDialog (“Enter your name, ” ” ” )
if (inputStr == null)
return;
2.
3.If the expected input is a number, one other thing must be done before it can be processed. The dialog box returns a string of digits, which must be converted to an int or a double. THe methods Integer.parseInt(aString) and Double.parseDouble (a String) accomplish this for intergers and floating number points.
4.This alternative is useful when we want the size of each panel to be exactly the size we want.
Add a comment April 23, 2008
3.7
1.a)g.drawRect (45, 20, 100, 50)
b)g.drawLine (20, 20, 100, 100)
c)g.drawCir (100,100,50)
d)g.drawTri (100,100,50,50,200,200)
2. The program uses a modified version of the code for the ColorPanel class. Then added a paintComponent method that draws a blue rectangle containing a red text message when the window opens and whenever it is refreshed.
3. The method getWidth() and getHeight () return the current width and height of a panel. If these methods are called before the window is opened, they return a default value of 0.
4. Color, Font style , Font size and Font name.
Add a comment April 23, 2008