Topic: Java Code Repository

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Quote from: toofast;1458232
I didn't think such thing as a java enthusiast existed.


ikr.

Reply #25 Posted: December 22, 2011, 11:39:04 pm
Everyone needs more Bruce Campbell.

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Do not extend GUI Swing JComponents or any java.awt.Component for that matter and more than a few (<4) Data Members. If you do need to include more than a small number of variables (e.g more than JButton.pressed=true/false and so forth) then create a Data Member Reference to an Object instead ('Global Variable Pointer' for you C types).

If you give too many Data Members then the Object will not draw correctly. Example below:
Code: [Select]

public class NarutoChessPiece extends JButton{
   protected char type;
   protected String name=&quot;Empty Square&quot;;
   protected boolean turn=false;
   protected boolean empty=true;
   protected boolean moveMe=false;
   protected boolean player1=false;
   protected int x;
   protected int y;

}

Will not draw in a correct order from a two dimensional array for a board. By creating a Class, say 'NarutoPiece' and the moving all the Data Members from the above class into the NarutoPiece class all problems disappear.

Except for User Error which can only be eliminated with bullets or education.

Reply #26 Posted: March 20, 2012, 04:11:01 pm
I am now banned from GetSome

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485
You should can Java and go to C# :P

Reply #27 Posted: March 20, 2012, 05:08:02 pm
-= Sad pug is sad =-

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
-#

Reply #28 Posted: March 20, 2012, 09:17:30 pm
Everyone needs more Bruce Campbell.

Offline Bell

  • Addicted
  • Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.
  • Posts: 4,263
+ ++

Reply #29 Posted: March 21, 2012, 12:22:26 am

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Quote from: Tiwaking!;1458223



Writing software for parking meters is a serious business.


Code: [Select]
while ( myWallet.Money > 0)
{
EatMoreMoney(moreMoney);
System.out.println(&quot;Om Nom Nom!&quot;);
}
Last Edit: March 21, 2012, 11:23:24 am by Spacemonkey

Reply #30 Posted: March 21, 2012, 11:21:20 am

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485
Quote from: Spacemonkey;1476169
Writing software for parking meters is a serious business.


Code: [Select]
while ( myWallet.Money > 0)
{
EatMoreMoney(moreMoney);
System.out.println(&quot;Om Nom Nom!&quot;);
}

You bastard! I can't believe you'd write that code to steal my monies. I'm just glad you haven't figured out how to charge my cc yet...

Reply #31 Posted: March 21, 2012, 02:17:10 pm
-= Sad pug is sad =-

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
I can only charge your credit card if you don't give me your number.

Reply #32 Posted: March 21, 2012, 02:23:06 pm

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Quote from: Spacemonkey;1476169
Writing software for parking meters is a serious business.


Code: [Select]

while ( myWallet.Money > 0)
{
EatMoreMoney(moreMoney);
System.out.println(&quot;Om Nom Nom!&quot;);
}
Thats not how the system works!
Code: [Select]
public class Bank extends Thief{
protected final ArrayListsuckers;
protected double phatLewts=0;
public Bank(ArrayListcustomers){
suckers=customers;
}//constructor

public void depositMoney(Customer sucker){
if(sucker.hasMoney()){
phatLewts=phatLewts+sucker.getMoney();
sucker.setMoney(0);
}//fi
}//method Take their money and laugh
}//class

Reply #33 Posted: March 21, 2012, 05:12:01 pm
I am now banned from GetSome

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Quote from: Spacemonkey;1476169
Writing software for Java VMs is a serious business.


Code: [Select]
while ( myDevice.Memories > 0)
{
EatMoreMemory(moreMemory);
System.out.println(&quot;Om Nom Nom!&quot;);
}

I've so totally busted your elaborate ruse.

Reply #34 Posted: March 21, 2012, 05:45:06 pm
Everyone needs more Bruce Campbell.

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Quote from: Tiwaking!;1476035
Do not extend GUI Swing JComponents or any java.awt.Component for that matter and more than a few (<4) Data Members. If you do need to include more than a small number of variables (e.g more than JButton.pressed=true/false and so forth) then create a Data Member Reference to an Object instead ('Global Variable Pointer' for you C types).

If you give too many Data Members then the Object will not draw correctly. Example below:

