Starting from:

$25

CS212- Object-Oriented Programming in Java: Lab 11 Solved

Aim: JFrames and TextAreas.

Create a project in Eclipse for Lab11, and import three files from the Z: drive Lab11 folder: HelloWorldSwing, HelloWorldMore, and Lab11.

Look at HelloWorldSwing, noticing the JFrame components used, and run the program. You should get a small JFrame with a label that says "Hello World!".

Now open the file HelloWorldMore. See that it is almost the same, but after the JFrame is set visible, an input dialog is opened for more text, and that text is put in the label. The JFrame is then setVisible again. Run the program and see that the text in the JLabel changes to whatever you type in.

Also observe that not all the text fits in the window. Now uncomment the statement frame.pack() and run it again. Notice that the pack method sizes the window so everything fits.

Now open the program Lab11 and read through it and get the idea. Run the program and see that the TextArea is empty and there is no sum calculated.

Complete the method readAndDisplayMatrix so that the matrix is displayed and the sum is printed. Change the title in the JFrame, too. For example:

More products