I am making a Java program, but I am having a problem.
First, let me show you the code:
if (file.exists()){
for (String s : DFileLoader.getMethod(pathToSaveAs)){
if (s.startsWith("playerSendMessage%$%@@")){
pSmsgc.setSelected(true);
}else{
pSmsg.setEnabled(false);
}
}
if (DFileLoader.getMethod(pathToSaveAs).size() <= 0){
pSmsg.setEnabled(false);
}
}else{
pSmsg.setEnabled(false);
}
pSmsgc.setFont(fDisp);
pSmsgc.setBounds(new Rectangle(50, 135, 140, 30));
pSmsg.setBounds(new Rectangle(175, 135, 150, 30));
pSmsgc.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if (pSmsgc.isSelected()) pSmsg.setEnabled(true);
else pSmsg.setEnabled(false);
}
});
pane.add(pSmsgc);
if (file.exists()){
for (String s : DFileLoader.getMethod(pathToSaveAs)){
if (s.startsWith("playerSendMessage%$%@@")){
String[] d = s.split("%$%@@");
String text;
if (d.length <= 1) text = "";
else text = d[1];
pSmsg.setText(text);
}
}
}
pane.add(pSmsg);
Here are some details about this:
When I use "getMethod (path)", it just returns a list of lines (list), which includes every line of the TXT file.
pSmsgc is the JCheckBox, and pSmsg is the JTextField.
I have this when the window is not checked, the text field is grayed out, which works fine.
If there is a line in the file starting with "playerSendMessage% $% @@", the field will be checked to see if it works.
What does not work is where it sets the text of the text field to the second substring of this line.
, "playerSendMessage% $% @@Hello!". , , "Hello!"
, , .
, , . - ?