Solved

JComboBox selection

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

688 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