I'm trying to add a JComponent based on what's in the .txt file for example
inside Component.txt
"[button]
buttonName
buttonText
Location(x,y)"
so how can i make a JButton named as buttonName, with a text of buttonText at the location x & y
here's my code:
private void btnRetrieveActionPerformed(java.awt.event.ActionEvent evt) {
String filename=txtFilename.getText()+".txt";
int x=1;
String text=null;
String bname=new String(),btxt;
double bsizex,bsizey,blocx,blocy;
try (BufferedReader fw = new BufferedReader(new FileReader(new File(filename))))
{
String s;
while((s = fw.readLine()) != null)
{
if(s.equals("[button]"))
{
String btnName = fw.readLine(); //read the next line after [a]
JButton button1=new JButton(btnName);
this.add(button1);
}
}
}catch(IOException e)
{
e.printStackTrace();
}
}