Gluon JavaFX TextArea setEditable(false)

时间:2017-07-18 15:28:29

标签: ios javafx gluon-mobile

我有一个名为selectionLbl2的textarea,并且已被设置为无法使用selectionLbl2.setEditable(false);进行编辑当我将Gluon应用程序加载到iOS时,它仍然可编辑,忽略已设置的属性。有没有办法解决这个问题?

我偶尔会在模拟器上发生这种情况,并且几乎每个textarea都会使用普通的iPhone 6.文本通常是可滚动的,并且必须也是如此。

编辑:我的一个视图中的完整代码,build.gradle和错误的图片如下所示。 纹理的许多视图之一

package com.nopanicsselfhelper;
public class Relax extends View{

//initalise the variable textarea, the combo box to hold the switch belo and the list to hold the file

// Create a ComboBox for the variable text which is holding the steps
ChoiceBox<String> steps = new ChoiceBox<>();        
//ComboBox<String> steps = new ComboBox<>();
    List<String> lines = new ArrayList<String>();

public Relax(String name){
    super (name);



TextArea selectionLbl2 = new TextArea();
selectionLbl2.setPrefColumnCount(30);
selectionLbl2.setPrefRowCount(15);
    VBox layout = new VBox(10);
//call the stylesheet
    getStylesheets().add(WindowView.class.getResource("window.css").toExternalForm());
    //Create one buttons
    TextArea selectionLbl = new TextArea();
    selectionLbl.setEditable(false);      
    selectionLbl.setPrefColumnCount(30);
    selectionLbl.setPrefRowCount(13);

    //start the try catch block for reading the files
    try {
    String line;//initiate the string for the read file lines
        InputStream is = getClass().getResourceAsStream("/relaxation.txt");

    BufferedReader br = new BufferedReader(new InputStreamReader(is));//next buffered reader and file reader
//a While loop to read the document and attach it to the list.
        while ((line = br.readLine()) != null) {
            lines.add("\n\n" + line);
        }
                    //close the buffered reader
        br.close();
    }
    //catch any file not found exceptions
    catch (IOException e)
        {
            System.out.println(e.getMessage());
        }
    /*set the text of the textarea with parameters. The parameters are toString to turn the list into the String
    replace the commas created by the list with spaces then replace both [] to remove the list bars and
    replace the ; in the text with commas to create the standard formatting. The last parameter relies on the
    changing of comma in the main text document into ; as to preserve the desired formatting inside the text body.
    Set up an additional parameter of a substring to extract the main preamble of the relaxation technique*/
    selectionLbl.setText(lines.toString().replace('[', ' ').replace(']', ' ').replace('#', '"').replace('@', '\'').replace('+', '-').replace(',', ' ').replace(';', ',').substring(0, 5375));

    //start the switch and combo box integreation by setting the steps required
    steps.getItems().addAll("Step 1", "Step 2", "Step 3", "Step 4", "Step 5", "Step 6", "Step 7", "Step 8", "Step 9", "Step 10", "Step 11", "Step 12", "Step 13", "Step 14");
    // Select the first step from the list
    steps.getSelectionModel().selectFirst();

    // Add a ChangeListener to the ComboBox
    steps.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>()
    {
        public void changed(ObservableValue<? extends String> ov, final String oldValue, String newValue)
        {//start the main body of the switch
            switch(steps.getValue()) {//the relaxation exercise steps are coded directly into the switch to avoid excessive use of substrings
case "Step 1":
  newValue = "1. The muscles in your hands and forearms:\nYou tense these muscles by clenching your fists as tightly as you can.\n• Start now and count steadily to ten; notice the tension.\n• Relax your fists.\n• Notice the difference between tension and relaxation in your hands and forearms.\n• Keep focusing on the word relax.";
  break;

case "Step 2":
  newValue = "2. The muscles in your upper arms:\nYou tense these muscles by bending your arms at the elbows and trying to touch your wrists to your shoulders.\n• Start now and count steadily to ten; notice the tension.\n• Relax your arms.\n• Notice the difference between tension and relaxation in your upper arms.\n• Keep focusing on the word relax.";
  break;

case "Step 3":
  newValue = "3. The muscles in the back of your arms:\n" +
"You tense these muscles by straightening your arms as hard as you can.\n" +
"• Start now and count steadily to ten; notice the tension\n" +
"• Relax your arms.\n" +
"• Notice the difference between tension and relaxation in the back of your arms.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 4":
  newValue = "4. The muscles in your shoulders:\n" +
"You tense these muscles by shrugging your shoulders tightly into your neck.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your shoulders.\n" +
"• Notice the difference between tension and relaxation in your shoulders.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 5":
  newValue = "5. The muscles in your neck:\n" +
"You tense these muscles by pressing your head back as far as you can.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your neck.\n" +
"• Notice the difference between tension and relaxation in your neck.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 6":
  newValue = "6. The muscles in your forehead:\n" +
"You tense these muscles by raising your eyebrows as though enquiring.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your eyebrows.\n" +
"• Notice the difference between tension and relaxation in your forehead.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 7":
  newValue = "7. The muscles in your brows and eyelids:\n" +
"You tense these muscles by frowning and squeezing your eyes tightly shut.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your brows and eyelids.\n" +
"• Notice the difference between tension and relaxation in your brows and eyelids.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 8":
  newValue = "8. The muscles in your jaw:\n" +
"You tense these muscles by clenching your teeth as hard as you can.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your jaw.\n" +
"• Notice the difference between tension and relaxation in your jaw.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 9":
  newValue = "9. The muscles in your tongue and throat:\n" +
"You tense these muscles by pushing your tongue against the roof of your mouth.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your tongue.\n" +
"• Notice the difference between tension and relaxation in your tongue and throat.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 10":
  newValue = "10. The muscles in your lips and face:\n" +
"You tense these muscles by pressing your lips together tightly.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your lips.\n" +
"• Notice the difference between tension and relaxation in your lips and face.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 11":
  newValue = "11. The muscles in your chest:\n" +
"You tense these muscles by taking a deep breath and holding it\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your chest by breathing out.\n• Notice the difference between tension and relaxation in your chest.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 12":
  newValue = "12. The muscles in your stomach\n" +
"You tense these muscles by making your stomach muscles hard as though expecting a punch.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your stomach.\n" +
"• Notice the difference between tension and relaxation in your stomach\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 13":
  newValue = "13. The muscles in your hips and lower back:\n" +
"You tense these muscles by arching your back and clenching your buttocks.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your hips and lower back.\n" +
"• Notice the difference between tension and relaxation in your hips and lower back.\n" +
"• Keep focusing on the word relax.";
  break;

case "Step 14":
  newValue = "14. The muscles in your legs and feet:\n" +
"You tense these muscles by straightening your legs and pointing your toes down.\n" +
"• Start now and count steadily to ten; notice the tension.\n" +
"• Relax your legs and feet.\n" +
"• Notice the difference between tension and relaxation in your legs and feet.\n" +
"• Keep focusing on the word relax.\n" +
"Now completely relax for 10-15 minutes and let the feeling of relaxation spread throughout the whole of your body. Keep focusing on the word relax and enjoy that feeling of deep relaxation. Try and return to your daily activities keeping the body as relaxed as you can.";
  break;

default:
  newValue = "None";
  }
                //set the text of the initalised varible textarea to the value of the selection of the switch
            selectionLbl2.setText(newValue);
        }
    });
    //set the base parameters of the textareas
    selectionLbl2.setText("1. The muscles in your hands and forearms:\nYou tense these muscles by clenching your fists as tightly as you can.\n• Start now and count steadily to ten; notice the tension.\n• Relax your fists.\n• Notice the difference between tension and relaxation in your hands and forearms.\n• Keep focusing on the word relax.");
    selectionLbl2.setEditable(false);
    selectionLbl2.setEditable(false);
    //add everything to the layout       
    layout.getChildren().addAll(selectionLbl, steps, selectionLbl2);
    layout.setAlignment(Pos.CENTER);
    //centre the screen on the layout.
    setCenter(layout);

}
//override the view method to add te side menu and set the title.
@Override
protected void updateAppBar(AppBar appBar) {
    appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> MobileApplication.getInstance().showLayer(NoPanicsSelfHelper.MENU_LAYER)));
    appBar.setTitleText("The Muscle Relaxation");

}
}

