setEnabled(false) Bug?

Hi Guy's,

Is there an issue with the setEnabled(false)? I've a gui with buttons which by default i have not enabled. The application runs and the buttons are indeed grayed out which, to me, would mean they are not live, clickable and certainly should not perform the code that is behind them until they become enabled with setEnabled(true) when other code is run. Make sence?

Why then are my buttons clickable and running code when they are grey out?

Please help? Its driving me loopy!

Doo

[522 byte] By [dooie07a] at [2007-11-27 4:06:52]
# 1
Post a small (<1 page) example program that demonstrates your problem.
DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 2
How are you capturing the clicks? Not with a MouseListener, is it?
georgemca at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 3
guessing... guessing...
DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 4

> guessing... guessing...

I bet you that donut you owe me I'm right

import java.awt.FlowLayout;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import javax.swing.JButton;

import javax.swing.JFrame;

public class ClickyMouseyButtons extends JFrame {

public ClickyMouseyButtons() {

JButton button = new JButton("click me");

setLayout(new FlowLayout());

this.getContentPane().add(button);

button.addMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

System.err.println("The button's disabled, but I can click it anyway");

}

});

button.setEnabled(false);

}

public static void main(String[] args) {

JFrame frame = new ClickyMouseyButtons();

frame.setSize(100, 100);

frame.setVisible(true);

}

}

georgemca at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 5
You're on. It's the FRIDAY DONUT CHALLENGE!!!
DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 6

Ok, the 5p button should not work, right?

/*

* testEnables.java

*

* Created on 11 May 2007, 16:46

*/

/**

*

* @author Dooie & Rooney

*/

public class testEnables extends javax.swing.JFrame {

/** Creates new form testEnables */

public testEnables() {

initComponents();

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">

private void initComponents() {

jButton5p = new javax.swing.JButton();

jPanelInfoAndInstructions = new javax.swing.JPanel();

jPanelCreditTime = new javax.swing.JPanel();

jLabelCreditLabel = new javax.swing.JLabel();

jLabelCredit = new javax.swing.JLabel();

jLabelEquals = new javax.swing.JLabel();

jLabelSeconds = new javax.swing.JLabel();

jLabelSecondLabel = new javax.swing.JLabel();

jPanelCallSelected = new javax.swing.JPanel();

jLabelCallType = new javax.swing.JLabel();

jLabelCallTypeSelected = new javax.swing.JLabel();

jPanelInstruction = new javax.swing.JPanel();

jLabelInstruction = new javax.swing.JLabel();

jLabelInst = new javax.swing.JLabel();

jRadioButtonLocal = new javax.swing.JRadioButton();

jRadioButtonLong = new javax.swing.JRadioButton();

jRadioButtonInter = new javax.swing.JRadioButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton5p.setFont(new java.awt.Font("Verdana", 0, 11));

jButton5p.setText("5p");

jButton5p.setEnabled(false);

jButton5p.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jButton5pMouseClicked(evt);

}

});

jPanelInfoAndInstructions.setBorder(javax.swing.BorderFactory.createEtchedBorder());

jLabelCreditLabel.setFont(new java.awt.Font("Verdana", 0, 14));

jLabelCreditLabel.setText("Credit:");

jLabelCredit.setFont(new java.awt.Font("Verdana", 1, 14));

jLabelCredit.setText("0");

jLabelEquals.setFont(new java.awt.Font("Verdana", 0, 14));

jLabelEquals.setText("=");

jLabelSeconds.setFont(new java.awt.Font("Verdana", 1, 14));

jLabelSeconds.setText("0");

jLabelSecondLabel.setFont(new java.awt.Font("Verdana", 0, 14));

jLabelSecondLabel.setText("Seconds Of Talk Time");

javax.swing.GroupLayout jPanelCreditTimeLayout = new javax.swing.GroupLayout(jPanelCreditTime);

jPanelCreditTime.setLayout(jPanelCreditTimeLayout);

