Java GUI help!

0 amaw amaw · April 9, 2015
hey guys!

i want to create a GUI  that has 3 buttons (3 colors) & another 2 (Refresh & Browse)
when a user clicks on the window (of the app) it draws dot (with the same color clicked in the buttons)
then the dot's positions (X & Y) must be saved to a text file
when the user clicks to Refresh it cleans the board,
when pressing on the Browse buttons it reads an external text file.

can anyone help me please!!!!! asap

Post a Reply

Replies

Oldest  Newest  Rating
0 Eyeshield Rosalin · April 12, 2015
Here let me help you about the 3 buttons, Try to do the rest ya-ha!

import javax.swing.*;
class eyeshield {
   public static void main(String[] args){
   
    jam jammi = new jam();
    jammi.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jammi.setSize(143,143);
    jammi.setVisible(true);
   }

}


import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import javax.swing.*;

public class jam extends JFrame{
   
   private JButton button1;
   private JButton button2;
   private JButton button3;
   
   public jam(){
      super("Title me");
      setLayout(new FlowLayout());
      
      button1 = new JButton("Button1");
      button2 = new JButton("Button2");
      button3 = new JButton("Button3");
      
      button1.addActionListener(
         new ActionListener() {
            public void actionPerformed(ActionEvent stell) {
               JOptionPane.showMessageDialog(null,"I am Button 1","Button 1",JOptionPane.PLAIN_MESSAGE);
            }
            
         }
      );
      add(button1);
     
      button2.addActionListener(
         new ActionListener() {
            public void actionPerformed(ActionEvent eye) {
               JOptionPane.showMessageDialog(null,"I am Button 2","Button 2",JOptionPane.PLAIN_MESSAGE);
            }
            
         }
      );
      add(button2);
      
      
       button3.addActionListener(
         new ActionListener() {
            public void actionPerformed(ActionEvent fish) {
               JOptionPane.showMessageDialog(null,"I am Button 3","Button 3",JOptionPane.PLAIN_MESSAGE);
            }
            
         }
      );
      add(button3);

}
}
0 Branislav Lazic · April 10, 2015
And what did you try?
0 Nicholas Eason · April 10, 2015
We aren't here to do the work for you, we are here to help you out when you find yourself in trouble :P
  • 1

Java / Android Development

106,922 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator