java - New JFrame with TextArea -


i'm trying make new jframe contains textarea in java swing application. i've made jframe , assigned button making textarea inside new window speak seems bit more difficult imagined. app looks far: http://i.imgur.com/fyo3ggj.jpg

here's code:

public class userinterface extends jframe {  private jpanel contentpane; private jtextfield brugernavn;  string username = ""; string password = "";    private jpasswordfield adgangskode;  /**  * launch application.  */ public static void main(string[] args) {     eventqueue.invokelater(new runnable() {         public void run() {             try {                 userinterface frame = new userinterface();                 frame.setvisible(true);             } catch (exception e) {                 e.printstacktrace();             }         }     }); }  /**  * create frame.  */  public userinterface() {     setdefaultcloseoperation(jframe.exit_on_close);     setbounds(100, 100, 600, 400);     contentpane = new jpanel();     contentpane.setborder(new emptyborder(5, 5, 5, 5));     setcontentpane(contentpane);     contentpane.setlayout(null);      brugernavn = new jtextfield();     brugernavn.setbounds(6, 41, 134, 28);     contentpane.add(brugernavn);     brugernavn.setcolumns(10);      jlabel lblbrugernavn = new jlabel("brugernavn");     lblbrugernavn.setbounds(22, 20, 98, 16);     contentpane.add(lblbrugernavn);      jlabel label = new jlabel("adgangskode");     label.setbounds(22, 88, 98, 16);     contentpane.add(label);      jbutton btnfindmitskema = new jbutton("find mit skema");     btnfindmitskema.setbounds(6, 175, 150, 29);     contentpane.add(btnfindmitskema);      adgangskode = new jpasswordfield();     adgangskode.setbounds(6, 116, 134, 28);     contentpane.add(adgangskode);      jlabel titel = new jlabel("skema-checker elevplan v1");     titel.setfont(new font("lucida grande", font.plain, 20));     titel.setbounds(151, 11, 298, 28);     contentpane.add(titel);      final jframe licensinfoframe = new jframe("licens & info");       final string gpl = "elevplan checker version \n"                 + "copyright (c) 2013  philip jakobsen \n"                 + "this program free software: can redistribute and/or modify \n"                 + "it under terms of gnu general public license published \n"                 + "the free software foundation, either version 3 of license, or \n"                 + "(at option) later version. \n"                 + "this program distributed in hope useful, \n"                 + "but without warranty; without implied warranty of \n"                 + "merchantability or fitness particular purpose.  see \n"                 + "gnu general public license more details. \n"                 + "you should have received copy of gnu general public license \n"                 + "along program.  if not, see \n"                 + "http://www.gnu.org/licenses";        final string licensinfoframeheader = "licens & info";      jbutton btnlicensinfo = new jbutton("licens & info");     btnlicensinfo.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e) {             licensinfoframe.pack();             licensinfoframe.setvisible(true);              licensinfoframe.settitle(licensinfoframeheader);          }     });     btnlicensinfo.setbounds(6, 245, 150, 29);     contentpane.add(btnlicensinfo);      final textarea textarea = new textarea();     textarea.setbounds(162, 41, 428, 233);     contentpane.add(textarea);     textarea.setbackground(new color(255, 255, 255));     textarea.seteditable(false);      btnfindmitskema.addactionlistener(new actionlistener() {          @suppresswarnings("deprecation")         @override         public void actionperformed(actionevent e) {             // todo auto-generated method stub              username = brugernavn.gettext();             password = adgangskode.gettext();             string output = "";             new backend();             try {                 output = backend.main(username, password);             } catch (ioexception e1) {                 // todo auto-generated catch block                 e1.printstacktrace();             }             textarea.settext(output);          }     });    }     } 

in short, want add textarea jframe triggered button labeled "license & info". jframe works fine empty.

you should add text area jscrollpane.

futhermore, suggest use swing editors default netbeans swing editor these tools making interface coding easier , allow focus on important.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -