blog's Doomworld Forums Blog

blog's Doomworld Forums Blog

Java Memory Game July 6, 2015, 11:11 pm
In an assignment, I created a simple memory game.

Memory Game.

Also, I have a question. Which is better to use to close the program? System.exit(0)? Or dispose() to destroy the window, which already terminates the program on close?
1 Comment

What happened to Liam? July 4, 2015, 2:03 am
I remember him being a part of the forum leaders here but now he's no longer on the leader list.

Thinking Out Loud (TOL) July 3, 2015, 8:15 am
Maybe we could use a TOL thread? It's a 50/ 50 - maybe not, even.

Anyway, I'm thinking of releasing an "alpha" of my mod, because there is even lots of progress to be made before it even reaches a beta stage, and not to mention a final stage.

Java GUI Calculator July 2, 2015, 11:36 pm
Here is a code for a calculator using GUI and event driven programming. One annoying problem is that the numbered buttons call the action method twice. Suggestions to improve the program is much appreciated.

EDIT: An error found. Putting 0s in front of numbers might manipulate the calculation a bit.

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

// these are for evaluating equations stored in a string. searched on net
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;

public class Calculator extends JFrame {

// components are declared here for reference in the inner class (ButtonListener)

JButton jbtCalculate = new JButton("Calculate");
JButton jbtClear = new JButton("Clear");
JButton[] jbtNumbers = new JButton[10];
JButton[] jbtOperators = {new JButton ("+"), new JButton ("-"), new JButton ("/"), new JButton ("*")};

JTextField equationText = new JTextField(15);

ButtonListener listener = new ButtonListener();

public Calculator() {

JPanel mainPanel = new JPanel(new BorderLayout(5, 5));

JPanel panelText = new JPanel();
JPanel panelNumberButtons = new JPanel(new GridLayout(4, 3, 5, 5));
JPanel panelOperatorButtons = new JPanel(new GridLayout(4, 1, 5, 5));
JPanel panelBottomButtons = new JPanel(new FlowLayout(FlowLayout.CENTER)); // "Calculate" and "Clear" buttons

for (int i = 0; i < jbtNumbers.length; i++) {

jbtNumbers = new JButton("" + i);


panelText.setBorder(new TitledBorder("Equation"));

panelNumberButtons.setBorder(new TitledBorder("Numbers"));
for (int i = jbtNumbers.length - 1; i > 0; i -= 3) {

panelNumberButtons.add(jbtNumbers[i - 2]);
panelNumberButtons.add(jbtNumbers[i - 1]);

jbtNumbers[i - 2].addActionListener(listener);
jbtNumbers[i - 1].addActionListener(listener);


panelOperatorButtons.setBorder(new TitledBorder("Ops"));
for (int i = 0; i < jbtOperators.length; i++) {




mainPanel.add(panelText, BorderLayout.NORTH);
mainPanel.add(panelNumberButtons, BorderLayout.CENTER);
mainPanel.add(panelOperatorButtons, BorderLayout.EAST);
mainPanel.add(panelBottomButtons, BorderLayout.SOUTH);



class ButtonListener implements ActionListener {

// these are for evaluating equations stored in a string. searched on net
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");

public void actionPerformed(ActionEvent e) {

if (e.getSource() != jbtCalculate && e.getSource() != jbtClear)
equationText.setText(equationText.getText() + ((JButton)e.getSource()).getText());

else if (e.getSource() == jbtClear)


try {



catch (Exception ex) {





public static void main(String[] args) {

Calculator calculator = new Calculator();

calculator.setSize(225, 300);



Eris Falling
18 July 2, 2015, 7:11 pm
So today (3rd) I turn 18. Yay, etc.

Now to not get absolutely bollocksed because I'm a boring bastard like that :p

alcoholics anon July 2, 2015, 12:23 pm
Apparently I drink an average of 44 units of beer in a week. This is considered to be a bad thing.

Compiling a high score board of DW regulars. Be honest.

And now, I'm off to the pub to drink until I'm retarded.

If you excel at math, then you don't know the struggle. July 1, 2015, 9:29 pm
So here's my problem: I love quantum mechanics, physics, chemistry, biology, astrophysics and cosmology. But in order to understand those subjects intimately, I would have to be able to comprehend the mathematical formulae associated with those fields of study. I am unable to do most high school algebra and in fact I am almost unable to add or subtract numbers larger than single digit without using pen and paper; and with pen and paper, I am nearly unable to do division. I am not willing to drop everything and spend the next 10 years learning various forms of math, just so I can catch up with someone who, because of their natural skill, learned he same amount of information in one year or less.

My point is that people who are naturally skilled at arithmetic are unable to understand the that it's simply too difficult for unskilled folks to learn, as very few people have the time or devotion to overcome their inability comprehend anything higher than grade school math. Is there anything than can be done about this, or are mathematically challenged folks like myself doomed to never "getting it"?

No more predictions, I guess? June 30, 2015, 11:07 am
So, I've noticed that most of my prediction threads have been Helled, and each one quicker than the previous, usually after someone makes an inappropriate remark that has nothing to do with thread. That's fine, I guess, and if my predictive discussions are unwanted, then okay, I get the hint. But what's the deal? I don't mention anything criminal, inappropriate, risque or trollish in these posts. I base my predictions on years of research (and in fact can find examples of pretty much everything on Google) and state that they are simply thought experiments, rather than absolutes. What typically seems to happen is that any potential for interesting discussion gets derailed by someone calling me insane, accusing me of being drugged up (which is not the case when I express these ideas), or otherwise insulting me. With this latest thread drop, I was told to "stop making threads." I mean, c'mon, are you telling me that a voxel camera isn't worth discussing? Am I hated or something around here? I have turned the other cheek time and time again, and will continue to do so, but I do not understand the backlash.

Finding the biggest object June 27, 2015, 11:45 am
I've been asked to write a method which is public static Object max(Object[] a). It should return the highest Object in an Object array using compareTo method. However, with this method's parameter, since Object doesn't have compareTo method, I'm supposed to put several if statements to determine if the object is an instanceof Account, or Employee, or other classes that use compareTo:

public static Object max(Object[] a) {

if (a instanceof Account[]) {

// for loops and casting from Object to Account

return max;


if (a instanceof Employee[]) {

// for loops and casting from Object to Employee

return max;

// yadda yadda...

So I changed the function to this:

public static Object max(Comparable[] a) {

Comparable max = a[0];

for (int j = 0; j < a.length; j++)
if (max.compareTo(a[j]) < 0)
max = a[j];

return max;


Which works fine, and I think it's similar to java.util.Arrays.max(anArray). But I heard that it's not a very good idea to do that. Is it healthy to do this?

I need Doom friends. June 24, 2015, 5:00 am
I have been for a long time looking for online friends that are die hard Doom fans. I know I am 19, but Doom has been my everything since I build a DOS PC when I was 12. I am looking for friends to play Multiplayer with, Make and share WADs with, and to maybe someday start a Doom related WAD project with.

If you wanna be my friend, I wont mind to publicly give a link to my Facebook account (Through PM).