How to obtain the button size created by JavaFX ?

Here the codes:
ToggleButton tb1 = new ToggleButton("Minor");
System.out.println(tb1.getWidth());
System.out.println(tb1.getPrefWidth());
The output is :
0.0
-1.0
But in Swing,
JButton tb1 = new JButton("Minor");
System.out.println(tb1.getPrefferedSize().width);
The output is 109 which is I want to obtain.
How can we get the size of the button created by "new Button() ..." as in Swing ? I strongly hope the answer is yes, because I find that function in Swing very useful.
Thanks
(Note: I discover that after the code "primaryStage.show()", we can get the correct button width by using button.getWidth(), but when we use button.getPrefWidth() we still get -1.0, the value undesired.)

Thanks for your prompt. I have been read that discussion. But their responses are not very appropriate for me.
Rectangle rect = new Rectangle(); 
rect.widthProperty().bind(tb1.widthProperty().add(tb2.widthProperty())); 
is what I want to obtain.
And
final Button button = new Button("Play"); 
final Scene snapScene = new Scene(button); 
snapScene.snapshot(null); 
System.out.println(button.getWidth()); 
is also a very good solution for me.

Similar Messages

  • How to change the button size of Calendar prompt

    I want to change the button size in Calendar prompt. How to change it?
    Thank you!

    I think it is not necessary to modify the Calendar button size.
    The Calendar button actual size is 20X20.
    But the gif file which is used by Calendar button is not filled by icon.
    It seems that the height is smaller than the other buttons.
    Edited by: user12291797 on Dec 3, 2009 12:59 AM

  • Please help me...Why the buttons size change?

    Hi!!!
    I have a doubt with respect the buttons size, because with the following code i show 2 buttons that comprise the whole panel in a row:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class x1 extends JApplet {
    public void init() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel jp= new JPanel();
    jp.setBorder(new EmptyBorder(10,10,10,10));
    jp.setLayout(new GridLayout(1,2,5,5));
    JButton b1= new JButton("Button 1");
    jp.add(b1);
    JButton b2= new JButton("Button 2");
    jp.add(b2);
    contentPane.add(jp,BorderLayout.NORTH);
    But when i do other separated class with the buttons creation, my buttons appear in the center without comprising the whole panel in a rengl�n.....why happen it?.....i would like to obtain the same effect like the first code....how can i reach that?.....
    This is the applet code when i do the separated class with the buttons creation applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class x2 extends JApplet {
    public void init() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(new jbuttons(),BorderLayout.NORTH);
    class jbuttons extends JPanel {
    public jbuttons() {
    JPanel jp= new JPanel();
    jp.setBorder(new EmptyBorder(10,10,10,10));
    jp.setLayout(new GridLayout(1,2,5,5));
    JButton b1= new JButton("Button 1");
    jp.add(b1);
    JButton b2= new JButton("Button 2");
    jp.add(b2);
    add(jp);
    Could somebody help me please?.....Thanks in advance....
    Mary

    Mary,
    Your second class (jbuttons) actually contains TWO panels: "this" as well as the jp panel. The jp panel is in this case unnecessary.
    Although the sizing of the jp panel is set correctly, the "this" panel is still set to "flow" layout and will not give you the desired result.
    Try rewriting your second class this way:
    class jbuttons extends JPanel {
    public jbuttons() {
    this.setBorder(new EmptyBorder(10,10,10,10));
    this.setLayout(new GridLayout(1,2,5,5));
    JButton b1= new JButton("Button 1");
    this.add(b1);
    JButton b2= new JButton("Button 2");
    this.add(b2);
    Hope this helps!
    Steve

  • How to set the frame size?

    Hi,
    Can some one show me how to set the frame size in this program? History: I have created a window and added a button but its to small. So I want to increase the size of the frame to at least 600X400 pixel.
    private static void showGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("ButtonDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            Main newContentPane = new Main();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }It would be nice if you could show me how to do it.
    Thank you very much for reading this.

    Challenger wrote:
    Simply adding
    frame.setSize(new Dimension(600,400));to the end of your code should work perfectly.Or, if you want to do it correctly, .setPreferredSize() on your frame before you .pack() it. The default layout manager for JFrame is BorderLayout, which uses the preferredSize of each component to calculate sizes during the .pack() call.

  • In OBIEE 11G, how to get the special parameter created by JAVA?

    Hi Experts,
    In OBIEE 11G, how to get the special parameter created by JAVA?
    For example:
    In JAVA , it has set one parameter named 'test'.
    So how to get the parameter in filter area in OBIEE?

    Hi Kobe,
    No P2 holds the parameter name like PresentationTable.ColumnName, in your form you may go for complete name or just column name and before submitting the form you can define the Action url.
    I would suggest to read section 6.3.2.1.
    ex:
    <SCRIPT LANGUAGE="JavaScript">
    changeAction(url) {
    var TestVar = form.inputbox.value;
    document.this_form.action="saw.dll?Go&Path=/Shared/Test/SB2&Action=Navigate&P0=1&P1=like&P2=Customers.Region&P3="+TestVar;
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>
    <INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
    <INPUT TYPE="button" NAME="button" Value="Click" onClick="changeAction(this.value)">
    </FORM>
    If helps pls mark.
    Edited by: veeravalli on Oct 24, 2012 10:25 AM

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Hi, I am using Indesign CS6, How to set the page size in Inches.

    Hi, I am using Indesign CS6, How to set the page size in Inches.

    All fields in InDesign can be entered in any measurement system. So, if you want to make an 8"x10" document and go to File>New Document and the window looks like this:
    …you can type either 8 in or 8" into the Width field like this:
    …and when you move to the next field, it will convert the eight inches into the equivalent number in the unit of measure that it is using at the moment, like this:
    … (203.2 milimeters is the same as 8 inches). You can also enter a different measurement unit into other fields once the file is created, such as the width or height of a frame, or the position of an object in the X and Y coordinates.
    If you would rather just work in inches instead of having to type the inches mark or abbreviation, go to InDesign>Preferences>General and select the Units & Increments tab. There you will see Ruler Units for Horizontal and Vertical at the top of the window. Set them to Inches and all of the fields will display in inches. If you do that to an open document, you will change the unit of measure for that document. If you do it while no documents are open, it will change the unit of measure for any new documents you create. To change the unit of measure for existing documents, you will have to open each and make the change.

  • How to change the font size of text and case in smartforms

    hi,
       could any one explain how to change the font size of text in smartforms. ex. previously i had taken P4 left aligned and C6 but now i want to decrease the font without making it bold. pl......... guide me
       secondly the value which are coming from tables are upper case but i need lower case. pl. guide
    thanking u

    check out the smart styles...create a font of ur size n use.
    Define the paragraphs & character formats using SMARTSTYLES & use them in your smartform.
    You have to give the smartstyle name in the Form attributes-->Output options for the formats to be used in your smartform.
    You can define font size in Smartform Style.
    Smartform Styles > Charcterformat> Font --> size.
    to load the font to SAP server chk this
    Re: Adding a new font for SAPscript/SMARTFORM output
    Regards
    Vasu

  • How to change the font size of text element in smartform

    Hi
    i want to know how to change the font size of text element in smartform
    regards
    Gincy

    Hi
    You can create Smartstyles, in which you can define paragraph formats for texts and character formats for character level changes.
    Paragraph format ---> alignment, font size etc
    character format for ---> superscript, subscript.
    After creating, in your smartform, there will be a option in the text element to enter a style.
    You give the created style and you can use the paragraph and character formats i that style.
    Hope this is clear..
    Regards
    Sekar

  • How to change the font size of Text Box  Properties Appearance tab into 2 decimal digit.

    How to change the font size of Text Box  Properties Appearance tab into 2 decimal digit. I am uanble to modify it to 5.38 pt for example. Its only allowing to 1 decimal place.

    Click on each field and the choose Properties from either File menu (or if on Mac hold dow mouse button until context menu appears choose properties)
    go to Font
    choose desired size and type font,you can choose to make this the default.
    Do this with each field.
    Or if you have a lot of fields:
    while one is selected select all of them
    then go to fonts in properties
    change Font and size and make default.

  • How to change the font size of Text box tool ?

    How to change the font size of Text box tool ?
    I am using Acrobat PDF 6.0
    Tools > Advanced Commenting > Text Box Tool
    I need to know how to change the font size. The default font size is too big.
    let me know
    Thanks

    I do not have AA6 available right now (I can check at home this evening). I am also using AA Pro, not Std. In AA7, there is a text box tool that is a commenting tool. When I started typing, a properties toolbar came up that had the font size and such. I haven't figured out how to get the toolbar after the fact. In AA8, I selected the text box tool and then went to view and selected the properties bar (the font size and all showed then), or use Ctrl-E when editing the text. I have not been able to figure out how to edit the text in a text box after you have created it - think it is a mental block right now. Bill

  • How to increase the attachment size of a portal

    Hi,
    We have a portal developed using JSP.
    We have an option for attaching files. Now the maximum limit is only 5 MB. So we thought of using FTP so that we can increase the attachment limit. But we are not able to attach files more than 1 MB.
    Could you please help us in resolving this. Any idea how to increase the attachment size limit?
    Thanks in advance

    Hi,
    See what Patrick Yee has posted.
    how to create own page format in smartforms immmedia
    Svetlin

  • How to modify the blob size, or how to set the size?

    i want to know how to modify the blob size, or how to set the size?
    what's the default size of blob?
    Thanks in advance.

    Blob datatype can contain binary data with a maximum size of 4 GB.
    when you enter 10kb file, the database will only use 10kb to store the file (depending on block size etc)
    if you want to modify the blob size, you may do like this:
    SQL> create materialized view t_mv refresh fast on commit
    2 as select id, dbms_lob.getlength(x) len from t;
    Materialized view created.
    SQL> alter table t_mv add constraint t_mv_chk check (len < 100);
    Table altered.

  • How to reduce the barcode size

    hi
    How to reduce the barcode size in smartforms
    Thanks & Regards
    krishna rao

    Hai,
    Go to se73
    select system barcodes radi button
    click change button
    it wil moves to another screen .In that screen it wil show all Bar codes.
    select u r barcode from the list  click and change button.
    in this way u wil change barcode size.
    Reagards.
    kishore ale

  • How to increase the column size of Alv tbale

    Hi All,
    I created an Alv table to display the content of my database table. In one of the column the entire data from my database are not displayed the last few characters are missing. The data type for that column in the database is char. Can any one help me how to increase the column size in my Alv table or any suggestions to resolve this issue.

    Hi Vadiv,
    Try with this..
    DATA: LR_IF_CONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
    LR_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,
    LR_CMDL TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
    LR_TABLE_SETTING TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.
    LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV( ).
    IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
    LR_CMP_USAGE->CREATE_COMPONENT( ).
    ENDIF.
    " get reference to the ALV model
    LR_IF_CONTROLLER = WD_THIS->WD_CPIFC_ALV( ).
    LR_CMDL = LR_IF_CONTROLLER->GET_MODEL( ).
    LR_TABLE_SETTING ?= LR_CMDL.
    " Set column width
    DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.
    LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'PERNR' ).
    LR_COL->SET_WIDTH( '70' ) .
    LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ENAME' ).
    LR_COL->SET_WIDTH( '100' ) .
    LR_TABLE_SETTING->SET_FIXED_TABLE_LAYOUT( ABAP_TRUE ).
    You can refer to webdynpro component SALV_WD_TEST_TABLE_PROPS. Go to the view TABLE and look inside the method SET_COLUMN_SETTINGS. I hope this will help you.
    Cheers,
    Kris.

Maybe you are looking for

  • Lock ups and crashes

    I've been having this problem off and on now for awhile. My pc will just lock up and a message comes up "A program caused this to happen" Then the pc will auto restart page. The thing about it is it's doing it more and more. There's got to be somethi

  • Report for no of invoices sent for print

    Hi Gurus, Report is needed that indicates how many invoices should be printed daily from SAP.  we are printing and mailing invoices; report should detail how many need to be mailed vs. were sent edi/faxed. How i can achive this ? Regards, Sujit Shind

  • Using Qmaster with DVD Studio Pro OR Qmaster requires FCP on all machines?

    Greetings everyone, After a few days of tinkering I've finally managed to set up a managed cluster. However, I have a problem (surprise, surprise). When I submit a job to the cluster, Final Cut Pro suddenly opens up on all of the computers being used

  • Can two remote workgroups sync their XServes?

    Our company has two main physical locations (Midwest and Pacific Northwest), each with its own xServe and LAN.  Our employees collaborate on projects between the two offices. Frequently, I hear complaints that someone is looking for a file but doesn'

  • \n in result handler xml

    When I extract the following from result handler xml, the \n display as \n in TextArea. How can I extract from result so they are actually line breaks? <EmailText>Thank you for reporting this to us.\nPlease include the city you are in.</EmailText> pr