This discussion is archived
2 Replies Latest reply: Feb 2, 2013 9:38 AM by AndreLopes RSS

I dont want that all Columns Resize because of the First line of that Colum

AndreLopes Newbie
Currently Being Moderated
I dont want that all Columns Resize because of the First line of that Column is too Big!!!!

This line of Code was suppose to fix that i guess...
But it isnt :
gp.getColumnConstraints().get(4).fillWidthProperty().setValue(false);
Heres the Whole Class:
package View;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 *
 * @author André
 */
public class CadastrarChatUsers extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        Group root = new Group();
        Scene scene = new Scene(root, 300, 250);
        scene.setFill(Color.CADETBLUE);
        primaryStage.setTitle("Cadastro de Usuários");
        
        //Cria o Layout
        GridPane gp = new GridPane();
        gp.setHgap(2);
        gp.setVgap(2);
        //Cria os Componentes:
        Text titleText = new Text("Cadastrar Usuários Do Chat");
        titleText.setFont(new Font("Verdana",18));
        titleText.setFill(Color.rgb(0,0,0));
        
        //Campo E-mail
        TextField emailTextField = new TextField();
        Label labelEmail = new Label("E-Mail");
        Tooltip toolTipEmail = new Tooltip("Insira um e-mail Válido");
        emailTextField.setTooltip(toolTipEmail);
        
        //Campo Password
        TextField passwordTextField = new PasswordField();
        Label labelPassword = new Label("Password");
        Tooltip toolTipPassword = new Tooltip("Insira uma senha Válida");
        passwordTextField.setTooltip(toolTipEmail);
        
        //Campo Nivel Usuario
        ComboBox<String> nivelUsuarioComboBox = new ComboBox<>();
        nivelUsuarioComboBox.getItems().addAll("Admin","Moderador","Publico","Banido");
        Label labelNivelUsuario = new Label("Nivel De Uso");
        Tooltip toolTipNivelUsuario = new Tooltip("Selecione O Nivel de Poder");
        nivelUsuarioComboBox.setTooltip(toolTipNivelUsuario);
        
        //
        
        
        
        gp.add(titleText,4,2);
        
        gp.add(emailTextField,3,5);
        gp.add(labelEmail,4,5);
        
        gp.add(passwordTextField,3,8);
        gp.add(labelPassword,4,8);
        
        gp.add(nivelUsuarioComboBox,3,11);
        gp.add(labelNivelUsuario,4,11);
        //
        root.getChildren().add(gp);
        
        primaryStage.setScene(scene);
        primaryStage.show();
        gp.getColumnConstraints().get(4).fillWidthProperty().setValue(false);
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}
And heres the Error

>
ant -f "D:\\Arquivos E Programas\\MeusProjetosJava\\CadastrarChatUsers" jfxsa-run
init:
Deleting: D:\Arquivos E Programas\MeusProjetosJava\CadastrarChatUsers\build\built-jar.properties
deps-jar:
Updating property file: D:\Arquivos E Programas\MeusProjetosJava\CadastrarChatUsers\build\built-jar.properties
Deleted 1 out of date files in 0 seconds
Compiling 1 source file to D:\Arquivos E Programas\MeusProjetosJava\CadastrarChatUsers\build\classes
compile:
Detected JavaFX Ant API version 1.2
Launching <fx:jar> task from D:\Arquivos E Programas\NetBeans_JavaSE_7.2.1_Portable\App\jdk\lib\ant-javafx.jar
Launching <fx:deploy> task from D:\Arquivos E Programas\NetBeans_JavaSE_7.2.1_Portable\App\jdk\lib\ant-javafx.jar
jfx-deployment:
jar:
run:
Exception in Application start method
java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at com.javafx.main.Main.launchApp(Main.java:642)
     at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Exception in Application start method
     at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
     at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
     at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
     at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
     at java.util.ArrayList.rangeCheck(ArrayList.java:604)
     at java.util.ArrayList.get(ArrayList.java:382)
     at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
     at View.CadastrarChatUsers.start(CadastrarChatUsers.java:77)
     at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
     at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
     at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
     at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
     at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
     at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
     ... 1 more
