Results 1 to 4 of 4
  1. #1
    rru96 is offline Senior Member
    Join Date
    Sep 2012
    Posts
    107
    Rep Power
    0

    Default Button not displaying text, only "..."

    I am just trying out JavaFX, but ran into what seems like a simple little issue. I am using Eclipse and started a new JavaFX project. All I am trying to do is get a Button to show up so that I can style it and learn how that aspect goes,.. but there seems to be an issue with the sizing perheps. Not exactly sure. All I am seeing is the "..." as if the button can't stretch to fill the text out.
    Any help on getting me started would be greatly appreciated. As you can see, I am able to style the button a little (just tried some simple stuff.) I just cant get it to display totally.

    Java FX Code:
    package application;
    	
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    
    
    public class Main extends Application {
    	
    	private int count = 0;
    	private Button btn;
    	private VBox vb;
    	
    	
    	@Override
    	public void start(Stage primaryStage) {
    		try {
    			vb = new VBox();
    			btn = new Button("Click Counter = " + count);
    			btn.setId("btn");
    			
    			vb.getChildren().add(btn);
    			
    			BorderPane root = new BorderPane();
    			root.getChildren().add(vb);
    			Scene scene = new Scene(root,800,800);
    			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
    			primaryStage.setScene(scene);
    			primaryStage.show();
    		} catch(Exception e) {
    			e.printStackTrace();
    		}
    	}
    	
    	public static void main(String[] args) {
    		launch(args);
    	}
    }
    And my CSS :
    Java FX Code:
    .root{
    	-fx-background-color: rgb(100,100,100);
    }
    
    #btn{
    	-fx-background-color: yellowgreen ;
    }

  2. #2
    jenifer is offline Member
    Join Date
    Jul 2014
    Posts
    1
    Rep Power
    0

    Default Re: Button not displaying text, only "..."

    ha ha ha

  3. #3
    DaveW is offline Member
    Join Date
    Jul 2014
    Posts
    8
    Rep Power
    0

    Default Re: Button not displaying text, only "..."

    set the minimum width for the button:

    Java FX Code:
    btn.setMinWidth(200);

  4. #4
    PiratePopcorn is offline Member
    Join Date
    Jul 2014
    Posts
    1
    Rep Power
    0

    Default Re: Button not displaying text, only "..."

    You could also get java to choose a size to fit everything in by changing line 29 to this
    Java FX Code:
    Scene scene = new Scene(root);

Similar Threads

  1. Replies: 0
    Last Post: 11-21-2013, 06:13 PM
  2. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  3. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  4. Adding "Choose File" button to applet
    By mju4t in forum Java Applets
    Replies: 1
    Last Post: 09-17-2009, 08:11 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •