After learning JAVA for a month, I wrote a NotePad. Due to the time relationship, I had to perform practical training. Many functions were not added, but only simple interfaces and basic functions were implemented.
I will try again later ..
========================================================== ========================================================== =
/* Cat... the first Java program
*
*
* Copyright cat
*/
Import java. awt .*;
Import java. awt. event .*;
Import javax. swing .*;
Import javax. swing. event .*;
Import java. io .*;
Public class Notepad extends JFrame
{
String openFilePath;
String openFileName;
String title = "error message ";
Int type = JOptionPane. ERROR_MESSAGE;
Public Notepad ()
{
Super ("notepad ");
Final JTextArea text = new JTextArea ();
Text. setToolTipText ("Enter the content ");
// Interface
// Exit event
This. addWindowListener (new WindowAdapter ()
{
Public void windowClosing (WindowEvent e)
{
System. exit (0 );
}
});
// Simple layout
Final JPanel panel = new JPanel ();
Panel. setLayout (new GridLayout (1, 1 ));
Panel. add (new JScrollPane (text ));
This. getContentPane (). add (panel );
// Menu item
JMenuBar Mbar = new JMenuBar ();
This. setJMenuBar (Mbar );
JMenu file = new JMenu ("file ");
JMenu edit = new JMenu ("edit ");
JMenu help = new JMenu ("help ");
Mbar. add (file );
Mbar. add (edit );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service