3/5/2023 0 Comments Simple notepad in javaOn selecting “open” menu item, a file chooser will get opened which will show the open dialog after selecting a file a file reader and a buffered reader would read the file and set the text of the text area to the contents of the file.On selecting “save” menu item, a file chooser will get opened which will show the save dialog after selecting a file the filewriter(buffered writer) would write the contents of the text area to the file and close the file writer and buffered writer.On selecting the cut, copy, paste and print menu item the inbuilt functions of text area cut(), copy(), paste() and print() will be invoked.Here is how the functions of the menu will be invoked: We will add the text area to the frame using add function set the size of the frame to 500,500 using setSize(500,500) function and then display the frame using show function.We will add the menu items to the menu and menu to the menubar using add() function and we would add the menubar to the frame using addJMenuBar() function.We will add an action listener to all the menu items(using addActionListener() function) to detect any action. “Edit” has 3 menu items cut, copy and paste.The “File” option has 4 menu items new, open, save and print.We will add a text area and a menubar with three menu File, Edit, and Close.First, we will create a frame f titled “editor” and apply a metal look and feel and set an ocean theme in it.Removes the selected area from the text area and store it in clipboardĬopies the selected area from the text area and store it in clipboardįor more methods on JSwing components refer: ISRO CS Syllabus for Scientist/Engineer Exam. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |