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

x
?
Solved

JComboBox selection

Posted on 2000-03-19
2
Medium Priority
?
212 Views
Last Modified: 2012-05-04
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
Comment
Question by:hpchong7
[X]
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
2 Comments
 

Accepted Solution

by:
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() {
        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
 
LVL 2

Author Comment

by:hpchong7
ID: 2648767
thanks!
0

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