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 / First Aid / September 2005

Tip: Looking for answers? Try searching our database.

Frame, Panel limit Resizing

Thread view: 
bherbst65@hotmail.com - 02 Sep 2005 15:38 GMT
Hi All,

Given an application as shown below, is there a way to keep the frame
and panel on that frame at the starting size so that the  user cannot
resize it after a "run" by using a mouse to grab of the corner of the
frame?

For instance this:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class NameAgeDataToTextArea
 extends JFrame {

 JTextField f1, f2;
 JTextArea t1;
 JButton b1;
 String x;
 String y;

 public static void main(String[] args) {
   NameAgeDataToTextArea NameAgeDataToTextArea1 = new
NameAgeDataToTextArea();
 }

 public NameAgeDataToTextArea() {

   super("Text Sample . . .");
   JPanel p1 = new JPanel();
   JPanel p2 = new JPanel();

   JLabel l1 = new JLabel("Name : ");
   JLabel l2 = new JLabel("Age : ");

   f1 = new JTextField();
   f1.setSize(80,40);
   f2 = new JTextField();
   f2.setSize(80,40);

   t1 = new JTextArea();
   t1.setSize(300, 300);
   b1 = new JButton("Click to Test");

   p1.setLayout(new GridLayout(2, 2));
   p1.add(l1);
   p1.add(f1);
   p1.add(l2);
   p1.add(f2);

   p2.add(b1);
   JScrollPane p3 = new JScrollPane(t1);
   this.getContentPane().add(p1, BorderLayout.NORTH);
   this.getContentPane().add(p2, BorderLayout.SOUTH);
   this.getContentPane().add(p3, BorderLayout.CENTER);

   setSize(250, 250);
   show();
   b1.addActionListener(new moveToArea());

 }
 class moveToArea
   implements ActionListener {
   public void actionPerformed(ActionEvent h) {
     x = f1.getText();
     y = f2.getText();
     t1.append("Name : " + x + " is "+ y + " years old"+
               "\n");
     System.out.println(x);
     JOptionPane.showMessageDialog(null, "Test Finished !",
                                   "Message . . .",
                                   JOptionPane.WARNING_MESSAGE);
     
   }
 }
}
Andrew Thompson - 02 Sep 2005 15:51 GMT
> Given an application as shown below, is there a way to keep the frame
> and panel on that frame at the starting size so that the  user cannot
> resize ...

<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Frame.html#setResizable(boolean)>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Sing out Hare Hare, dance the Hoochie Koo."
Led Zeppelin 'The Song Remains The Same'

bherbst65@hotmail.com - 07 Sep 2005 00:31 GMT
Hello Roedy,

I have downloaded your suggestion, but I have no appetite for the Sun
page that lists the  info in diagram format  and then the referenced
items named on your page

J:\j2sdk1.4.2_09\docs\api\java\awt\LayoutManager.html (s) are not
available.

So I  have looked at a similar program that is at:

http://cstsolaris.cst.nait.ab.ca/resources/tutorials/uiswing/layout/example-swin
g/index.html


The program is in two segments:
CustomLayoutDemo.java
and DiagonalLayout.java