jPanelCreditTimeLayout.setHorizontalGroup(

jPanelCreditTimeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelCreditTimeLayout.createSequentialGroup()

.addGap(55, 55, 55)

.addComponent(jLabelCreditLabel)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelCredit)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelEquals)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelSeconds)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelSecondLabel)

.addContainerGap(157, Short.MAX_VALUE))

);

jPanelCreditTimeLayout.setVerticalGroup(

jPanelCreditTimeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelCreditTimeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabelCreditLabel)

.addComponent(jLabelSecondLabel)

.addComponent(jLabelSeconds)

.addComponent(jLabelEquals)

.addComponent(jLabelCredit))

);

jPanelCallSelected.setEnabled(false);

jLabelCallType.setFont(new java.awt.Font("Verdana", 0, 14));

jLabelCallType.setText("Call Type:");

jLabelCallTypeSelected.setFont(new java.awt.Font("Verdana", 0, 14));

javax.swing.GroupLayout jPanelCallSelectedLayout = new javax.swing.GroupLayout(jPanelCallSelected);

jPanelCallSelected.setLayout(jPanelCallSelectedLayout);

jPanelCallSelectedLayout.setHorizontalGroup(

jPanelCallSelectedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelCallSelectedLayout.createSequentialGroup()

.addGap(34, 34, 34)

.addComponent(jLabelCallType)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelCallTypeSelected, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(11, Short.MAX_VALUE))

);

jPanelCallSelectedLayout.setVerticalGroup(

jPanelCallSelectedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelCallSelectedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabelCallType)

.addComponent(jLabelCallTypeSelected))

);

jLabelInstruction.setFont(new java.awt.Font("Verdana", 1, 12));

jLabelInstruction.setForeground(new java.awt.Color(255, 0, 0));

jLabelInstruction.setText("Select 'New' To Make A Call...");

jLabelInst.setFont(new java.awt.Font("Verdana", 1, 14));

jLabelInst.setForeground(new java.awt.Color(255, 0, 0));

jLabelInst.setText("Instruction:");

javax.swing.GroupLayout jPanelInstructionLayout = new javax.swing.GroupLayout(jPanelInstruction);

jPanelInstruction.setLayout(jPanelInstructionLayout);

jPanelInstructionLayout.setHorizontalGroup(

jPanelInstructionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelInstructionLayout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabelInst)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabelInstruction, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE))

);

jPanelInstructionLayout.setVerticalGroup(

jPanelInstructionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelInstructionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabelInst)

.addComponent(jLabelInstruction))

);

javax.swing.GroupLayout jPanelInfoAndInstructionsLayout = new javax.swing.GroupLayout(jPanelInfoAndInstructions);

jPanelInfoAndInstructions.setLayout(jPanelInfoAndInstructionsLayout);

jPanelInfoAndInstructionsLayout.setHorizontalGroup(

jPanelInfoAndInstructionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanelInstruction, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanelCallSelected, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanelCreditTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

);

jPanelInfoAndInstructionsLayout.setVerticalGroup(

jPanelInfoAndInstructionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanelInfoAndInstructionsLayout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanelInstruction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanelCallSelected, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanelCreditTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jRadioButtonLocal.setFont(new java.awt.Font("Verdana", 0, 11));

jRadioButtonLocal.setText("Local Call");

jRadioButtonLocal.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

jRadioButtonLocal.setMargin(new java.awt.Insets(0, 0, 0, 0));

jRadioButtonLocal.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jRadioButtonLocalMouseClicked(evt);

}

public void mouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonLocalMouseEntered(evt);

}

});

jRadioButtonLong.setFont(new java.awt.Font("Verdana", 0, 11));

jRadioButtonLong.setText("Long Distance");

jRadioButtonLong.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

jRadioButtonLong.setMargin(new java.awt.Insets(0, 0, 0, 0));

jRadioButtonLong.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jRadioButtonLongMouseClicked(evt);

}

