JToggleButton help

Hi,

I have a JToggleButton in my windows xp, and it looked great. But my app is opened using windows 2000, and the users didn't kinda like it. Because it has 3 JToggleButtons and when the button is selected, the button beside it has a 3d shadow effect which the users want to erase or remove.

Another problem is, I can't replicate the Look and feel in windows xp. Can I make the buttons selected but not look like it is selected, i'll just make the text different if its selected or not.. Or is there another way? Thank you very much.

[557 byte] By [JavaStartera] at [2007-10-3 9:24:16]
# 1

> Can I make the buttons selected but not look like it is selected,

you could try this - I don't like the look of it, but it might give you something

to play around with.

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

class Testing

{

public void buildGUI()

{

final JToggleButton tb1 = new JToggleButton("TB1");

final JToggleButton tb2 = new JToggleButton("TB2");

tb1.setUI(new javax.swing.plaf.basic.BasicButtonUI(){

protected void paintButtonPressed(Graphics g,AbstractButton b){}});

JFrame f = new JFrame();

f.getContentPane().add(tb1,BorderLayout.NORTH);

f.getContentPane().add(tb2,BorderLayout.SOUTH);

f.pack();

f.setLocationRelativeTo(null);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setVisible(true);

tb1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

System.out.println("tb1 "+(tb1.isSelected()? "":"un")+"selected");

}

});

tb2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

System.out.println("tb2 "+(tb2.isSelected()? "":"un")+"selected");

}

});

}

public static void main(String[] args)

{

SwingUtilities.invokeLater(new Runnable(){

public void run(){

new Testing().buildGUI();

}

});

}

}

Michael_Dunna at 2007-7-15 4:38:12 > top of Java-index,Desktop,Core GUI APIs...
# 2
thank you very very much!!! its the code i need!!! thank you very much!!!
JavaStartera at 2007-7-15 4:38:12 > top of Java-index,Desktop,Core GUI APIs...