Framework. Java

Source: Internet
Author: User

Import javax. Swing. swingutilities;
Import java. AWT. borderlayout;
Import javax. Swing. jpanel;
Import javax. Swing. jframe;
Import java. AWT. dimension;
Import javax. Swing. jbutton;
Import java. AWT. rectangle;
Import javax. Swing. jlist;
Import javax. Swing. jtextarea;
Import javax. Swing. jtextfield;
Import java. Io .*;

Import javax. Swing. joptionpane;
Public class framework extends jframe {

Private Static final long serialversionuid = 1l;

Private jpanel jcontentpane = NULL;

Private jbutton jbutton1 = NULL;

Private jbutton jbutton2 = NULL;

Private jtextarea = NULL;

Private jtextfield = NULL;

/**
* This method initializes jbutton1
*
* @ Return javax. Swing. jbutton
*/
Private jbutton getjbutton1 (){
If (jbutton1 = NULL ){
Jbutton1 = new jbutton ();
Jbutton1.setbounds (New rectangle (556, 23, 60, 28 ));
Jbutton1.settext ("read ");
Jbutton1.addactionlistener (New java. AWT. event. actionlistener (){
Public void actionreceivmed (Java. AWT. event. actionevent e ){

String name = jtextfield. gettext ();

File Ss = new file (name );
Try {
Filereader A = new filereader (SS );
Bufferedreader BR = new bufferedreader ();

String S = Br. Readline ();
While (s! = NULL) // The value is not null.
{
Jtextarea. settext (s );
S = Br. Readline ();

}
BR. Close ();

}


Catch (ioexception E1 ){

Joptionpane. showmessagedialog (null, "file path error, please enter again ");

}
}
});

}
Return jbutton1;
}

/**
* This method initializes jbutton2
*
* @ Return javax. Swing. jbutton
*/
Private jbutton getjbutton2 (){
If (jbutton2 = NULL ){
Jbutton2 = new jbutton ();
Jbutton2.setbounds (New rectangle (559,249, 60, 28 ));
Jbutton2.settext ("save ");
Jbutton2.addactionlistener (New java. AWT. event. actionlistener (){
Public void actionreceivmed (Java. AWT. event. actionevent e ){
String name = jtextfield. gettext ();
String S = NULL;
File Save = new file (name );
Try {
S = jtextarea. gettext ();

// String Ss = S. Readline ();
// Bufferedreader sr = new bufferedreader (s );
Printwriter out = new printwriter (New filewriter (SAVE ));
If (! S. Equals ("")){
Out. println (s );
}
Out. Close ();

} Catch (ioexception E2 ){

Joptionpane. showmessagedialog (null, "file path error, please enter again ");
}





}







});
}
Return jbutton2;
}

/**
* This method initializes jtextarea
*
* @ Return javax. Swing. jtextarea
*/
Private jtextarea getjtextarea (){
If (jtextarea = NULL ){
Jtextarea = new jtextarea ();
Jtextarea. setbounds (New rectangle (2, 68,459,224 ));
Jtextarea. settext ("");
}
Return jtextarea;
}

/**
* This method initializes jtextfield
*
* @ Return javax. Swing. jtextfield
*/
Private jtextfield getjtextfield (){
If (jtextfield = NULL ){
Jtextfield = new jtextfield ();
Jtextfield. setbounds (New rectangle (22, 13,211, 44 ));
Jtextfield. settext ("");

}
Return jtextfield;
}

/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Swingutilities. invokelater (New runnable (){
Public void run (){
Shurushuchu thisclass = new shurushuchu ();
Thisclass. setdefaclocloseoperation (jframe. exit_on_close );
Thisclass. setvisible (true );
}
});
}

/**
* This is the default constructor
*/
Public framework (){
Super ();
Initialize ();
}

/**
* This method initializes this
*
* @ Return void
*/
Private void initialize (){
This. setsize (641,339 );
This. setcontentpane (getjcontentpane ());
This. settitle ("jframe ");
}

/**
* This method initializes jcontentpane
*
* @ Return javax. Swing. jpanel
*/
Private jpanel getjcontentpane (){
If (jcontentpane = NULL ){
Jcontentpane = new jpanel ();
Jcontentpane. setlayout (null );
Jcontentpane. Add (getjbutton1 (), null );
Jcontentpane. Add (getjbutton2 (), null );
Jcontentpane. Add (getjtextarea (), null );
Jcontentpane. Add (getjtextfield (), null );
}
Return jcontentpane;
}

} // @ Jve: Decl-Index = 0: Visual-constraint = "10, 10"

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.