NumericStepper/ComboBox problems
Hello. I have a learning interaction that utilizes
NumericStepper component instances as well as ComboBox instances.
The file was working fine until yesterday when all of a sudden the
text field that displays users' selections no longer does so. Any
ideas about how these components suddenly "broke"? Is there a way I
can fix this?
Thanks
watch for duplicate instance names and watch for component
conflict where one component causes a problem with another and
watch for an embedded font issue.
Similar Messages
-
Ok, I have a simple ComboBox with instance name of dragonCombo
A Lable with an instance name of dragonLabel
Using a an AS3 called Dragon.as
When the ComboBox is clicked, a picture should pull up. The problem is, there are no errors, but The ComboBox is not listing any of the Labels I loaded. This is my AS3 code, maybe someone can see the mistake I have made somewhere.
package
import flash.display.MovieClip;
import flash.display.Loader;
import fl.controls.ComboBox;
import fl.data.DataProvider;
import flash.events.Event;
import flash.text.TextFieldAutoSize;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import fl.controls.Label;
public class Dragons extends MovieClip{
public var dragonCombo:ComboBox;
public var dragonLabel:Label;
var comboDP:DataProvider;
var dragonLoader:Loader;
public function Dragons() {
setupComboDP();
setupdDragonCombo();
setupLabels();
private function setupComboDP():void{
comboDP = new DataProvider();
comboDP.addItem({ Label:"Fire"});
comboDP.addItem({ Label:"IceNFire"});
comboDP.addItem({ Label:"Ghost"});
private function setupDragonCombo():void{
dragonCombo.width = 150;
dragonCombo.prompt = "Choose a Dragon";
dragonCombo.dataProvider = comboDP;
dragonLoader = new Loader();
dragonLoader.x = 200.00;
dragonLoader.y = 60.00;
addChild(dragonLoader);
dragonCombo.addEventListener(Event.CHANGE,loadData);
public function setupLabels():void{
dragonLabel.text="";
dragonLabel.autoSize = dragonLabel.autoSize = TextFieldAutoSize.LEFT;
public function loadData(e:Event):void{
dragonLoader.load(new URLRequest("dragons3/"+e.target.selectedItem.Label.toLowerCase()+".png"));Your Dragons class is creating its own dragonCombo (it is not the one on the stage)...
public var dragonCombo:ComboBox;
that has no association with the combobox you placed on the stage manually as far as I can see.
Assuming this is not your document class, if all you are doing is importing the Dragons class, then you are not implementing it at all. You would have to have a line...
var dragons:Dragons = new Dragons();
in you fla in order to instantiate the class. At that point you might start seeing error messages because in doing that your class is trying to target an object that doesn't exist because it only declared the combobox, it did not create an instance of it, as in...
dragonCombo = new ComboBox(); -
Hi,
With the help of JDC i am able to finish the work of creating the customized comobo but I'm stuck at the edge.
I have a customized comobobox, which can show multiple columns in its combo popup, but only one item of column should be shown as selected in combo, This i achieved when combobox status is editable. but not working when combo is non editable.
kindly see( can execute too ) the code and let me know where i'am going wrong.
public class TestCoeusComboBox2 extends javax.swing.JFrame {
/** Creates new form TestCoeusComboBox2 */
public TestCoeusComboBox2() {
initComponents();
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
//jPanel1.setLayout( new java.awt.GridLayout(2,4,10,10));
jPanel1.setLayout( new java.awt.FlowLayout());
java.util.Vector people = new java.util.Vector();
for( int i= 0 ; i< 15 ; i++ ){
people.add(new ComboBoxBean(""+i,"Yaman kumar-"+i));
javaEditable = new javax.swing.JLabel("java-Editable");
javaNonEditable = new javax.swing.JLabel("java-NON Editable");
coeusEditable = new javax.swing.JLabel("Coeus - Editable ");
coeusNonEditable = new javax.swing.JLabel("Coeus - NON Editable");
coeusComboEditable = new CoeusComboBox(people,true);
coeusComboEditable.setPopupSelectionBackground(Color.yellow);
coeusComboEditable.setPopupBackground(Color.white);
coeusComboNonEditable = new CoeusComboBox(people,false);
coeusComboNonEditable.setPopupSelectionBackground(Color.gray);
coeusComboNonEditable.setPopupBackground(Color.white);
javaComboEditable = new javax.swing.JComboBox(people);
javaComboEditable.setEditable(true);
javaComboNonEditable = new javax.swing.JComboBox(people);
javaComboNonEditable.setEditable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
jPanel1.setPreferredSize(new java.awt.Dimension(1000, 200));
jPanel1.add(javaEditable); jPanel1.add(javaComboEditable);
jPanel1.add(javaNonEditable); jPanel1.add(javaComboNonEditable);
jPanel1.add(coeusEditable); jPanel1.add(coeusComboEditable);
jPanel1.add(coeusNonEditable); jPanel1.add(coeusComboNonEditable);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
pack();
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
* @param args the command line arguments
public static void main(String args[]) {
new TestCoeusComboBox2().show();
private javax.swing.JPanel jPanel1;
private CoeusComboBox coeusComboEditable;
private CoeusComboBox coeusComboNonEditable;
private javax.swing.JComboBox javaComboEditable;
private javax.swing.JComboBox javaComboNonEditable;
private javax.swing.JLabel javaEditable;
private javax.swing.JLabel javaNonEditable;
private javax.swing.JLabel coeusEditable;
private javax.swing.JLabel coeusNonEditable;
* @(#)CoeusComboBox.java 08/29/2002, 5:06 AM
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.event.*;
import java.util.Vector;
import javax.swing.border.*;
public class CoeusComboBox extends JComboBox {
private boolean editable = false;
private Color popupSelBackground ;
private Color popupBackGround;
* Initializes the properties of CoeusComboBox as it needs to set custom Renderers
* and Editors for CoeusComboBox
private void initProperties(){
CoeusComboBoxRenderer renderer= new CoeusComboBoxRenderer();
CoeusComboCellEditor editor = new CoeusComboCellEditor();
setBorder(new LineBorder(Color.black,1));
setRenderer(renderer);
setEditor(editor);
//setEditable(true);
/** Creates a new instance of CoeusComboBox */
public CoeusComboBox() {
super();
setUI(new StateComboBoxUI());
initProperties();
* Constructor with default ComboBoxModel
public CoeusComboBox(ComboBoxModel aModel) {
super(aModel);
setUI(new StateComboBoxUI());
initProperties();
* Constructor with default items that are shown in popup when the combo is selected
public CoeusComboBox(final Object[] items) {
super(items);
setUI(new StateComboBoxUI());
initProperties();
* Constructor with default items that are shown in popup when the combo is selected
* @param items An array of elements that are shown in popup
* @param editable Status of ComboBox, If true the combobox value can be modified.
public CoeusComboBox(final Object[] items, boolean editable) {
super( items);
this.editable =editable;
setEditable(editable);
setUI(new StateComboBoxUI());
initProperties();
* Constructor with default items that are shown in popup when the combo is selected
* @param items a Vector of combobox items.
public CoeusComboBox(Vector items) {
super(items);
setUI(new StateComboBoxUI());
initProperties();
* Constructor with default items that are shown in popup when the combo is selected
* @param items A vector of items that are shown in popup
* @param editable Status of ComboBox, If true the combobox value can be modified.
public CoeusComboBox(Vector items, boolean editable){
super( items);
this.editable = editable;
setEditable(editable);
setUI(new StateComboBoxUI());
initProperties();
* Sets combobox Popup Background Color
* @param color background color of Combobox popup.
public void setPopupBackground( Color color){
this.popupBackGround = color;
* Sets combobox Popup Selection Background Color
* @param color Selected Item background color of Combobox popup.
public void setPopupSelectionBackground( Color color){
this.popupSelBackground = color;
* Sets the Status(Editable/NonEditable) of combobox, Based on which the combo
* value can be changed. Default is not editable
* @param flag If true the combobox is editable.
// public void setEditable( boolean flag){
// editable = flag;
* An inner class to set the Default renderer for CoeusComboBox. As this combobox
* can show multiple columns in combo popup, so add number columns to this panel, like
* that as many as number panel will be added to panel as many items available in combobox.
* that is rendered in every cell.
class CoeusComboBoxRenderer extends JPanel implements ListCellRenderer {
private JLabel left;
private JLabel right;
private JLabel middle;
* Constructor to set the layout and border for this panel.
public CoeusComboBoxRenderer() {
//setLayout(new GridLayout(1, 2,0,0));
BoxLayout boxLayout =new BoxLayout(this,BoxLayout.X_AXIS);
setLayout( boxLayout);
setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
left = new JLabel();
middle= new JLabel();
right = new JLabel();
add(left);
add(middle);
add(right);
* An overridden method to render this component in desired cell.
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (isSelected) {
if(popupSelBackground == null ){
popupSelBackground = list.getSelectionBackground();
setBackground(popupSelBackground);
setForeground(list.getSelectionForeground());
} else {
if( popupBackGround == null){
popupBackGround = list.getBackground();
setBackground(popupBackGround);
setForeground(list.getForeground());
if( value instanceof ComboBoxBean ){
ComboBoxBean comboBoxBean = (ComboBoxBean) value;
left.setText(comboBoxBean.getCode());
middle.setText(" ");
right.setText(comboBoxBean.getDescription());
return this;
}// end of CoeusComboBoxRenderer class
* An inner class to set the editor of CoeusComboBox when it gets focus and about to be
* selected by the user
class CoeusComboCellEditor extends javax.swing.plaf.basic.BasicComboBoxEditor {
public CoeusComboCellEditor() {
super();
System.out.println(" editable "+editable);
editor.setEditable(true);
//editor.setBackground(editorSelBackground);
}// end of CoeusComboCellEditor
}// end of CoeusComboBox
* @(#)StateComboBoxUI.java 08/20/2002 9:21 AM
import javax.swing.plaf.basic.*;
import javax.swing.*;
public class StateComboBoxUI extends BasicComboBoxUI{
* Creates the ComboBox popup that is displayed when the implemented combobox is selected.
* As in Basic LAF the combobox does not provide the horizontal scrollbar for popup this
* method is overridden with that property.
protected ComboPopup createPopup(){
BasicComboPopup popup = new BasicComboPopup(comboBox){
protected JScrollPane createScroller() {
return new JScrollPane( list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
}//end of method createScroller
return popup;
}//end of method createPopup
* The Class is used to populate any combo box
public class ComboBoxBean implements java.io.Serializable{
private String code;
private String description="";
/** Default Constructor */
public ComboBoxBean() {
/** Constructor with parameters */
public ComboBoxBean(String code, String description) {
this.code = code; this.description = description;
* This method gets the Code
* @return String code
public String getCode() {
return code;
* This method sets the Code
* @param String code
public void setCode(String code) {
this.code = code;
* This method gets the Description
* @return String description
public String getDescription() {
return description;
* This method sets the Description
* @param String description
public void setDescription(String description) {
this.description = description;
public String toString(){
return getDescription();Gregor,
As an alternative way i did take "selectedItem" away from MXML and used it on "creationComplete". But not i am running in to different problem which i am going to open as new discussion.
Between i have documented this issue on my blog @ http://www.srinivaskusunam.com/2009/05/13/flex-combobox-selecteditem-problem/
Thanks,
Srini -
HTML component blinking cursor and combobox problems
Hi there.
I have a problem using a website displayed with the HTML component in a spark window. In any textfield in this homepage there is no blinking cursor displayed which is not really a problem but is still pretty confusing to the users. Another issue comes up with the comboboxes where the possible choices cannot be clicked with the mouse. Choosing an entry with the keyboard is possible though.
To reproduce this issue, add a html component in a spark window and load for example http://www.ard.de. The cursor is blinking in the search textfield in the top left. After clicking on the combobox on the left side - where i can't choose an entry with the mouse - the cursor in the textfield is no longer displayed.
Is this a known issue?
Best regardsHi,
I've looked at your example and found the following 2 issues:
1. The cursor not appearing was actually a focus issue and you can fix it by adding an event listener on "windowActivate" in which to re-set the focus to the _htmlWindow. See the code below for more details on "onActivate()"
2. The issue with the dropdown is actually a bug (internal bug id #2721855) and it has been fixed in the next version of AIR which will be released towards the end of this year.
<?xml version="1.0" encoding="utf-8"?>
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
windowDeactivate="onDeactivate()"
windowActivate="onActivate()"
alwaysInFront="true"
showStatusBar="false"
title="WebKit Browser"
creationComplete="onCreationComplete()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.profiler.showRedrawRegions;
import mx.controls.Alert;
import mx.managers.CursorManager;
import mx.managers.HistoryManager;
[Bindable]
private var _location:String;
private function onCreationComplete():void {
nativeWindow.x = Capabilities.screenResolutionX * 0.1;
nativeWindow.y = Capabilities.screenResolutionY * 0.1;
nativeWindow.width = Capabilities.screenResolutionX * 0.8;
nativeWindow.height = Capabilities.screenResolutionY * 0.8;
// call this function on "windowActivate" in order to re-set the focus on your html element
private function onActivate():void {
_htmlWindow.setFocus();
private function onDeactivate():void {
try {
if (nativeWindow)
nativeWindow.activate();
} catch (e:Error) { // nativeWindow Object not yet available
public function set location(value:String):void {
_location = value;
showStatusBar = false;
status = "Lade " + value + "...";
CursorManager.setBusyCursor();
public function get location():String {
return _location;
private function onHTMLComplete():void {
CursorManager.removeBusyCursor();
showStatusBar = false;
private function uncaughtScriptExecution(e:HTMLUncaughtScriptExceptionEvent):void {
CursorManager.removeBusyCursor();
Alert.show("Scriptfehler: " + e.exceptionValue, "Error", Alert.OK);
]]>
</fx:Script>
<mx:HTML id="_htmlWindow"
width="100%"
height="100%"
runtimeApplicationDomain="{ApplicationDomain.currentDomain}"
complete="onHTMLComplete()"
location="{_location}"
uncaughtScriptException="uncaughtScriptExecution(event)">
</mx:HTML>
</s:Window>
Regards,
Catalin -
Hi!
I'm having problems with the combobox component. I'm calling
a swf file, with a combobox with options, within another swf, and
the combobox does not display the options, it only higlight in
green the arrow, but not display nothing.
any idea is welcome.
thanks in advance.Your question is a little bit confusing. Can you explain it a
bit more?
Are you loading a swf with a comboBox into another swf?
Dan Mode
*THE online Radio*
http://www.tornadostream.com
*Must Read*
http://www.smithmediafusion.com/blog
*Flash Helps*
http://www.smithmediafusion.com/blog/?cat=11
"Ma?" <[email protected]> wrote in message
news:eadcft$9eh$[email protected]..
> Hi!
>
> I'm having problems with the combobox component. I'm
calling a swf file,
> with
> a combobox with options, within another swf, and the
combobox does not
> display
> the options, it only higlight in green the arrow, but
not display nothing.
>
> any idea is welcome.
>
> thanks in advance.
> -
Hi,
I have a jsp-page with two frames. The leftone has values from the database with a combobox and in the left one you could insert values to the database.
My problem is that when adding values in the right frame to the database the right frame will not update the changes unless i press the refresh button un the browser. How can i update the combobox in the left frame when i have made changes to the database without having to press the refresh button on the browser?If you are submitting one page, the other can be reloaded using Javascript automatically when the submitted page comes back...
<body ... onload="top.document.frames['nameOfLeftFrame'].document.location.reload();"> -
ComboBox problems when in a MovieClip loaded at runtime
Hello,
I hope someone out there can help me with this problem: I
have a ScrollPane that contains a MovieClip that to which I attach
several other MovieClips at runtime in response to user inputs
using attachMoveClip() (both MCs are in my library and set to
export for actionscrip in first frame). Each of those MovieClips
contains a ComboBox.
At runtime, I attach the MovieClip containing the ComboBox,
then I set the dataProvider property for the ComboBox to a list
(Array) of data/label value pairs. I then try to set the text
property of the ComboBox to a "Please select a value" message and
then I add a couple of listeners.
Setting the dataProvider property sort of works: the ComboBox
displays the proper dropdown list when clicked, but nothing happens
when I select an item from the dropdown list - i.e., the selected
value doesn't display in the ComboBox's TextField.
Setting the text property doesn't seem to work: the value
doesn't display in the ComboBox's TextField, but oddly, if I trace
the ComboBox's text property, it outputs the correct message.
Also, none of the event handlers work at all.
I tried all of the same code on a ComboBox that isn't created
dynamically, and it all works.
Here's the code. The first set of code is the part I need to
get working. It sets up the ComboBox after the MovieClip it is
contained in is attached to the parent MovieClip. The second set of
code was my test code to see if this worked on a ComboBox that
isn't created at runtime. It all works properly.Most likely the Combobox isn't fully loaded yet. In your code
check if a property of the cb is undefined using an interval and
proceed with the code when the property is defined. -
ComboBox Problem to change the size of selected text in JTextPane.
hi 2 all!
I have a problem in combo box actions, when i change the item in the combo its set is not set at that time but that action is performed when next action is taken, i have used combobox.setAction(new StyledEditorKit.FontSizeAction(" click", 12);) command to set the size of the selected text
Plz suggest the solution also if possible,plz provide some code for this
Action action1 = new StyledEditorKit.FontSizeAction(
"double click", 12);
Action action2 = new StyledEditorKit.FontSizeAction(
"double click", 14);
Action action3 = new StyledEditorKit.FontSizeAction(
"double click", 18);
s2 = (String) cb7.getSelectedItem();
if (s2.equals("Small")) {
cb7.setAction(action1);
e1.setSource(cb7);
} else
if (s2.equals("Medium")) {
cb7.setAction(action2);
e1.setSource(cb7);
} else if (s2.equals("Large")) {
cb7.setAction(action3);
// e1.setSource(cb7);
when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.
thanx in advance..this code is not working properly according to the action i set on comboBox.Thats correct, the setAction() method is used to invoke an existing Action on the combo box, not create a new Action.
What you need to do is have a single action that uses the information from the item that was selected to build a dynamic Action to change the font. Something like:
public void actionPerformed(ActionEvent e)
JComboBox comboBox = (JComboBox)e.getSource();
int fontSize = Integer.parseInt( comboBox.getSelectedItem().toString() );
Action fontAction = new StyledEditorKit.FontSizeAction("size", fontSize);
fontAction.actionPerformed(null);
} -
From using a tutorial from a website.. it places a JComboBox in first column the ComboBox elements are: "item1", "item2", "item3", all rows are given these values.
How can I do it such that JComboBox have different values for each row?
JTable table = new JTable();
DefaultTableModel model = (DefaultTableModel)table.getModel();
// Add some columns
model.addColumn("A", new Object[]{"item1"});
model.addColumn("B", new Object[]{"item2"});
// These are the combobox values
String[] values = new String[]{"item1", "item2", "item3"};
// Set the combobox editor on the 1st visible column
int vColIndex = 0;
TableColumn col = table.getColumnModel().getColumn(vColIndex);
col.setCellEditor(new MyComboBoxEditor(values));
// If the cell should appear like a combobox in its
// non-editing state, also set the combobox renderer
col.setCellRenderer(new MyComboBoxRenderer(values));
public class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
public MyComboBoxRenderer(String[] items) {
super(items);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
// Select the current value
setSelectedItem(value);
return this;
public class MyComboBoxEditor extends DefaultCellEditor {
public MyComboBoxEditor(String[] items) {
super(new JComboBox(items));
}thank you for informing me, i will be posting question on that, the solution is helpful...but not sufficient..
For ref. the topic is:
http://forum.java.sun.com/thread.jspa?threadID=606573 -
Combobox dropdown doesn't refresh
Hi all!
I have a comboBox problem. Please test this simple code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var dp:ArrayCollection;
private function init():void
dp = new ArrayCollection(["one", "two"]);
]]>
</mx:Script>
<mx:ComboBox id="cb" dataProvider="{dp}"/>
<mx:Button label="click me" click="dp = new ArrayCollection(['three', 'four']);dp.refresh()"/>
</mx:Application>
What happens is that the dropdown list of the combobox doesn't show the new values. I guess I'm overlooking something here.
Any advice?
Thanks!
DanyHi Archimedia,
I have run the sample code that you have sent....but I could see no problem I could see the combobox being refreshed when the button being clicked.
However it is always safer to remove all the elements in the ArrayCollection using the removeAll() method before assigning the new values.
Try the below code and check whether it's working for you...?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()"
>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
Bindable]
private var dp:ArrayCollection;
private function init():void
dp =
new ArrayCollection(["one", "two"]);}
private function refreshComboBox():void
if(dp != null){
dp.removeAll();
dp.refresh();
dp =
new ArrayCollection(['three', 'four']);}
]]>
</mx:Script>
<mx:ComboBox id="cb" dataProvider="{dp}"/>
<mx:Button label="click me" click="refreshComboBox()"/></mx:Application>
If this post answers your question or helps, please kindly mark it as such.
Thanks,
Bhasker Chari -
Hello,
In my application, I open a JComboBox inside a JPanel.
But the combo box is wierd : the top line is badly drawn. In non editable mode, the current text is drawn, but the arrow is not. In editable mode, nothing is drawn, just a gray line. But the combo box is active : when I click on the top line, the list appears, properly drawn.
The JPanel is set to opaque. It has a layout manager set to null, and I use setbounds to set the position and size of the combo box. But I have tried also with a layout manager, and the result is the same.
The paint function of the JPanel draws an image in the back every 1/50 second. I have tried to remove this regular paint, and the result is the same.
For your information, Labels and ListBox work perfectly in this application.
I do not understand what is going wrong. Does anyone has an idea?
Thanks, FrancoisHello,
I have made a simple application that deponstrates the problem. Here is the main class :
* ComboBox problems demonstration
package combotry;
import java.awt.*;
import javax.swing.*;
public class Main
JFrame window;
CPanel panel;
JComboBox combo;
public Main()
public void run()
// Creates a JFrame without layout manager
window = new JFrame() ;
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setLayout(null);
// Creates panel
panel=new CPanel();
panel.setPreferredSize(new Dimension(640, 480));
panel.setLayout(null);
window.getContentPane().add(panel);
panel.setOpaque(true);
// Position window and panel
window.setVisible(true);
Insets insets=window.getInsets();
int width=640+insets.left+insets.right;
int height=480+insets.top+insets.bottom;
window.setSize(width, height);
panel.setBounds(0, 0, 640, 480);
// Creates combobox
String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
combo=new JComboBox(petStrings);
combo.setSelectedIndex(4);
Dimension d=combo.getPreferredSize();
combo.setEditable(true);
combo.setVisible(true);
panel.add(combo);
combo.setBounds(100, 100, 250, d.height);
// Main loop
do
try
Thread t=Thread.currentThread();
t.sleep(20);
catch(InterruptedException e)
}while(true);
public static void main(String[] args)
new Main().run();
}And here is the Panel class :
* CPanel.java
package combotry;
import javax.swing.*;
import java.awt.*;
public class CPanel extends JPanel
public CPanel()
protected void paintComponent(Graphics g)
Graphics2D g2=(Graphics2D)g;
Color c=new Color(0xFFFFFF);
g2.setColor(c);
g2.fillRect(0, 0, 640, 480);
}If you run this application, you will see that the combo box top line is gray. When you click on it, the list opens. But no arrow, just a gray line. Same behavior (a little better) if you set editable to false.
Any idea anyone? -
Transfer of the variable through JComboBox
Hello people,
I have the following question. In the main JFrame class i put on the JPanel JComboBox. Depending on the values i choose with the help of JCombobox, my following program shoud change the behavior, then in one of classes which is called from another class i use the chosen value.
so, should i again call main class in one of subclasses with the aim to transfer of the given value.? When i call the main the program was hanging,
Thank you in advance
GJavagirlMy
AnimatorFrame.class calls 2 classes
Animator11 and Animator33
Animator33 calls ReadFile.class, but the value (the name of the file is defined in the AnimatorFrame ,
i see only one way to call Animator33(filename), which calles the ReadFile(filename)
Finally my main program doesn't work, what wrong with it?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class AnimatorFrame extends JFrame implements ActionListener
Animator11 an1;
Animator33 an3;
JButton okbutton,endbutton;
JPanel buttonPanel;
public AnimatorFrame() {
super("Animator");
addWindowListener(new WindowDestroyer());
createComponents();
pack();
setVisible(true);
private void createComponents() {
Container c=getContentPane();
buttonPanel=new JPanel();
okbutton=new JButton("Start");
endbutton=new JButton("Stop");
buttonPanel.add(okbutton,BorderLayout.CENTER);
buttonPanel.add(endbutton,BorderLayout.CENTER);
an1=new Animator11();
an3=new Animator33();
an1.setLayout(new BorderLayout());
an1.add(an3, BorderLayout.NORTH);
an1.add(buttonPanel,BorderLayout.CENTER);
c.add(an1, BorderLayout.SOUTH);
public void startAnimation() {
an1.start();
an3.start();
public void actionPerforme(ActionEvent e)
if(e.getActionCommand().equals("Start"))
this.startAnimation();
if(e.getActionCommand().equals("Stop"))
System.exit(0);
public static void main(String[] args) {
AnimatorFrame f=new AnimatorFrame();
f.createComponents();
f.setVisible(true);
// f.startAnimation();
}It gives animator class must be declared abstract!
i didn't present here ComboBox problem...... -
Hello,
I am almost finished with a large Flex 2.01 project and
wanted to see if there would be any problems with the Application
porting to Flex 3 plus I wouldn't mind trying out some of the cool
features that were implemented. After installing Flex 3, The
Coldfusion Extensions, and the New Cairngorm everything work fine.
So I compiled my Application to take a look an here are a few
things I have noticed so far:
Combo Box component: No Arrow Button and the Selected State
is not rendering correctly.
Measurements on Some buttons are not correct. It seems some
of the text in the button labels are not getting measured correctly
with the label showing up as BUT... instead of BUTTON.
I think there might have been changes in the CSS in Flex that
I have not had a chance to investigate. The custom components and
standard components have been styled with CSS so the problem might
be there.
As far as Flex Builder it seems to be faster at compiling and
the over all performance of the Application has improved
Keep up the great work.
RichHi Rich,
There were some layout changes to Button, which can result it
some labels being truncated. Please see the compatability doc for
more information, and instructions on how to switch to
compatability mode:
http://labs.adobe.com/wiki/index.php/Flex_3:Backwards_Compatibility_Flag
Regarding the ComboBox problems, please log a bug at
http://bugs.adobe.com/flex
Glenn -
[svn:fx-trunk] 12971: Remove obsolete code.
Revision: 12971
Revision: 12971
Author: [email protected]
Date: 2009-12-15 14:01:01 -0800 (Tue, 15 Dec 2009)
Log Message:
Remove obsolete code. We no longer need the override in RichEditableTextEditManager to force remeasure when one or both of the width and height is auto-sizing and we are typing. Each insert will trigger the damageHandler which now invalidates the size and if "auto-sizing" will remeasure the text and the update the display.
QE notes:
Doc notes:
Bugs:
Reviewer: Gordon
Tests run: checkintests, TextArea, TextInput, NumericStepper, ComboBox
Is noteworthy for integration: no
Modified Paths:
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/RichEditableText.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/RichEditable TextEditManager.as -
Problem setting Index value on ComboBox
I am running into a problem with setting the index on a
dropdown box. I will try to give as much detail as possible. From
what I can tell, it should be working and does, but only for one
item. If anyone can suggest a different group to post to, let me
know. I can not find a solution anywhere.
I have the following code to show a combobox. The data is
derived from a XML config file. The combobox itself works fine and
does in fact show all of the data from the XML config file.
<mx:HBox>
<mx:Label text="Status" width="55"/>
<mx:ComboBox id="uxstatus" dataProvider="{_xmlVulnStatus}"
labelField="status"/>
</mx:HBox>
The part of the XML config file that is used to populate the
combobox.
<mainconfig>
<vulnstatus>
<status>Open</status>
<status>In Progress</status>
<status>Closed</status>
</vulnstatus>
</mainconfig>
Now, when a user selects an item from a separate datagrid, on
change I have it run the following function. The function reads in
the data, parses it and compares the "status" value from the
datagrid info with the "status" options in the XML config file.
When it matches, it sets the index number for the combobox so it
shows the right data. My problem is below the function.
public function parseMSVulnStatus(evt:Event):void {
var xmlMSV:XML = XML(msdetailed.selectedItem); //the host
dataProvider item
//trace ("MS Vuln status = "+xmlMSV.status);
for ( var MSVi:Number=0; MSVi<_xmlVulnStatus.length();
MSVi++ ) { //loop over the items in the dataProvider
var sDataValueCurMSV:String =
_xmlVulnStatus[MSVi].valueOf(); //get the current item.data value
if ( sDataValueCurMSV == xmlMSV.status ) { //compare desired
value to current item.data value
mx.controls.Alert.show("match found - MS Vuln status =
"+xmlMSV.status +" and MSVi = " +MSVi);
msstatus.selectedIndex = MSVi; //set the seletedIndex of the
combo box
else {msstatus.selectedIndex = -1}
if (msdetailed.selectedItem.falsepos=='Y')
{msfalsepos.selected=true;}
The problem. If the value from the datagrid is "Closed", it
shows the index as being "2" and sets the combobox index
appropriately and displays "Closed". The alert box is displayed
(for testing) to show the values.
If the value from the datagrid is either "Open" or "In
Progress", it does show the proper index as being either 0 or 1,
respectively and shows the alert box. However, the combobox appears
to be set to -1. I have verified the data is set properly in the
database (which is what populates the datagrid).
Any thoughts on this? Based on my alert box, it appears that
the data is seen properly and that it knows how to set the index of
the combobox.... it's just not happening (unless it's "Closed").
Thanks in advance.
Chrisyou could force a selected index using something like
mydatagrid.selectedIndex=0 or 1 try this pos i made for someone
beacause if you want to cange the value of field based on selection
this could be simpler by using an xml file with all the value for
each record in one object
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1273227&CF ID=48614795&CFTOKEN=89f80916a77a7788-F5418AD3-F360-8283-2DCCA603D0E18DCF&jsessionid=48307b ef3fdf5663544a
Maybe you are looking for
-
Just recently my Creative Cloud files are not showing up in either the Library or Develop tab when I have already previously moved them over. The arrow on the navigator tabs that is beside Creative Cloud is not solid as where it was before I started
-
Issue in migrating analysis service job from one server to another
Hi All, I'm migrating analysis services from one server to another, within the source server there is a job with the name denreportingprocess which executes a batch file within local drive on server. I have moved all the analysis services cubes from
-
Modifying a pdf page using Javascript
Hi all, - I am having an html report that consists of many html pages. - Each page of these html pages contains a table or more, in addition to some buttons that hides/display specific rows in these tables. And these buttons are programmed using Java
-
RunState.Caller.Sequence.AsPropertyObject does not return the comment
RunState.Caller.Sequence.AsPropertyObject.Comment gives a null string but RunState.Caller.Sequence.AsPropertyObject.Name does give the right name of the sequence any idea what teststand is doing here
-
Accordion Issue with Spry 1.6
I have not been able to make the Accordion widget operate consistently in IE 7. Occasionally it will not display all the information within the Panel tab. An example, using IE7, can be seen when repeatedly selecting California at www.Qualite1.com/con