Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-08-2007, 07:03 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
Applet, To center text and To open I engage in a dialog in an Applet
1) I have a figure (for example, an ellipse) I must draw it with a text inside that it has to be trim.
If you don't understand imagine a diagram of states,in where each state has a name. How can I center the text?
Now I'm calculating the High/width of the figure and then I center it the problem is when there are more than one line

2) I want to open modal Dialogo, but I cannot create it because the constructor requests to me that the owner is a Frame or a Dialog and what I have is an Applet.

Some idea?

Marcus
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-08-2007, 07:04 AM
Member
 
Join Date: Jun 2007
Posts: 92
Daniel is on a distinguished road
With respect to the trim there is layout that is called borderlayout that divides the screen to you in north, south, east, west and to center

2: Applet extends of Panel who extends of Frame Container extends of Window that extends of Container ergo you cast to your Applet to Container, you send it and then if you want you can use as container or return to cast it

Daniel
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-08-2007, 07:08 AM
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
How can I center the text within the figure? I use it with the Applet to locate the bar of tools and the Canvas,
but i don' know how can I do to the figure, can you send me some code?

I did not prove what you said to me, but it does not seem to me a very elegant solution, in addition I do not believe that it works, because the Dialog() waits for a Frame or a Dialog, not a container, that is to say, it is necessary to see if the constructor uses the own methods of Frame or Dialog…

This is one of the bad ones of which Java is typed… (This in Smalltalk does not happen). I already solved it, simply I put the applet in an instance variable of a Frame, and what I do in the constructor of the Frame he is init(); start(); to the applet.

Eric
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-08-2007, 07:11 AM
Member
 
Join Date: Jun 2007
Posts: 95
Felissa is on a distinguished road
RE: Applet, To center text and To open I engage in a dialog in an Applet
Here is an example of applet
about the part 2 that you describe, I dont understand, send the code maybe I can help you.

greetings

Code:
import java.awt.*; import java.applet.Applet; public class AWT extends Applet { public void init() { setLayout(new BorderLayout()); add(new Button("North"), BorderLayout.NORTH); add(new Button("South"), BorderLayout.SOUTH); add(new Button("East"), BorderLayout.EAST); add(new Button("West"), BorderLayout.WEST); add(new Button("Center"), BorderLayout.CENTER); } }
Felissa
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-08-2007, 07:15 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
RE: Applet, To center text and To open I engage in a dialog in an Applet
That example I understand it… but setLayout() is a message of Applet. I need to center the text inside of a circle (or any other figure). How can I apply the Layout to a figure? Is there some method in Graphics2D that helps me to center the text? With respect to the solution that I found, and it implements was this:

Code:
import java.awt.*; import java.awt.event.*; class FrameLine extends Frame { private AppletDiagonal oneApplet; // One will be public static void main( String[] s ) { new FrameLine( 200, 230 ); } public FrameLine( int wide, int length ) { super(); // Constructor of Component // A listener adds itself who closed the application addWindowListener( new ListenerLine() ); // A diagonal applet is created oneApplet=new AppletDiagonal(); oneApplet.init(); oneApplet.start(); // The applet in frame puts add( oneApplet ); setSize(wide,length); // it fits frame setVisible(true); // it shows frame } // Nested class class ListenerLine extends WindowAdapter { //I rewrite the method of “when window is closed” public void windowClosing(WindowEvent e) { oneApplet.stop(); oneApplet.destroy(); System.exit(0); } } }
Marcus
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applet - reading text files packed into JAR file Java Tip Java Tips 0 02-08-2008 10:15 AM
How to prevent keyboard shortcuts when a dialog is open? sajad.ar SWT / JFace 0 01-21-2008 02:29 PM
Open "Save Page As" Dialog Box Anubha JavaServer Pages (JSP) and JSTL 0 12-12-2007 10:27 PM
First Applet HELP???? nvidia New To Java 0 08-13-2007 11:11 PM
Applet kapoorje Java Applets 0 07-24-2007 05:06 PM


All times are GMT +3. The time now is 01:25 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org