Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

JComboBox selection

Dear,

    In my application,left hand side is a Jtextarea,right handside is a JComboBox.I don't know why when I make a selection in the combo box,the text inside the textarea disappear!How can I prevent this(ie.I make selections and the text remains in the textarea)Thanks!

ps:Is selection in combo box invokes repaint?
0
hpchong7
Asked:
hpchong7
1 Solution
 
n_vadimCommented:
Hello hpchong7,

It is possible, I did not understand the question, but in this example all is OK:

import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class ListDemo1 extends JFrame {
    public ListDemo1() {
        super("ListDemo1");
        JPanel screenPane = new JPanel();
        screenPane.add(new JTextArea("Hello world Hello world Hello world"));
        String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
        screenPane.add(new JComboBox(petStrings));
        getContentPane().add(screenPane);
    }
    public static void main(String s[]) {
        JFrame frame = new ListDemo1();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        frame.pack();
        frame.setVisible(true);
    }
}

Best Regards,
n_vadim
0
 
hpchong7Author Commented:
thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now