But how to adapt that it to my program :(

While you have mentioned that this is not as detailed as the
standard approach, this looks like a formidable task to translate my
first offering above.
As I would guess each panel is a now a pane and the buttons get added
to a pane.
The layout preserves each of the items but which need to be added on
the pane, but how to activate the timer and getting the buttons to
initiate the movement are a real puzzle.

Bob
Andrew Thompson - 07 Sep 2005 02:42 GMT
> Hello Roedy,

I'm not Roedy.

> I have downloaded your suggestion, but I have no appetite for the Sun
> page that lists the  info in diagram format  and then the referenced
> items named on your page

Now I am not sure just how confused you are, since your words
are an accurate description of this page, (to which I linked)
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Frame.html#setResizable(boolean)>

Are you saying you have 'no appetite' for the JavaDocs?

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"I got a raw deal, so I'm lookin' for a steel.."
Tricky 'Black Steel'

bherbst65@hotmail.com - 07 Sep 2005 05:10 GMT
Andrew,

Sorry for the bad post.

I tried to remove it before you were able to read it after I discovered
my error, since I have two Q's going on this same/similar topic.

First, your link was very helpful. I appreciate it. The
rewrite kept things correctly lined up with
frame.setResizable(false);    I later discovered that I needed further
help because frame.setResizable(false);    was not on the table for
options. So I did a new post that Roedy reponded to. I placed my
response to him into this post, which I later withdrew.

Yes, I cannot "get with the format for the JavaDocs: hence no appetite"
of the Java Docs.

I can say, that for me, it easier to move toward finishing a project,
that I use the resource of "code completion tool" while using the IDE.
But not all IDE's have that feature and some programmers/instructors
feel that "code completion tool" may be a threat  to effective
learning.

I am using DrJava IDE, which does not have code completion, neither
does BlueJ. I have written a Java program that uses the OverView topics
that accesses the items within j2sdk1.4.2_08. Sort of a code completion
still abbreviated JavaDocs.
 
Again thanks for your help

Bob
Andrew Thompson - 07 Sep 2005 05:32 GMT
....
> Yes, I cannot "get with the format for the JavaDocs: hence no appetite"
> of the Java Docs.
>
> I can say, that for me, it easier to move toward finishing a project,
> that I use the resource of "code completion tool" while using the IDE.

..good luck with that.

> But not all IDE's have that feature and some programmers/instructors
> feel that "code completion tool" may be a threat  to effective
> learning.

Count me among them.

Please understand that requests for information here, that
could be obtained from the JavaDocs, generally go down like
a lead brick.

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Everybody's groovin' to their own song."
Josh Abrahams/Amiel Daemion 'Addicted to Bass'

bherbst65@hotmail.com - 07 Sep 2005 07:01 GMT
Andrew,
"generally go down like a lead brick."    well stated.

But its diagrammatic layout, is like doing the thing in
English class with English sentences, or some foreign language class,
which Java is, obviously.

I think, that to do diagramming, requires first a casual feel for the
language.
And unlike say Latin or Spanish, Java lacks the consistency of
term endings to denote the possible links in diagramming.
To me, it is a giant crap shoot of terms that border on sheer nonsense.
Even guessing does not get a logical possibility in some instances.
Java is emergent, like a person grasping for words to express a moment
of
emotion. "What shall we call this next term that will allow us to
do....."
And then there is the matter of capitalization. I got the right
word but Cool != cool ;

So why not have some help with a "code completion tool" in the guessing
game if one's memory is not the size of a expanding dictionary of
nonsense terms? I imagine that you have no trouble recalling every
moment in your life. Once read/heard/said... never forgotten.
What a blessing!

Bob
Andrew Thompson - 07 Sep 2005 07:41 GMT
> So why not have some help with a "code completion tool" in the guessing
> game if one's memory is not the size of a expanding dictionary of
> nonsense terms?

I do not see how an inability to 'find the right words' is any
less of a detriment in an IDE.  After all, in order to *code*
*complete*, the programmer must type *something*.

So what do *you* type that invokes code complete -
"next term that will allow us to do" ?

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"It's a never ending battle, for a peace that's always torn.."
Bob Dylan 'Shelter from the Storm'

bherbst65@hotmail.com - 08 Sep 2005 00:04 GMT
Hi Andrew,

I tried to write a concise explanation of what it is all about but
failed.

So rather than reinvent the wheel I searched  on msn topic:
jbuilder code completion

selecting:

Introducing JBuilder: Automating code development
found this to be a resonable explanation

http://info.borland.com/techpubs/jbuilder/jbuilder9_bea/introjb/envcoding.html#c
odeinsight


Bob

PS,
I had JBuilder9 but it overwhelmed my computer so that Jbuilder took 90
seconds to load the IDE and 90 seconds to run a simple app.
So I went to a lightweight IDE like DrJava and I also tried
BlueJ but the latter was very confusing. So I tossed it.

RH
Monique Y. Mudama - 08 Sep 2005 21:41 GMT
> On 6 Sep 2005 21:10:39 -0700, bherbst65@hotmail.com wrote: ....
>> Yes, I cannot "get with the format for the JavaDocs: hence no
[quoted text clipped - 5 lines]
>
> ..good luck with that.

Er, to the OP: It sure sounds like what you're saying is, "Rather than
taking the time to really understand the classes I'm using, I just try
some methods and see if they seem to work.  Then, if they seem to
work, I go on my merry way and hope nothing unexpected happens."

I hope that's not what you mean, but that's what it sounds like.

Code completion is a great tool to save your fingers and jog your
memory when it comes to an exact method name.  It shouldn't be a
replacement for understanding the libraries you're using.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

bherbst65@hotmail.com - 09 Sep 2005 03:03 GMT
monique,
Thanks for putting your abilities/successes into print for me to read.
And Ask smart questions reference, the html page reads more like
"don't bother me with such....."

Bob
Monique Y. Mudama - 09 Sep 2005 16:06 GMT
> monique,
> Thanks for putting your abilities/successes into print for me to read.
> And Ask smart questions reference, the html page reads more like
> "don't bother me with such....."

Bob, not sure what you mean by the first sentence.  I hope you'll read
over the link again and reconsider.  It's honestly not saying, "Don't
bother me."  It's saying "Don't bother a group unless you've done your
research and can provide enough information to show that you've
actually tried to address the problem yourself, and enough information
that someone else could actually hope to help you."  The rest is just
details.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

bherbst65@hotmail.com - 10 Sep 2005 15:27 GMT
monique,

well said , "...actually tried..."  Sometimes I think
that it is not knowing where to begin that prompts
neophytes to go to the "pillars of help". I find a lot of help on the
internet at msn.com starting with the first word "java" and then
listing what it is I need programmed.

I have nothing to add,

Bye,

Bob
Roedy Green - 11 Sep 2005 11:39 GMT
>I have downloaded your suggestion, but I have no appetite for the Sun
>page that lists the  info in diagram format  and then the referenced
>items named on your page
>
>J:\j2sdk1.4.2_09\docs\api\java\awt\LayoutManager.html (s) are not
>available.

at http://mindprod.com/jgloss/layoutmanager.html I give several
variants to that link including one on Sun's website:

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/LayoutManager.html

the link:

file://localhost/J:/Program%20Files/java/jdk1.5.0_04/docs/api/java/awt/LayoutManager.html

presumes you have  JDK 1.5.0_04 on your local hard disk J: drive.

J: drive is a virtual drive you set up with SUBST or drive mapping to
point to whereever you keep your JDK.  See
http://mindprod.com/jgloss/jdrive.html
for details.

There are similar J: links for  JDK 1.5.0_03 and JDK 1.4.2_09

The idea is you can browse offline and/or faster than you could the
Sun site.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Roedy Green - 11 Sep 2005 12:09 GMT
>I have downloaded your suggestion, but I have no appetite for the Sun
>page that lists the  info in diagram format  and then the referenced
>items named on your page

I have added links to the table of layouts to the corresponding Sun
docs and the Sun tutorials. I presume that is why you had "no
appetite".

If there is something else wrong with the page, at
http://mindprod.com/jgloss/layout.html

please let me know.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



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.