Results 1 to 5 of 5
- 06-08-2007, 06:03 AM #1
Member
- Join Date
- Jun 2007
- Posts
- 92
- Rep Power
- 0
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:cool:
- 06-08-2007, 06:04 AM #2
Member
- Join Date
- Jun 2007
- Posts
- 91
- Rep Power
- 0
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
- 06-08-2007, 06:08 AM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 111
- Rep Power
- 0
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
- 06-08-2007, 06:11 AM #4
Member
- Join Date
- Jun 2007
- Posts
- 95
- Rep Power
- 0
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
Felissa:pJava 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); } }
- 06-08-2007, 06:15 AM #5
Member
- Join Date
- Jun 2007
- Posts
- 92
- Rep Power
- 0
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:
Marcus:cool:Java 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); } } }
Similar Threads
-
Applet - reading text files packed into JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:15 AM -
How to prevent keyboard shortcuts when a dialog is open?
By sajad.ar in forum SWT / JFaceReplies: 0Last Post: 01-21-2008, 01:29 PM -
Open "Save Page As" Dialog Box
By Anubha in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-12-2007, 09:27 PM -
First Applet HELP????
By nvidia in forum New To JavaReplies: 0Last Post: 08-13-2007, 10:11 PM -
Applet
By kapoorje in forum Java AppletsReplies: 0Last Post: 07-24-2007, 04:06 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks