Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


JComboBox selection

Posted on 2000-03-19
Medium Priority
Last Modified: 2012-05-04

    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?
Question by:hpchong7
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

n_vadim earned 16 total points
ID: 2633139
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() {
        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));
    public static void main(String s[]) {
        JFrame frame = new ListDemo1();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}

Best Regards,

Author Comment

ID: 2648767

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question