Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: New guy needs help

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New guy needs help

    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);
     
     
     
     
    			}
     
    		}}


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: New guy needs help

    main is a static method.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: New guy needs help

    Welcome to the forums deeznut.

    Is there a question associated with this? What is the problem?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.