Solved

JComboBox selection

Posted on 2000-03-19
2
203 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
2 Comments
 

Accepted Solution

by:
n_vadim earned 8 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now