I am trying to make a gui that i will be able to add ips to and remove them then if i hit the button it it writes the ip to a .txt then if i hit anorther button it also writes to another .txt that has this format and it replaces the ip in "lastServer" (aka) 15th row
music:0.0
sound:0.014084507
invertYMouse:false
mouseSensitivity:0.5
viewDistance:0
guiScale:0
bobView:true
anaglyph3d:false
advancedOpengl:false
fpsLimit:1
difficulty:2
fancyGraphics:true
ao:true
skin:Default
lastServer:192.168.1.1
key_key.forward:17
key_key.left:30
key_key.back:31
key_key.right:32
key_key.jump:57
key_key.sneak:42
key_key.drop:16
key_key.inventory:18
key_key.chat:20
key_key.fog:33
import java.awt.FlowLayout; import javax.swing.JFrame; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JOptionPane; public class chsv extends JFrame{ private static final long serialVersionUID = 1L; public JTextField pi; public JButton in; public JLabel item1; public String itme5; public chsv(){ super("~~~America Fuck Yea~~~"); setLayout(new FlowLayout()); item1= new JLabel("The ips"); add(item1); JTextField pi = new JTextField("enter ip", 20); add(pi); JButton in =new JButton("add"); thhnd hnd = new thhnd(); pi.addActionListener(hnd); in.addActionListener(hnd); } public class thhnd implements ActionListener{ public void actionPerformed(ActionEvent event){ String item4 = ""; if(event.getSource()==pi){ item4=String.format("field 1: %s", event.getActionCommand()); JOptionPane.showMessageDialog(null, item4); class wrt { public void main(String[] args) throws IOException{ BufferedWriter sn = new BufferedWriter(new FileWriter("/Users/Kingkong/Desktop/ff.txt")); String fn = ""; sn.write(fn); sn.close(); JOptionPane.showMessageDialog(null, "the ip" +fn, "~~", JOptionPane.PLAIN_MESSAGE); } } } JOptionPane.showMessageDialog(null, item4); } }}