JOptionPane showInputDialog: text not displaying correctly

56 views
Skip to first unread message

Jan Flanders

unread,
Sep 2, 2012, 11:24:08 AM9/2/12
to aswing-...@googlegroups.com
I'm using JOptionPane but the text in the input textfield is partially outside the textfield/box

For example:
http://www.haxer.be/guests/aswing/aswingfont0.png

I tried fixing it by using :
pane.getInputText().getTextField().autoSize = flash.text.TextFieldAutoSize.LEFT;

But then I get this:
http://www.haxer.be/guests/aswing/aswingfont1.png

When I try to set the font with:
var v = new Verdana();
this.inputText.setFont(new org.aswing.ASFont(v.fontName, 12, false, false, false, true));

I get this:
http://www.haxer.be/guests/aswing/aswingfont2.png

What is the correct way to handle this, or how do I set the font and the size of that 'box' correctly?

Jan

骷髅小白

unread,
Sep 3, 2012, 4:23:30 AM9/3/12
to aswing-...@googlegroups.com
you should past nearly code, so we are easy to help u.
check the preferred size of components( getPreferredSize() )
i guess that the preferred size is not correct because it's text is null when be layouting.
try to set text to " " at earlist.

骷髅小白

unread,
Sep 3, 2012, 4:28:40 AM9/3/12
to aswing-...@googlegroups.com
And you should take control on component per se, not getText() etc., 
usually it does not take effects, especially at this case.

Jan Flanders

unread,
Sep 3, 2012, 12:42:41 PM9/3/12
to aswing-...@googlegroups.com
Hi  小白,
Thanks for your reply.
Here is a simple example to show my problem:

//------------------------
package;
import flash.display.Sprite;
import flash.Lib;
import org.aswing.BorderLayout;
import org.aswing.geom.IntDimension;
import org.aswing.JFrame;
import org.aswing.JTextField;

class InputTextTest extends Sprite
{
    public function new()
    {
        super();
       
        var tf = new JTextField();
        tf.setText("HELLO WORLD");

        var frame = new JFrame( this, "test" );
        frame.setSize(new IntDimension(200, 200));
        frame.getContentPane().append(tf, BorderLayout.NORTH);
        frame.show();
    }
    public static function main()
    {
        org.aswing.AsWingManager.setRoot(Lib.current);
        org.aswing.AsWingManager.initAsStandard(Lib.current);
        Lib.current.addChild(new InputTextTest());
    }
}
//------------------------

The result can be seen here: http://www.haxer.be/guests/aswing/aswingtextfield1.png

When I try to set another font with:
//------------------------
var v = new Verdana();//font is embedded with Flash CS5.5 and class name is Verdana
var font = new org.aswing.ASFont(v.fontName,false,false,false,true);
tf.setFont(font);
//------------------------
The result is this: http://www.haxer.be/guests/aswing/aswingtextfield2.png

Changing the order of setText and setFont doesn't make any difference.

Thanks in advance for any help on how to solve both issues.

Cheers,

Jan

iiley

unread,
Sep 3, 2012, 10:20:44 PM9/3/12
to aswing-...@googlegroups.com
 Lib.current.addChild( is useless,

You can try just 

atest = new InputTextTest();

because jframe.show() will make it be added into the stage root.

2012/9/4 Jan Flanders <adn...@gmail.com>



--
-iiley
Burstyx Studio Limited

Jan Flanders

unread,
Sep 3, 2012, 10:33:33 PM9/3/12
to aswing-...@googlegroups.com


On Tuesday, September 4, 2012 4:20:45 AM UTC+2, iiley Chen wrote:
 Lib.current.addChild( is useless,
 

iiley

unread,
Sep 4, 2012, 10:26:11 PM9/4/12
to aswing-...@googlegroups.com
i see, the font is strange at your platform... have no idea for this, since it works fine for me with PC+AS3.

is there any one familiar with haXe can help?

2012/9/4 Jan Flanders <adn...@gmail.com>

chunbiao huang

unread,
Sep 5, 2012, 6:54:39 AM9/5/12
to aswing-...@googlegroups.com
Looks wrong code, I will repair

2012/9/5 iiley <iiley...@gmail.com>

chunbiao huang

unread,
Sep 5, 2012, 7:03:05 AM9/5/12
to aswing-...@googlegroups.com
font bug check in svn    


2012/9/5 chunbiao huang <huangc...@gmail.com>

chunbiao huang

unread,
Sep 5, 2012, 7:04:56 AM9/5/12
to aswing-...@googlegroups.com
 The layout size issues still repair

2012/9/5 chunbiao huang <huangc...@gmail.com>

Jan Flanders

unread,
Sep 5, 2012, 12:09:15 PM9/5/12
to aswing-...@googlegroups.com


On Wednesday, September 5, 2012 1:03:06 PM UTC+2, paling wrote:
font bug check in svn    


2012/9/5 chunbiao huang <huangc...@gmail.com>
Looks wrong code, I will repair

Many thanks for fixing it! It works now. :)

A bit bit off topic:
Could you please not put any classes in the class path that are not part of the aswing library?
Main is a very common name to use as a 'main' class for a project.
You have a Main.hx in trunk and every time I update the svn I must delete this file because my 'main application file/class' is also called Main (and yours takes precedence).
Maybe it's better to create a 'demo' folder and put your Main.hx, AsWingFlash.hxproj, compile.hxml, run.bat, bin folder etc. in there?

Thanks again!

Jan

chunbiao huang

unread,
Sep 6, 2012, 1:54:11 AM9/6/12
to aswing-...@googlegroups.com
text  size   bug check in svn      At revision: 1264
 good  idea,   classification    next   time


2012/9/6 Jan Flanders <adn...@gmail.com>

Jan Flanders

unread,
Sep 6, 2012, 10:03:54 AM9/6/12
to aswing-...@googlegroups.com


On Thursday, September 6, 2012 7:54:12 AM UTC+2, paling wrote:
text  size   bug check in svn      At revision: 1264
 
Thank you for fixing this issue as well. The text is no longer 'cut off' at the bottom and displays correctly now. Looks good!

Cheers,

Jan
Reply all
Reply to author
Forward
0 new messages