public void mouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonLongMouseEntered(evt);

}

});

jRadioButtonLong.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jRadioButtonLongActionPerformed(evt);

}

});

jRadioButtonInter.setFont(new java.awt.Font("Verdana", 0, 11));

jRadioButtonInter.setText("International");

jRadioButtonInter.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

jRadioButtonInter.setMargin(new java.awt.Insets(0, 0, 0, 0));

jRadioButtonInter.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jRadioButtonInterMouseClicked(evt);

}

public void mouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonInterMouseEntered(evt);

}

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(62, 62, 62)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jPanelInfoAndInstructions, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jRadioButtonLocal)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(jRadioButtonLong)

.addGap(65, 65, 65)

.addComponent(jButton5p, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jRadioButtonInter))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(49, 49, 49)

.addComponent(jRadioButtonLocal)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jRadioButtonLong)

.addComponent(jButton5p))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jRadioButtonInter)

.addGap(59, 59, 59)

.addComponent(jPanelInfoAndInstructions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(44, 44, 44))

);

pack();

}// </editor-fold>

private void jRadioButtonInterMouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonInter.setToolTipText("Make An International Call");

}

private void jRadioButtonInterMouseClicked(java.awt.event.MouseEvent evt) {

if (jRadioButtonInter.isSelected()) {

//jButtonDone.setEnabled(true);

jLabelCallTypeSelected.setText("Local Call 10p = 5 Seconds");

}

}

private void jRadioButtonLongActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jRadioButtonLongMouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonLong.setToolTipText("Make A Long Distant Call");

}

private void jRadioButtonLongMouseClicked(java.awt.event.MouseEvent evt) {

if (jRadioButtonLong.isSelected()) {

//jButtonDone.setEnabled(true);

jLabelCallTypeSelected.setText("Long Distance Call 15p = 15 Seconds");

}

}

private void jRadioButtonLocalMouseEntered(java.awt.event.MouseEvent evt) {

jRadioButtonLocal.setToolTipText("Make A Local Call");

}

private void jRadioButtonLocalMouseClicked(java.awt.event.MouseEvent evt) {

if (jRadioButtonLocal.isSelected()) {

//jButtonDone.setEnabled(true);

jLabelCallTypeSelected.setText("Local Call 10p = 30 Seconds");

}

}