Java Result: 1
jfxsa-run:
CONSTRUÍDO COM SUCESSO (tempo total: 8 segundos)
  • 1. Re: I dont want that all Columns Resize because of the First line of that Colum
    AndreLopes Newbie
    Currently Being Moderated
    Anyone?

    I cant Find any Useful Information About that.
    Heres a Screenshot to Show whats happening :

    [http://imageshack.us/photo/my-images/705/columnfixlarguramx1024a.png/]

  • 2. Re: I dont want that all Columns Resize because of the First line of that Colum
    AndreLopes Newbie
    Currently Being Moderated
    Problem Solved!
    I inserted a GridPane inside the GridPane.
    package View;
    
    import Control.ControlCadastro;
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Pos;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.CheckBox;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.Label;
    import javafx.scene.control.PasswordField;
    import javafx.scene.control.RadioButton;
    import javafx.scene.control.TextField;
    import javafx.scene.control.Tooltip;
    import javafx.scene.layout.GridPane;
    import javafx.scene.paint.Color;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    import javax.swing.ButtonGroup;
    
    /**
     *
     * @author André
     */
    public class CadastrarChatUsers extends Application {
        
        ControlCadastro controlCadastro = new ControlCadastro(this);
        
        @Override
        public void start(Stage primaryStage) {
            Group root = new Group();
            Scene scene = new Scene(root,450,300);
            scene.setFill(Color.BLUEVIOLET);
            primaryStage.setTitle("Cadastro de Usuários");
            
            //Cria o Layout
            GridPane gp = new GridPane();
            gp.setHgap(2);
            gp.setVgap(2);
            
            GridPane gpCadastrar = new GridPane();
            gpCadastrar.setHgap(2);
            gpCadastrar.setVgap(2);
            
            //Cria os Componentes:
            Text titleText = new Text("Cadastrar Usuários Do Chat");
            titleText.setFont(new Font("Verdana",18));
            titleText.setFill(Color.rgb(0,0,0));
            
            //Campo E-mail
            final TextField emailTextField = new TextField();
            Label labelEmail = new Label("E-Mail");
            Tooltip toolTipEmail = new Tooltip("Insira um e-mail Válido");
            emailTextField.setTooltip(toolTipEmail);
            
            //Campo Password
            final TextField passwordTextField = new PasswordField();
            Label labelPassword = new Label("Password");
            Tooltip toolTipPassword = new Tooltip("Insira uma senha Válida");
            passwordTextField.setTooltip(toolTipPassword);
            
            //Campo Nivel Usuario
            final ComboBox<String> nivelUsuarioComboBox = new ComboBox<>();
            nivelUsuarioComboBox.getItems().addAll("Admin","Moderador","Publico","Banido");
            nivelUsuarioComboBox.setValue("Publico");
            
            Label labelNivelUsuario = new Label("Nivel De Uso");
            Tooltip toolTipNivelUsuario = new Tooltip("Selecione O Nivel de Poder");
            nivelUsuarioComboBox.setTooltip(toolTipNivelUsuario);
            
            //Dead File 
            CheckBox checkBoxDeadFile = new CheckBox("Arquivo Morto");
            Tooltip toolTipDeadFile = new Tooltip("Marque para indicar arquivo Morto");
            
            //Banned
            CheckBox checkBoxBanned = new CheckBox("Banido");
            Tooltip toolTipBanned = new Tooltip("Marque para Indicar Usuário Banido");
            
            //
            TextField registroTextField = new TextField();
            Tooltip toolTipRegistro = new Tooltip("Preencha o RE do usuário!");
            Label labelRegistro = new Label("Registro");
            
            //Botao de Cadastro de usuário
            Button cadastrarButton = new Button("Cadastrar");
            cadastrarButton.setOnAction(new EventHandler<ActionEvent>() {
               @Override
                public void handle(ActionEvent t) 
                {
                 
                 controlCadastro.cadastrarUsuario(emailTextField.getText(),passwordTextField.getText(),nivelUsuarioComboBox.getValue());
                }
            });
                    
                    
            Label labelCadastrar = new Label("Cadastrar");
            
            
            
            gp.add(titleText,4,2);
            
            gp.add(emailTextField,3,5);
            gp.add(labelEmail,4,5);
            
            gp.add(passwordTextField,3,8);
            gp.add(labelPassword,4,8);
            
            gp.add(nivelUsuarioComboBox,3,11);
            gp.add(labelNivelUsuario,4,11);
            
            gp.add(checkBoxDeadFile,3,14);
            
            gp.add(checkBoxBanned,3,17);
            
            gp.add(registroTextField,3,20);
            gp.add(labelRegistro,4,20);
            
            gp.add(gpCadastrar,3,26);
           
            gpCadastrar.add(cadastrarButton,0,0);
            gpCadastrar.add(labelCadastrar,1,0);
            //
            root.getChildren().add(gp);
            
            primaryStage.setScene(scene);
            primaryStage.show();
           
            //gp.getColumnConstraints().get(4).fillWidthProperty().setValue(false);
        }
    
        /**
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         *
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            launch(args);
        }
    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points