JButton CLICKED color

Hello !
I know how to change buttons colors with setBackground and setForeground, but I can't find a way to change the clicked color. It's always that basic grey.
Another question while I'm here...: I have a similar problem with checkboxes colors : the checkmark remains the original color, so I can't see if it's on or off, as I put black as foreground color (and the checkmark is black...). The foreground color doesn't change the checkmark's color.
Thanks for your help !
C14

I forget if the API for jcomponent/jbutton/jcheckbox suppots that. For the checkbox, I had to extend JCheckBox an doverride paint.
For JButton you may want to do something like that as well:
class MyButton extends JButton
pulic void paintComponent(Graphics g)
super.paintComponent(g);
// do your code here
Not sure if that will work, you want to call parent to paint the button, but there may be a state identifier to see if its in a clicked state.

Similar Messages

  • How to change the button's clicked color

    Dear all,
    How to change the button's clicked color
    I want it to be white in color as my button's background color is white
    Thanks

    How to change the button's clicked colorvia the UIManager

  • Selecting checkbox through a JButton click in JFrame

    i am trying to change the state of the check box in a JFrame through a JButton click, using the getsource() method.
    if (e.getSource()==johnButton){
    // Set the state of the checkbox to on
    checkbox.setSelected(true);
    i have also tried using isSelected().
    there is no error in the programme, how ever it doesn't work for me.

    Must be
    if(e.getSource()== JCheckbox)
    do whatever
    However, a better way if you had many checkboxs
    JCheckbox b = new JCheckbox(...);
    b.addActionListener(this);
    b.setActionCommand("MyChkBx");
    public void actionPerformed(ActionEvent e)
    String cmd = e.getActionEvent();
    if(cmd.equals("MyChkBx"))
    do whatever
    }

  • Why does JButton background color change when  clicking ?

    Hello,
    I have defined :
    JButton mybutton = new JButton(Icon xxx) ;
    with no associated text and I set both foreground and background colors to black, and an empty border.
    This is because the background color of the container which contents this button is also black and I want to see only the button icon.
    When I click on the icon , the button background color becomes grey. How can I change this to make it remains black ?
    Thanks a lot.
    Gege

    Well, the color changes because that is how the look and feel is defined,
    presumably to give better feedback to the user that she has clicked the
    button.
    If you don't want this, you could try using a different L&F which doesn't do this.
    Alternatively, If you've only got the one button, you could just do
        UIManager.put( "Button.select", Color.BLACK );If you have multiple buttons, and you want the other buttons to behave
    normally, you can extend the one button and have it change the color
    while it is pressed, e.g.,
    import java.awt.*;
    import java.io.IOException;
    import java.net.URL;
    import javax.swing.*;
    public class ButtonSelect extends JFrame {
         public ButtonSelect() throws IOException {
              super();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel = new JPanel();
              panel.add( new JButton( "Normal" ) );
              Image img = Toolkit.getDefaultToolkit().getImage( new URL("http://www.google.com/intl/en/images/logo.gif" ) );
              ImageIcon ii = new ImageIcon( img );
              JButton b = new JButton( ii ) {
                   static final private String KEY = "Button.select";
                   public void paint( Graphics g ) {
                        Color save = null;
                        if ( getModel().isArmed() && getModel().isPressed() ) {
                             save = UIManager.getColor( KEY );
                             UIManager.put( KEY, Color.WHITE );
                        super.paint( g );
                        if ( save != null )
                             UIManager.put( KEY, save );
              b.setForeground( Color.WHITE );
              b.setBackground( Color.WHITE );
              b.setFocusPainted( false );
              panel.add( b );
              getContentPane().add( panel );
              pack();
              setVisible( true );
         public static void main( String[] a ) throws IOException {
              new ButtonSelect();
    }

  • JButton - avoid color change when clicked

    Hello All,
    probably this is a simply question, but i didn't find the answer.
    I have some JButtons in my window. When they are clicked, they change
    their background color for a momement (normal behavior). This is what I
    want to avoid. How could I do this?
    Thank you in advance.
    Ralf

    i haven't got the soources at the moment, but check it out from there... it's probably defined in some L&F class, like ButtonUI or something... you'd probably need to create custom *UI class.
    if you extend BasicButtonUI and override protected void paintButtonPressed(), then you may have it do as little as you please.
    easyest way would probably be copying original one, and then have it paint background with original background color, or not to fill it at all..

  • Issue with JButton clicking

    Hi guys,
    I'm having an issue with a JTable, I hope you can help me.
    Last cells of each row is a JButton and my issue is with click on that button.
    In fact, it's required clicking two times to run code linked to listener for the same button.
    What I need is clicking just one time to run code, not two times.
    This is code to build Table:
    private JTable getJTable() {
              if (jTable == null) {
                   jTable = new JTable();
                   jTable.setModel(new MyTableModel());
                   final MyTableModel tabella = (MyTableModel) jTable.getModel();
                   Vector<String> nameColumn = new Vector<String>();
                   nameColumn.addElement("Cliente");
                   nameColumn.addElement("Data");
                   nameColumn.addElement("Esito");
                   nameColumn.addElement("Immagine");
                   nameColumn.addElement("Dettagli");
                   tabella.setColumnIdentifiers(nameColumn);
                   tabella.setElencoDiagnosi(true);
                   final Vector<Diagnosi> elencoDiagnosi = gestioneDiagnosi.selectAllDiagnosi();
                   jTable.getColumn("Dettagli").setCellRenderer(new PanelRender());
                 jTable.getColumn("Dettagli").setCellEditor(new PanelEditor());
                 jTable.getColumn("Immagine").setCellRenderer(new PanelRender());
                 jTable.getColumn("Immagine").setCellEditor(new PanelEditor());
                 jTable.setRowHeight(36); //Metto un altezza che mi consenta di vedere tutto il bottone
                 JButton[] arrayButtonDettagli = new JButton[elencoDiagnosi.size()];
                 JButton[] arrayButtonImmagini = new JButton[elencoDiagnosi.size()];
                 for (int i=0;i<elencoDiagnosi.size(); i++)
                      final int contatore=i;
                      arrayButtonDettagli[i] = new JButton("Elenco Dettagli");
                      arrayButtonDettagli.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent e)
                                  Diagnosi diagnosi=elencoDiagnosi.get(contatore);
                                  GUIElencoDiagnosi.this.dispose();
                                  GUIModificaDiagnosi modificaDiagnosi =
                                       new GUIModificaDiagnosi(OrthoLabMain.listaUtenti,
                                            risultati,diagnosi);
                                  modificaDiagnosi.setVisible(true);
              final Diagnosi diagnosi=elencoDiagnosi.get(i);
              arrayButtonImmagini[i] = new JButton(new javax.swing.ImageIcon(getClass().getResource("/image/jpg-icon.gif"))) ;
              arrayButtonImmagini[i].setSize(36, 36);
              arrayButtonImmagini[i].setBackground(Color.WHITE);
              arrayButtonImmagini[i].addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent e)
                                  JOptionPane.showMessageDialog(null,"","Zoom Immagine",
                                            JOptionPane.INFORMATION_MESSAGE,new ImageIcon(diagnosi.getImmagine()));
              Object[] row = new String[4];
              row[0]=diagnosi.getCognomeCliente()+" "+diagnosi.getNomeCliente();
              String dataviewanno=diagnosi.getData().substring(0, 4);
              String dataviewmese=diagnosi.getData().substring(4,6);
              String dataviewgiorno=diagnosi.getData().substring(6, 8);
              row[1]=dataviewgiorno+"/"+dataviewmese+"/"+dataviewanno;
              row[2]=diagnosi.getEsito();
              tabella.addRow(row);
              tabella.setValueAt(arrayButtonImmagini[i],i, 3);
                        tabella.setValueAt(arrayButtonDettagli[i], i, 4);
              return jTable;
    This is code for CellRender and CellEditor (written ad hoc)Cell renderer (PanelRenderer)
    public class PanelRender extends DefaultTableCellRenderer {
         private static final long serialVersionUID = 1L;
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if(value instanceof JComponent) {
    return (JComponent)value;
    } else {
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    Cell Editor (PanelEditor)
    public class PanelEditor extends AbstractCellEditor implements TableCellEditor {
         private static final long serialVersionUID = 1L;
         private JComponent panel = null;     
         public Object getCellEditorValue() {
              return panel;
         public Component getTableCellEditorComponent(JTable table, Object value,
                   boolean isSelected, int row, int column) {
              panel = (JComponent)value;
              return panel;
    Could you help me?
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Thanks Ryan,
    I solved my issue with your help. Now I've a bit issue, that is I can't see icon on my button, it seems like toString method is displayed instead icon.
    For table renderer I use a new class that implements TableCellRenderer, while for model I use a new class that extends DefaultTableModel.. In the following some code...please help me, icon on button aren't shown! Thanks
    private JScrollPane getJScrollPane(Vector<Diagnosi> ris) {
              if (jScrollPane == null) {
                   TableCellRenderer defaultRenderer;
    final MyTableModel tabella = (MyTableModel) jTable.getModel();
                   defaultRenderer = jTable.getDefaultRenderer(JButton.class);
                   jTable.setDefaultRenderer(JButton.class,
                               new PanelRender(defaultRenderer));
                   jTable.getColumn("Immagine").setCellRenderer(defaultRenderer);
                   jTable.getColumn("Immagine").setCellEditor(new PanelEditor());
                   jTable.getColumn("Regolo").setCellRenderer(defaultRenderer);
                   jTable.getColumn("Regolo").setCellEditor(new PanelEditor());
                   jTable.getColumn("PDF").setCellRenderer(defaultRenderer);
                   jTable.getColumn("PDF").setCellEditor(new PanelEditor());
                   jScrollPane.setViewportView(jTable);
              return jScrollPane;My Table Model
    public class MyTableModel extends DefaultTableModel {
              public MyTableModel(Object[][] data, Object[] columnNames) {
                 super(data, columnNames);
              public MyTableModel(){
                   super();
              public boolean isCellEditable(int row, int column) {
                   if(elencoClienti){
                        if(column!=5)
                             return false;  
                        else return true;
                   else if(elencoDiagnosi){
                        if(column<3)
                             return false;
                        else return true;
                   else if(clientiLista)
                        return false;
                   else if(diagnosiLista){
                        if(column<3)
                             return false;  
                        else return true;
                   else if(clientiPerDiagnosi){
                        if(column!=3)
                             return false;
                        else return true;
                   else return false;
         }Panel Editor
    public class PanelEditor extends AbstractCellEditor implements TableCellEditor {
         private static final long serialVersionUID = 1L;
         private JComponent panel = null;     
         public Object getCellEditorValue() {
              return panel;
         public Component getTableCellEditorComponent(JTable table, Object value,
                   boolean isSelected, int row, int column) {
              panel = (JComponent)value;
              return panel;
    }

  • JButton.setBackground(Color color) not working

    With JDK 1.4.2, my JButtons below have a blue background. When I compile with 1.5, they are gray. I tried using setOpaque(true) on one of them below. It didn't work. Any ideas?
    class MainMenu extends JFrame
        public MainMenu() throws Exception
            super("");// no title on main menu
            JPanel pane = new JPanel(null, true);
            pane.setBackground(new Color(4194496));
            Icon icon = new ImageIcon(BizThriveMenu.getResourceDir()+"\\BizThriveSmall.gif");
            JLabel lImage = new JLabel(icon);
            JButton bEditCustomers = new JButton("<html><FONT COLOR=WHITE>Customers</FONT></html>");
            bEditCustomers.setOpaque(true);
            bEditCustomers.setBackground(new Color(4194496));
            JButton bAccounting = new JButton("<html><FONT COLOR=WHITE>Accounting</FONT></html>");
            bAccounting.setBackground(new Color(4194496));
            JButton bEditReminders = new JButton("<html><FONT COLOR=WHITE>Reminders</FONT></html>");
            bEditReminders.setBackground(new Color(4194496));
            JButton bPublish = new JButton("<html><FONT COLOR=WHITE>Publish</FONT></html>");
            bPublish.setBackground(new Color(4194496));
            JButton bExit = new JButton("<html><FONT COLOR=WHITE>Exit</FONT></html>");
            bExit.setBackground(new Color(4194496));
            bEditCustomers.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        try {
                            new TableListFrame(MainMenu.this, "customers");
                        catch (Exception e) {
                            e.printStackTrace();
            bAccounting.addActionListener(
                    new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            try {
                                new AccountCategoryListFrame(MainMenu.this, "accountCategories");
                            catch (Exception e) {
                                e.printStackTrace();
            bEditReminders.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        try {
                            new CurrentRemindersFrame(MainMenu.this);
                        catch (Exception e) {
                            e.printStackTrace();
            bPublish.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        try {
                            new Designer(MainMenu.this);
                        catch (Exception e) {
                            e.printStackTrace();
            bExit.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        System.exit(0);
            Font buttonFont = bEditCustomers.getFont();
            buttonFont = new Font("Times New Roman", Font.ITALIC+Font.BOLD, 24);
            bEditCustomers.setFont(buttonFont);
            bAccounting.setFont(buttonFont);
            bEditReminders.setFont(buttonFont);
            bPublish.setFont(buttonFont);
            bExit.setFont(buttonFont);
            pane.add(lImage);
            pane.add(bEditCustomers);
            pane.add(bAccounting);
            pane.add(bEditReminders);
            pane.add(bPublish);
            pane.add(bExit);
            int appWidth = 500;
            int appHeight = 700;
            this.setSize(new Dimension(appWidth,appHeight));
            this.setResizable(false);
            this.getContentPane().add(pane);
            Insets insets = pane.getInsets();
            lImage.setBounds(((appWidth-4-icon.getIconWidth())/2)+insets.left, 35+insets.top, icon.getIconWidth(), icon.getIconHeight());
            bEditCustomers.setBounds(((appWidth-4-235)/2)+insets.left,  200 + insets.top, 235, 40);
            bAccounting.setBounds(((appWidth-4-235)/2)+insets.left,  250 + insets.top, 235, 40);
            bEditReminders.setBounds(((appWidth-4-235)/2)+insets.left,  300 + insets.top, 235, 40);
            bPublish.setBounds(((appWidth-4-235)/2)+insets.left,  350 + insets.top, 235, 40);
            bExit.setBounds(((appWidth-4-235)/2)+insets.left,  400 + insets.top, 235, 40);
            //center application window on desktop
            Dimension screenSize = null;;
            screenSize = getToolkit().getScreenSize();
            this.setBounds((screenSize.width - appWidth)/2,
                (screenSize.height - appHeight)/2, appWidth, appHeight);
            // make the frame visible
            this.setVisible(true);
        }

    As a newbie to the forum you obviously didn't understand how to post a simple direct question, with only the relevant code to demonstrate the problem, which is why I provided you with all the extra information to help you get better answers in the future.
    Did you bother to read the link of creating an SSCCE?
    Your question is about setting the background color of a button. 99% of the code you posted is not related to that issue. Keep the code simple so we don't waste time reading through unnecessary code. That way we can determine whether the problem is with your code or the environment as I already mentioned.
    1) Though the information about setting the text color is helpful, the
    background color of the button is the subject of the posting. Please
    limit your replies to the subject of the posting.If the code posted was only related to the background color then we wouldn't have this issue now would we? When I see something strange or wrong I make a comment whether it is directly related to the question or not. It has been my experience that most people appreciate the bonus advice, so I will not change my behaviour for you. If you don't like the advice, then just ignore it.
    2) Regarding, "I don't use 1.5 so I can't really help you, but neither can
    anybody else...", please read Michael_Dunn's post, who remarkably
    was able to provide help.My comment was related to the code you provided. Nobody could use the code to compile and execute to see if it ran on their machine. So, Michael, had to waste time creating his own simple test program to see if it worked, which it did.
    My point was if you provided the same simple demo program that Michael did, then all he (or anybody else) would have had to do would be to copy, compile and test the program. You should be spending the time creating the simple test program not each of us individually. Think of how much time is wasted if everybody who wanted to help you had to create their own program? Thats why I included the link on creating an SSCCE, so the next time we don't need to waste time.
    3) ..... Otherwise, it's alright not to reply to a subject. Nobody will think less of you.Of course I don't have to replay to every question (and I don't), but if you don't learn to post a question properly you will make the same mistake again and again. That was the context of my answer. It was designed to help you ask a better question the next time.
    4) Your comment, "And don't forget to use the Code Formatting Tags > so the code retains its original formatting." That was a standard message I use for many newbies to the forum. I'm amazed at the number of people who think we are mind readers and can guess exactly what is causing the problem without posting any code. So I got tired of typing in a different message every time and I now just cut and paste. Yes I could have edited the last line out, but you would be amazed at how many people format the code the first time but then forget to do it when prompted for more detail. So I just keep it in all messages.
    Please keep your comments related to the problem. I think I've learned a think or two over the years on how to ask and answer a question.

  • JButton Background Color difference Windows/Solaris

    I have a GUI application that has several JButtons, and the program sets them to different colors based on data received from a network. The program was developed on Solaris, and the GUI has several users. We used setBackground(Color.XXX) to set the Colors. We have users that use the GUI on windows. On Solaris, the entire JButton becomes the desired color. On Windows, the JButton is gray, and only the outline of the button is in the desired color. Is there anyway to configure the Runtime Environment on Windows so that the entire button is the desired color. If not, what other options are there?
    Thank You in Advance for Your Help!!!

    I followed these threads and none of these solutions created the LAF I am after. What I ended up doing is creating my own "button" by extending JPanel. This has a consistent look across all LAF's & OS's I've tried it on. I just override mouseClicked to get the button specific behaviour that I need.
    private class MyButton extends JPanel implements MouseListener
    public MyButton(Color color)
    setBorder(BorderFactory.createRaisedBevelBorder());
    setBackground(color);
    addMouseListener(this);
    public void mouseClicked(MouseEvent e)
    public void mousePressed(MouseEvent e)
    setBorder(BorderFactory.createLoweredBevelBorder());
    public void mouseReleased(MouseEvent e)
    setBorder(BorderFactory.createRaisedBevelBorder());
    public void mouseEntered(MouseEvent e)
    public void mouseExited(MouseEvent e)
    }

  • JButton background color question

    Hi everybody,
    I have a feeling I'm going to get slammed for this, but I have to ask a very general question and hope for an answer.
    I have a JDialog on which buttons don't seem to hold their background color. That is, when I use setBackground, the only color change I get is a very thin outline of the color, and the rest of the button is white. The strange thing about the button is that the white center actually seems transparent--if I change the panel the button is on to another color besides white, the center of the button turns that color.
    I've tried to solve this problem with setOpaque( true ), setContentAreaFilled( true ), setBackground( color ), setForeground( color ), and I'm pretty sure every combination of those.
    Unfortunately, I haven't been able to reproduce this in a test case, so I can't give a SSCCE, although I've tried for a while now to make one.
    So...has anyone ever run into a problem like this and can give me some advice? I'm sorry I can't be more specific, if anyone has a question I'll do my best to answer.
    Thanks,
    Jezzica85

    I have a feeling I'm going to get slammed for this, but I have to ask a very general question and hope for an answer.Why would people be harsh on you? The only risk you take is: vague question => vague answer (or random).
    So...has anyone ever run into a problem like this and can give me some advice? I'm sorry I can't be more specific, if anyone has a question I'll do my best to answer.Never seen that myself, so I'll add a few random questions/thoughts:
    I have a JDialog on which buttons don't seem to hold their background color. That is, when I use setBackground, the only color change I get is a very thin outline of the color, and the rest of the button is white.- are you using a custom JButton subclass? If yes are you certain the subclass does not override paintComponent()?
    - If not, the button is painted by its ButtonUI. Can you tell which UI class is used (sysout(+theButton.getUI()+)?
    The UI is set according to the LookAndFeel.
    - Do you set any special LookAndFeel (+UIManager.setLookAndFeel(...)+, or look and feel's UIDefault properties in your app (generally that is done at startup)?
    - If not, can you tell the current look and feel when you bring up the dialog (+UIManager.getLookAndFeel(...)+, although that can be inferred from the ButtonUI subclass' name.
    I've tried to solve this problem with setOpaque( true ), setContentAreaFilled( true ), setBackground( color ), setForeground( color ), and I'm pretty sure every combination of those.FYI, the ButtonUI paints the button however it sees fit; in particular it doesn't have to respect the colors, opacity, filling... properties.
    Eventually:
    - are you using a custom JDialog subclass (probably, as that's generally how people write dialogs; not the best way IMHO, but there are cases where this is hard to avoid).
    I see you can't provide an SSCCE right ow, but maybe you can try to narrow the list of suspects in your side?
    - Do you reproduce the same problem at startup, if you bring the JDialog up as soon as possible?
    - Do you reproduce the problem with a mere JOPtionpane.showMessageDialog(..., theButton,...)?
    - Do you reproduce the problem outside of the JDialog context (I see you mention using a different JPanel, but is that in the dialog or somewhere else?
    Good luck with your investigations.
    Edited by: jduprez on Sep 30, 2009 8:20 AM

  • Open a UNIX terminal (with a remote login session) on JButton click

    All,
    -- The domain of this problem blurs the line which decides if this question has to be posed on a Java swing audience or a UNIX forum. To understand this problem apart from being a Java swing person, you would also need to have a basic understanding of UNIX concepts such as gnome-terminal, xterm and rsh --
    I am creating a network monitoring GUI which has a JTable having many entries that pertains to various system information about nodes in a network. I have overridden the default cellEditor in the table with a custom TableCellEditor (camickr's archive) and have a column containing JButtons labelled with hostnames.
    Now, when a user clicks on any of these buttons, I would like to open up a terminal (xterm or /usr/bin/gnome-terminal) followed by executing some commands on this NEW terminal shell. In other words, I would like to automate this process as if the user opens a terminal and then keys in commands to rsh into the remote host by specifying the hostname (which is the label on the JButton) and finally provide the user with this state, from where on she takes control on that remote login session.
    I tried searching through various previous posts. I did find a related one:
    http://forum.java.sun.com/thread.jspa?threadID=5180094&messageID=9699614#9699614
    But I still have difficulty in getting my problem solved.
    The following statements are executed when one such button (labelled by a hostname) is clicked:
    public void actionPerformed(ActionEvent e) {
             String hostname = e.getActionCommand();
                fireEditingStopped();
                System.out.println( "probing:  " + hostname); //This appears correctly on the console
                Process p;
                   try {
                        p = Runtime.getRuntime().exec("/usr/bin/gnome-terminal");
                        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                                    out.write("rsh -l root "+hostname); //attempting to remote login in the NEW shell (terminal)..... I guess :|
                   } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
    .I guess I am not having control on the new terminal. Is there any way I could control the newly spawned shell?
    Appreciate,
    Rajiv

    Alright...
    assuming gnome-terminal is in /usr/bin path,
    /usr/bin/gnome-terminal -e "<command>"
    would solve this problem

  • Disabling normal JButton click behaviour for double click

    This seems quite a poser.
    Basically I have a test JButton for testing double click speed. This is in a dialog with the JButton and a JSlider.
    I have some code which detects the double click, I add this as using 'addMouseListener()', but I need to disable the normal single click action of the JButton to replace it by the double click code calling 'doClick()'.
    How do I disable the normal single click functionality ?
    I have looked through the SDK source but cannot fathom the normal behaviour of the event mechanism.
    Many thanks in advance.
    Aaron

    Here's an entire program. When I run it, it only catches doubleclicksimport javax.swing.*;
    import java.awt.event.*;
    public class Test {
      public static void main(String[] args) {
        TestFrame testFrame = new TestFrame("Test");
        testFrame.pack();
        testFrame.setSize(200,200);
        testFrame.show();
    class TestFrame extends JFrame {
      public TestFrame(String Title) {
        super(Title);
        JPanel myContent = (JPanel)getContentPane();
        JButton myButton = new JButton("Hello");
        myContent.add(myButton);
        myButton.addMouseListener(new MouseAdapter() {
          public void mouseReleased(MouseEvent me) {
         if (me.getClickCount()==2) System.out.println("DoubleClick!!");
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); }
    }

  • JButton Text Color help......

    Hey,
    I have tried everything that does not work to change the color of the text on a JButton I have in a JPanel. Does anyone know how to do this. I need the actual text on the button to be a different color than black..This is an application so I am not using public void paint( Graphics g);
    buttons[1] = new JButton("Open");
    buttons[1].addActionListener(this);
    That is a sample of my button creation code..I just need to change the word "Open"s color...

    http://java.sun.com/docs/books/tutorial/uiswing/components/html.html
    Run the HtmlDemo app as available from that page.
    Regards,
    lutha

  • JButton clicked problem?

    I have a Jbutton and on button clicked, action is performed.
    Now if mouse is just clicked but moved only one pixel(means focus is still on the button) , action will not occur. It works only if the button is clicked and mouse does not move at all. I want action if the button is clicked and does not leave the button forground area until it is released.
    thnx

    Sounds like there is a problem in your code. Only can make wild guesses based on the lack of info. (If you post code, please spare us the pain of looking at all of it, just create a simple example).

  • Resizing JFrame with a Jbutton click

    I've witten a simple GUI program that if you click on one button it increases the size of the JFrame and the other button will decrease it. The problem is I tried using ComponentResize() putting a listener on the buttons,but it wouldn't work. Anybody with an idea of how I could do this?

    try this code
    public void actionListener (ActionEvent e)
           int increment = 20;
           frame.setBounds (0,0,frame.getWidth()+increment,frame.getWidth()+increment);
    }

  • JButton background color on XP difference with theme classic and XP

    Hi all,
    I got a problem on Windows XP JSE 1.5.0_01 when trying to set the
    background of a JButton (or to be more precise of a subclass of
    JButton, but no override of paint or paint Component).
    The button background behaviour is correct with the theme Windows
    classic but not with XP Windows one. In the later case, only the
    background below the button is coloured, the rest is grey: impossible
    to modify the colour of the button itself.
    Any idea?
    F.

    It did.
    Thanx a lot.
    F.
    Maybe this thread will help you:
    http://forum.java.sun.com/thread.jspa?forumID=57&threa
    dID=430926

Maybe you are looking for