private void jButton5pMouseClicked(java.awt.event.MouseEvent evt) {

String tempCoinAmount;//set tempCoinAmount

String tempCallDuration;//set tempCallTime

//jButtonDone.setEnabled(false); //un-enable next button

int coinAmount; //set int type for coin amount

int callDuration;//set int call Duration

tempCoinAmount = jLabelCredit.getText();//get txt from jLabelCredit

coinAmount = Integer.parseInt(tempCoinAmount) ;//parse txt to coinamount

coinAmount += 5;//add 5

tempCallDuration = jLabelSeconds.getText(); //get txt from jLabelSeconds

callDuration = Integer.parseInt(tempCallDuration); //parse txt to callDuration

if (jRadioButtonLocal.isSelected()) {

callDuration += 5 * 3;

if (coinAmount >= 10){

//jButtonDone.setEnabled(true);

jLabelInstruction.setText("You Can Dial When Ready...");

//jButton1.setEnabled(true);

//jButton2.setEnabled(true);

//jButton3.setEnabled(true);

//jButton4.setEnabled(true);

//jButton5.setEnabled(true);

//jButton6.setEnabled(true);

//jButton7.setEnabled(true);

//jButton8.setEnabled(true);

//jButton9.setEnabled(true);

//jButton0.setEnabled(true);

//jButtonClearScreen.setEnabled(true);

//jButtonDone.setEnabled(false);

//jButtonNewCall.setEnabled(false);

////jButtonCall.setEnabled(true);

//jTextFieldScreenDisplay.setEnabled(true);

}

}else if (jRadioButtonLong.isSelected()) {

callDuration += 5;

if (coinAmount >= 15){

//jButtonDone.setEnabled(true);

jLabelInstruction.setText("You Can Dial When Ready...");

//jButton1.setEnabled(true);

//jButton2.setEnabled(true);

//jButton3.setEnabled(true);

//jButton4.setEnabled(true);

//jButton5.setEnabled(true);

//jButton6.setEnabled(true);

//jButton7.setEnabled(true);

//jButton8.setEnabled(true);

//jButton9.setEnabled(true);

//jButton0.setEnabled(true);

//jButtonClearScreen.setEnabled(true);

//jButtonDone.setEnabled(false);

//jButtonNewCall.setEnabled(false);

////jButtonCall.setEnabled(true);

//jTextFieldScreenDisplay.setEnabled(true);

}

}else {

callDuration = coinAmount / 2;

if (coinAmount >= 30){

//jButtonDone.setEnabled(true);

jLabelInstruction.setText("You Can Dial When Ready...");

//jButton1.setEnabled(true);

//jButton2.setEnabled(true);

//jButton3.setEnabled(true);

//jButton4.setEnabled(true);

//jButton5.setEnabled(true);

//jButton6.setEnabled(true);

//jButton7.setEnabled(true);

//jButton8.setEnabled(true);

//jButton9.setEnabled(true);

//jButton0.setEnabled(true);

//jButtonClearScreen.setEnabled(true);

//jButtonDone.setEnabled(false);

//jButtonNewCall.setEnabled(false);

////jButtonCall.setEnabled(true);

//jTextFieldScreenDisplay.setEnabled(true);

}

}

jLabelSeconds.setText(Integer.toString(callDuration));//set time

jLabelCredit.setText(Integer.toString(coinAmount));//set coin amount

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new testEnables().setVisible(true);

}

});

}

// Variables declaration - do not modify

private javax.swing.JButton jButton5p;

private javax.swing.JLabel jLabelCallType;

private javax.swing.JLabel jLabelCallTypeSelected;

private javax.swing.JLabel jLabelCredit;

private javax.swing.JLabel jLabelCreditLabel;

private javax.swing.JLabel jLabelEquals;

private javax.swing.JLabel jLabelInst;

private javax.swing.JLabel jLabelInstruction;

private javax.swing.JLabel jLabelSecondLabel;

private javax.swing.JLabel jLabelSeconds;

private javax.swing.JPanel jPanelCallSelected;

private javax.swing.JPanel jPanelCreditTime;

private javax.swing.JPanel jPanelInfoAndInstructions;

private javax.swing.JPanel jPanelInstruction;

private javax.swing.JRadioButton jRadioButtonInter;

private javax.swing.JRadioButton jRadioButtonLocal;

private javax.swing.JRadioButton jRadioButtonLong;

// End of variables declaration

}

dooie07a at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 7
Am i the Donut? Please don't eat me....
dooie07a at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 8

jButton5p.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jButton5pMouseClicked(evt);

}

});

[url #" style="display: block; background-image: url('http://www.geofftech.co.uk/50pence/photos/homer_doh.jpg'); width: 191px; height: 271px] [/url]

[url #" style="display: block; background-image: url('http://www.fitnessmantra.info/fitness/wp-content/uploads/2006/06/simpson-doughnut.jpg'); width: 196px; height: 184px] [/url]

And dooie07 -- that's not a short example. Next time trim it down to that than a page , please. More forum members will help you, then.

DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 9
It's hard to express in text, but I'm doing a little victory dance as we speak
georgemca at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 10
@dooie07: don't use a MouseListener to capture button clicks, use an ActionListenernot bad: 2 dukes and a donut
georgemca at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 11
My only compensation is that I can look at that code and grumble about how krap NetBeanz is...
DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 12
> My only compensation is that I can look at that code> and grumble about how krap NetBeanz is...NetBeanz rocks IMO, it's just the matisse editor that's ****. But they did it better than I could have...
BinaryDigita at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 13

jButton5p.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jButton5pMouseClicked(evt);

DO SOMETHING HERE?

}

OR DO SOMETHING HERE?

});