build.gradle

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'org.javafxports:jfxmobile-plugin:1.3.6'

}
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
jcenter()
maven {
    url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'

}

}

mainClassName = 'com.nopanicsselfhelper.NoPanicsSelfHelper'

dependencies {
compile 'com.gluonhq:charm:4.3.2'

}

jfxmobile {

downConfig {

    version = '3.2.4'
    // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
    plugins 'display', 'lifecycle', 'statusbar', 'storage'
}

android {
    signingConfig {
        storeFile file("x")
        storePassword 'x'
        keyAlias 'x'
        keyPassword 'x'
    }        
    applicationPackage = 'com.nopanicsselfhelper.NoPanicsSelfHelper.java'
    manifest = 'src/android/AndroidManifest.xml'
    resDirectory = 'src/android/res'
}
ios {

    infoPList = file('src/ios/Default-Info.plist')
    forceLinkClasses = [
            'com.gluonhq.**.*',
            'javax.annotations.**.*',
            'javax.inject.**.*',
            'javax.json.**.*',
            'org.glassfish.json.**.*'
    ]
    iosSignIdentity = "x"
    iosProvisioningProfile = "x"
    arch = "arm64"
    }
}

Image one - Textarea retains focus over views Image two - Textarea is editable

0 个答案:

没有答案