Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Swing and awt help needed!!!

Thread view: 
Connell Gauld - 01 Jan 2004 15:38 GMT
Hey,
I am having difficulty creating a user interface. There is a problem with
code below in that when it is compiled and run the CardLayout panel is
empty due to the face that the only card described is empty (I think).
I know that I am using a combination of Swing and awt.
Any help would be much appreciated.

Thanks
Connell

               // Card instruction label (at the top)
               JLabel two=new JLabel("<html>Please scan the barcode of the book you want
to lend or enter it into the box below.</html>");
               two.setVerticalAlignment(SwingConstants.TOP);

               // TextField for user entry
               barcode=new TextField(13);

               // This panel should arrange the label with "Barcode:" to the left of the
barcode TextField
               Panel m=new Panel();
               m.setLayout(new FlowLayout());
               m.add(new Label("Barcode:"));
               m.add(barcode);

               // This panel is a card in the CardLayout below which contains both the
instruction label (two) and the panel (m)
               Panel bcode=new Panel();
               bcode.setLayout(new BorderLayout());
               bcode.add("North", two);
               bcode.setLocation(0,0);
               bcode.setSize(width, height-50);
               bcode.add("South", m);

               // This is the panel which has the CardLayout
               Panel mpanel=new Panel();
               cl=new CardLayout();
               mpanel.setLayout(cl);
               mpanel.add("bc", bcode);
               mpanel.setLocation(0,50);
               mpanel.setSize(width, height-50);
               add(mpanel);
               cl.show(mpanel, "bc");
Andrew Thompson - 01 Jan 2004 23:00 GMT
> Hey,
> I am having difficulty creating a user interface. There is a problem with
> code below in that when it is compiled and run the CardLayout panel is
> empty due to the face that the only card described is empty (I think).
> I know that I am using a combination of Swing and awt.

That's the start of the problem, don't do it.

There are good reasons for using AWT
and good reasons for using Swing, but
they do not mix together well.

> Any help would be much appreciated.

Change the app to either AWT or Swing.

If you still have a problem with it, I
suggest you do not post an SSCCE
(not snippets) to the group..
http://www.physci.org/codes/sscce.jsp

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Andrew Thompson - 01 Jan 2004 23:02 GMT
...
> If you still have a problem with it, I
> suggest you do not post an SSCCE

..or rather.. 'suggest you _do_
post an SSCCE..'  ..Duh!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.