SRL Archive - Java Help and Tutorials

Help!


n3ss3s

2008-01-11 14:14:54

Okay, I want to use the thingz of DefaultButtonModel, I have isArmed there for example, but I know I can't do "la.isArmed" because la is a JButton, not a DefaultButtonModel, so, help please :)

[PHP]
import javax.swing.*;
import java.awt.*;


class Prog extends JFrame {

JButton la;
DefaultButtonModel dbm;

public Prog() {

la = new JButton("I r buttz0n?!");
dbm = new DefaultButtonModel();
getContentPane().add(la, BorderLayout.CENTER);

setTitle("GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main (String [] args) {

Prog prog = new Prog();
prog.setSize(600, 300);
prog.setVisible(true);

if (prog.dbm.isArmed()) {

System.out.println("armed");
}

}
}

[/PHP]


EDIT: Would "extends DefaultButtonModel" work? And can you do two extends?

Bobarkinator

2008-01-12 13:19:38

Perhaps "implements" JFrame and DBM

n3ss3s

2008-01-12 13:29:28

But how do I use it then, if the "la" gets clicked, it doesn't anyhow affect dbm anyway does it?

Jason2gs

2008-01-12 15:06:52

Blackmail? :|

Could you explain to me what you want to do. I'm afraid you didn't make much sense… You want the button to not change appearance when it's clicked? Is that it?

Edit: Wait… What?

Bobarkinator

2008-01-12 16:56:01

I am also rather confused about what you want

n3ss3s

2008-01-13 05:31:24

Nonono, you can ignore the isArmed part, just tell me how to use the DefaultButtonModel class's methods with the JButton "la".

R0b0t1

2008-01-13 19:19:38

Uhhhmmmm… You call them? Button.Method?

n3ss3s

2008-01-15 12:48:48

Gah, no - the JButton isn't the same as DefaultButtonModel - they ain't got the same functions :S

footballjds

2008-01-15 13:30:24

n3ss3s it looks like you know more then who your asking…
:rolleyes:

n3ss3s

2008-01-16 06:21:44

Umm… what?