Will not draw in a correct order from a two dimensional array for a board. By creating a Class, say 'NarutoPiece' and the moving all the Data Members from the above class into the NarutoPiece class all problems disappear.
OH! I found out why this was happening.

There are methods in the Component & JComponent called:

setX(int num)
setY(int num)

IF YOU OVERRIDE THESE IN ANY WAY EVERYTHING BREAKS.


Never override these methods. Create a new method instead, like "setXX(int n)" or "setYCoordinate".


If you override the methods then the Swing's draw X & Y coordinates become a weird number.

Dont forget to change the getX() and getY() to something like "getXX()" and "getYY()".

Reply #35 Posted: March 21, 2012, 08:07:15 pm
I am now banned from GetSome

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Then you could make a method miosis() to split your co-ordinates?

Reply #36 Posted: March 21, 2012, 09:37:48 pm
Everyone needs more Bruce Campbell.

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485



Reply #37 Posted: June 24, 2012, 08:38:31 pm
-= Sad pug is sad =-

Codex

  • Guest
lol epic

Reply #38 Posted: June 24, 2012, 10:33:06 pm

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
So old, but still good.
gOLDen, one might say :P

Reply #39 Posted: June 24, 2012, 10:50:49 pm
Everyone needs more Bruce Campbell.

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Dont forget the two required imports!
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
Code: [Select]
/**
Apparently getMethod does not allow for protected method access, but getDeclaredMethod does
*/
public void actionPerformed(ActionEvent ae){
try{
getClass().getDeclaredMethod(ae.getActionCommand()).invoke(this);
}//catch
catch(Exception e){
javax.swing.JOptionPane.showMessageDialog(null,e.toString(),ae.getActionCommand(),javax.swing.JOptionPane.INFORMATION_MESSAGE);
}//catch
}//me action performed

Reply #40 Posted: December 05, 2012, 05:50:37 pm
I am now banned from GetSome

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
For some reason KeyEvents (http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/event/KeyEvent.html) refuse to work properly. For example:
Code: [Select]

public void keyTyped(KeyEvent e) {
if(e.getKeyChar()==KeyEvent.VK_ESCAPE){
System.exit(0);
}//if you press escape (keyChar 27)
}//me

May or may not work. HOWEVER:
Code: [Select]

public void keyTyped(KeyEvent e) {
if(e.getKeyChar()==[b]e[/b].VK_ESCAPE){
System.exit(0);
}//if you press escape (keyChar 27)
}//me

DOES work even though KeyEvent key codes are static ints. This may be related to keyboard layout.


You have been warned

Reply #41 Posted: December 13, 2012, 11:21:14 pm
I am now banned from GetSome

Offline Bell

  • Addicted
  • Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.
  • Posts: 4,263
What happens if you use getKeyCode() instead of getKeyChar()

Reply #42 Posted: December 13, 2012, 11:38:30 pm

Offline oefox

  • Devoted Member
  • oefox has no influence.
  • Posts: 1,186
still on 1.5...oh dear

Don't upgrade to Juno, Juno is a bad upgrade over Helios/Indigo unless you turn off all validators, then it becomes quite usable.

Going to dabble in android apps over summer break, have been in spring mvc + hibernate/jpa for way too long

Reply #43 Posted: December 13, 2012, 11:39:11 pm
- badfox

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485
Tiwa doesn't use real IDE's.

He uses the glorified notepad that is BlueJ :)

On the same note, just upgraded from Galileo to Helios at work because it was balls.

Reply #44 Posted: December 14, 2012, 08:34:26 am
-= Sad pug is sad =-

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
This thread is intense.

Reply #45 Posted: December 14, 2012, 08:59:53 am

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485
You're in tents.

Reply #46 Posted: December 14, 2012, 09:16:04 am
-= Sad pug is sad =-

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
I pitch tents every night.

Reply #47 Posted: December 14, 2012, 10:31:08 pm
Everyone needs more Bruce Campbell.

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Quote from: Pyromanik;1511775
I pitch tents every night.


About Java code?

Reply #48 Posted: December 15, 2012, 12:28:46 pm

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Actually, no.

Reply #49 Posted: December 15, 2012, 04:12:35 pm
Everyone needs more Bruce Campbell.