Thankkyou both for the help, i'm working on it now... i've been doing java for about 3 weeks and beans is what we were told to use, do you have issues with it?

dooie07a at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 14
Button5p.addActionListener(...);
DrLaszloJamfa at 2007-7-12 9:12:02 > top of Java-index,Java Essentials,New To Java...
# 15
Its ok, I have is now, but why does this not work in mouse clicked? Thank You Guy'sDukes Awarded.Doo
dooie07a at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...
# 16

> i've been doing java for about 3 weeks and beans is what we were told to use, do you have issues with it?

1. Most (but not all) experienced Java programmers believe that an IDE gets

in the way of learning the basics. Instead they suggest starting out with a text

editor and working from the command line to compile and run code. Old Skool rulez.

2. Some people have issues with the quality of code generated by drag'n'drop tools like the Matisse component in NetBeans. They prefer to write such code

by hand, or rewrite what such tools generate.

3. Have you programmed in another language before? Three weeks seems

awfully fast to be getting into Swing, but then I know those "Learn Java

in 21 Days" books get to GUI programming in week 2...

DrLaszloJamfa at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...
# 17

I missed 3 months of this semester (Java element started this semester) due to illness. I will agree with you about the IDE, its the same with learning html in Dreamweaver, although you cannot compare java to html but you get what i mean.

Java is my first prog language, and i was worring about the amount of time i missed, but i found i quite like it and like getting into the code and hacking away.

I know html backwards with php and sql competency.

Cheers

Doo

dooie07a at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...
# 18

> Its ok, I have is now, but why does this not work in

> mouse clicked?

If you have Windows, right-click My Computer and select Properties. In that dialog is an "Apply" button that is disabled. If you right-click it, a "What's This" menu pops up. If disabled JButtons did not respond to mouse events, there would be no easy way for a Java program to implement something like that.

BinaryDigita at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...
# 19

Ok dudes, can you tell me why im not adding in increments of 5p?

I hit the 5p button, it adds 5p, hit it again the total is 15p then 30p then 50p, 75p, 110p....

Heres the code....

private void jButton5pActionPerformed(java.awt.event.ActionEvent evt) {

jButton5p.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jButton5pMouseClicked(evt);

String tempCoinAmount = jLabelCredit.getText();//get txt from jLabelCredit

int coinAmount = Integer.parseInt(tempCoinAmount) ;//parse txt to coinamount

coinAmount += 5;//add 5

String tempCallDuration = jLabelSeconds.getText(); //get txt from jLabelSeconds

int callDuration = Integer.parseInt(tempCallDuration); //parse txt to callDuration

if (jRadioButtonLocal.isSelected()) {

callDuration += 5 * 3;

if (coinAmount >= 10){

jLabelInstruction.setText("You Can Dial When Ready...");

}

}else if (jRadioButtonLong.isSelected()) {

callDuration += 5;

if (coinAmount >= 15){

jLabelInstruction.setText("You Can Dial When Ready...");

}

}else {

callDuration = coinAmount / 2;

if (coinAmount >= 30){

jLabelInstruction.setText("You Can Dial When Ready...");

}

}

jLabelSeconds.setText(Integer.toString(callDuration));//set time

jLabelCredit.setText(Integer.toString(coinAmount));//set coin amount

}

});

}

dooie07a at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...
# 20

> > Its ok, I have is now, but why does this not work

> in

> > mouse clicked?

>

> If you have Windows, right-click My Computer and

> select Properties. In that dialog is an "Apply"

> button that is disabled. If you right-click it, a

> "What's This" menu pops up. If disabled JButtons did

> not respond to mouse events, there would be no easy

> way for a Java program to implement something like

> that.

Ahh... i see binary... Thx

dooie07a at 2007-7-21 21:02:12 > top of Java-index,Java Essentials,New To Java...