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 / General / November 2006

Tip: Looking for answers? Try searching our database.

This is why I dont use layout managers

Thread view: 
Justin - 29 Nov 2006 21:23 GMT
heres the code i am using...

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.font.*;
import java.text.Collator;
import javax.swing.event.*;
import java.util.Date;
import java.text.DateFormat;

class ExamKnee2 extends JDialog{

   JLabel textKneeSocietyScore;
   JButton btnOK;

   ExamModuleFollowups followup;
   ExamModuleExamKnee examKnee;
   ExamModuleActivity activity;
   ExamModulePainGrade painGrade;
   ExamModuleSymptoms symptoms;

   Color bgColor = Color.YELLOW;

   final int WIDTH = 830;

   AccessConnection dataConnection = new AccessConnection();

   public String sSN, side;

   JPanel panel;
   JScrollPane scroller;

   public ExamKnee2(String stringSide, String stringSSN, String
timePain) {

       side = stringSide;
       sSN = stringSSN;

       setModal(true);
       Container pane = this.getContentPane();
       this.setAlwaysOnTop(true);
       pane.setLayout(new BorderLayout());
       //pane.setLayout(null);

       setDefaultCloseOperation(DISPOSE_ON_CLOSE);
       setBounds(300,0,WIDTH,600);

       addWidgets();

       setVisible(true);
       validate();

   }

   public void addWidgets(){
       panel = new JPanel();
       panel.setLayout(new BorderLayout());
       panel.setSize(400, 1000);

       JLabel testing = new JLabel("testing1");
       panel.add(testing, BorderLayout.PAGE_START);

       JLabel testing2 = new JLabel("testing2");
       panel.add(testing, BorderLayout.CENTER);

       JLabel testing3 = new JLabel("testing3");
       panel.add(testing2, BorderLayout.PAGE_END);

       scroller = new JScrollPane(panel);
       scroller.setSize(100,100);
       add(scroller, BorderLayout.LINE_START);

   }

   public static void main(String args[]){
       ExamKnee2 examKnee = new ExamKnee2("Right", "123-45-6789", "2
weeks");
   }
}

All I am trying to do is get the scroll pane to scroll vertically.
Will not do it.  This is really pissing me off.  According to the java
tutorial (found here
http://java.sun.com/docs/books/tutorial/uiswing/layout/border.html)
the "testing" labels should be displayed horizontally.  Secondly, I
should be able to scroll around to view the 3rd testing label but I
cant.  I know theres more problems but im a lil piissed off right now
becuase this isnt working.  please help...
A. Bolmarcich - 30 Nov 2006 00:14 GMT
> heres the code i am using...
>
[quoted text clipped - 61 lines]
>         JLabel testing2 = new JLabel("testing2");
>         panel.add(testing, BorderLayout.CENTER);

Instead of the above line, did you intend to write

       panel.add(testing2, BorderLayout.CENTER);

>         JLabel testing3 = new JLabel("testing3");
>         panel.add(testing2, BorderLayout.PAGE_END);

Instead of the above line, did you intend to write

       panel.add(testing3, BorderLayout.PAGE_END);

>         scroller = new JScrollPane(panel);
>         scroller.setSize(100,100);
[quoted text clipped - 16 lines]
> cant.  I know theres more problems but im a lil piissed off right now
> becuase this isnt working.  please help...

What may be really pissing you off is that Java does what you wrote,
not what you meant to write.

With the code as written, the "testing" labels should be displayed
vertically (once you add all three instead of adding and re-adding
"testing" and then adding "testing2").  To get the scroll pane to
have a vertical scroll bar, you have to reduce the height of the
window so that there is not enough height to show all the "testing"
labels at the same time.

Also, you may have meant to add the scroll pane to the CENTER instead
of to the LINE_START.


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.