GUI worksheet
1. Create a Java GUI app, implement the following criteria inside a main method 1) set up a visible frame with width 500, height 300; 2) frame title is "CSE205 Frame app"; and 3) setDefaultCloseOperation to EXIT_ON_CLOSE.
2. Continue working on previous question, create a button and a textfield (size:20) on to the same frame. What do you see?
3. Per previous question, create a panel object to organize the button and textfield in it. (create a JPanel object, add JButton and JTextField objects to the panel, add the JPanel object to the frame)
4. create 4 swing components (1 label, 1 textfield(size:15), 1 button and 1 textarea(10 rows and 30 columns)); when the button is clicked, the textarea will display the content of textfield.
public class MyFrame extends JFrame{
private JLabel myLabel;
private JButton myButton;
private JTextField myTextField;
private JTextArea myTextArea;
public MyFrame(){
public class MyGUIViewer {
public static void main(String args) {
JFrame myFrame = new MyFrame();
myFrame.setDefaultCloseOperation(myFrame
.EXIT_ON_CLOSE );
}
public JButton createPrintButton(String text){
myFrame.setSize(400,300);
myFrame.setVisible(true);
}
}
}
}
5. change the textarea to non-editable and background color as green.
6. Per assignment5, parseStringToProduct(String lineToParse) method will process lineToParse argument to split a big long string with certain pattern.
7. Please use proper formats to print out 2 digits after decimal point. What's the outcome when you print number1 with currency format?
double number1 = 3.1056;