2.7, 3.7, 4.10
2.7
1.
255, 255, 255
0,0,0
0,0,255
128,128,128.
2.
Frames are used for housing the elements of the GUI, panels show colors, text or images, and layout managers determine how everything in multiple panels and frames are laid out.
3.
A border layout arranges panels in 5 places, top, left, right, bottom, and center.
4.
pane.setLayout( new GridLayout(5, 5));
pane.add(panel1)
pane.add(panel2)
pane.add(panel3)
…
pane.add(panel25)
3.7
1.
drawRect (int 45, int 20, int 100, int 50)
drawLine (int 20, int 20, int 100, int 100)
drawOval (int 100, int 100, int 50, int 50)
drawLine (int 50, int 50, int 200, int 200)
drawLine (int 200, int 200, int 100, int 100)
drawLine (int 100, int 100, int 50, int 50)
2. To draw a filled blue rectangle on a red background, you need to set the background of the panel with g.setColor (Color.red);
g.drawRect (x, y, z, a);
g.setColor (Color.blue)
3.
The center point of a panel can be found with the getHeight and getWidth functions.
4. color, font style, font size.
4.10
1.
String inputName = JOption.Pane.showInputDialog(“Enter your name” , ” “);
2.
JOptionPane.showMessageDialog( “My name is Will” /n “My address is 1, Two st., Threed.”);
3. parseInt and parseDouble processes the String based number into a double or an integer.
4. By letting the message box set its own size, the message would fit perfectly and not get cut off accidentally.
Loading...