Go to Post When a vomit shooter runs out of balls, is it dry heaving? :p - Lil' Lavery [more]
Home
Go Back   Chief Delphi > Other > Chit-Chat
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 05-02-2012, 13:47
nitneylion452's Avatar
nitneylion452 nitneylion452 is offline
Registered User
AKA: Joe Lee
FRC #3167 (Environmental Tectonics Crusaders)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Philadelphia, PA
Posts: 596
nitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud ofnitneylion452 has much to be proud of
Some non-FRC programming help

So I'm working on a project for one of my classes and I'm using the ActionListener interface (Java). I need to make the button that appears on screen jump to a different location. The actionPerformed method is where I'm having an issue. I'm not sure what to do there. Any ideas? Thanks in advance!


Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment2;

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

/**
 *
 * @author tuc73318
 */
public class JumpingButton extends JFrame implements ActionListener
{
    JButton button;
    public JumpingButton()
    {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new GridLayout(1,1));

	button = new JButton("Click this!");
	getContentPane().add(button);
	pack();
	setVisible(true);

	button.addActionListener(this);
    }
    
    public void actionPerformed(ActionEvent e)
    {
	
    }

    public void relocate(JFrame f)
    {
	Random rand = new Random();
	/*If this function is called, it will relocate the window to a new random position on the screen*/
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension windowSize = f.getSize();
	int x = rand.nextInt(screenSize.width - windowSize.width);
	int y = rand.nextInt(screenSize.height - windowSize.height);
	f.setLocation(x,y);
    }
}
__________________
Joe
"The ones who will one day rule the world rule the basketball court today."

http://www.fatherjudgerobotics.webs.com

Volunteer 2012 MAR Region Championship - Field Reset
Volunteer 2013 MAR Region Championship - Field Reset
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi