Action event from jComboBox1 to setModel for jComboBox2

I am an extreme newbie. Sorry if the answer to this is obvious. I have 1 combo box(paperType) that has 2 items. Depending on which item is selected on jComboBox1, i want it to set the model for jComboBox2(weightBox). Using NetBeans IDE 6.5.1 - it is telling me that "_setModel(javax.swing.ComboBoxModel) in javax.swing.JComboBox cannot be applied to (java.lang.String[]_)". Here is the code I am trying to use:
private void paperTypeActionPerformed(java.awt.event.ActionEvent evt) {                                         
final String papType = (String)paperType.getSelectedItem();
{String[]texwgtString = { "50", "60", "70", "80", "100" };
{String[] covwgtString = {"65", "80", "100", "120"};
if(papType == "Text/Book"){
weightBox.setModel(texwgtString) ;
else weightBox.setModel(covwgtString);
What am I doing wrong? Again, I am still way new at this.
Thanks, Dave

To post code, use the code tags -- [code]Your Code[/code] will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
Read the API for JComboBox. What is the Type of the parameter to setModel? And what is the Type of your variable reference texwgtString?
Apart from that, you also have misplaced braces in the code you posted.
db

Similar Messages

  • Missing Action Event from Custom Component

    Hi JSF Gurus,
    I have two custom components, both extends UICommand and have their
    own renderers. I use them on two seperate pages, say component1 on
    page1 and component2 on page2. And page2 is include inside page2.
    I registered an action listener on component2. When the composite page
    is rendered, I clicked on component2. However, the registered action
    listener was not invoked. Inside the debugging (I'm using IntelliJ
    IDEA 5.0) I set a breakpoint inside the decode method of Renderer2
    (renderer for component2). I do see the componen2 actually as an
    actionLister method binding being set to correct value. I do queue the
    new action event to component2 at the end of the decode method. But
    the action listerner never invoke.
    Any idea what did I miss?
    Thanks,
    Edmond

    Hi Yuki,
    Yeah, after I turn on detail JSF debugging as instructed by the book Core JavaServer Faces, I figured out I had a validation error. That solves the mystery.
    Thanks,
    Edmond

  • Generate action events from objects

    Is there a way to have an object generate an event for a component just as if that component had received the event from the user?
    i.e. I have a JPanel that has a MouseListener added to it. Can I have a separate object (or actually just having the JPanel do it itself would be fine) create a MouseEvent and fire it to the MouseListener so that the code in the MouseAdapter's MouseClicked method gets run?
    Thanks,
    Matt

    I think Component.dispatchEvent() is what you are looking for.

  • Action Events from sub-components?

    I have a main Swing GUI JFrame, in this frame I have a JLayeredPane (should have named it JLayeredPain). I have a button to switch the layers (only 2 layers, one is a text area, one is a new class which I wrote) On startup the Textarea shows. I click "Switch" and the new class object ( extends JPanel) shows in the JLayeredPane. In the new object I have a JButton "Back". I would like "Back" to cause the main GUI to switch the layers back to the TextArea. I need to somehow pass the ActionEvent from the secondary class From the "Back" button to the Main GUI to call jLayer.moveToFront(TextArea). Hmmm, but I don't know how to do this... Any thoughts would be helpful.

    Use JTabbedPane instead. JLayeredPane is only useful if you have to stack a bunch of transparent layers like Adobe Illustrator does.
    JLayeredPane isn't real good at dynamically changing event listeners. In theory, JLayeredPane should direct events to the topmost layer. In practice, I could never get it to direct events to anything other than the first added component that had any listeners. Changing the order of the layers had no effect. In the end, I added an extra transparent JPanel on top with listeners to trap the events and perform the corresponding action on the correct layer. I'll be this is exactly how Adobe Illustrator is implemented.

  • Can JSF get Action Events from Applet  or  td

    following is a example of click different part of Command to get different effect.
    I wish get same effect as click on applet; In fact , I wish get the clicked point value (x and y ) relative to Component.
    Is this possible?
    Please help me to realization it. thanks!
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>                 
             <link href="styles.css" rel="stylesheet" type="text/css"/>
             <f:loadBundle basename="com.corejsf.messages" var="msgs"/>
             <title>
                <h:outputText value="#{msgs.indexWindowTitle}"/>
             </title>
          </head>
          <body>
             <h:form>
                <h:commandButton image="mountrushmore.jpg"
                   actionListener="#{rushmore.listen}"
                   action="#{rushmore.act}"/>
             </h:form>
          </body>
       </f:view>
    </html>
    package com.corejsf;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.util.Map;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    public class Rushmore {
       private String outcome = null;
       private Rectangle washingtonRect = new Rectangle(70, 30, 40, 40);
       private Rectangle jeffersonRect = new Rectangle(115, 45, 40, 40);
       private Rectangle rooseveltRect = new Rectangle(135, 65, 40, 40);
       private Rectangle lincolnRect = new Rectangle(175, 62, 40, 40);
       public void listen(ActionEvent e) {
          FacesContext context = FacesContext.getCurrentInstance();
          String clientId = e.getComponent().getClientId(context);
          Map requestParams = context.getExternalContext().getRequestParameterMap();
          int x = new Integer((String) requestParams.get(clientId + ".x"))
                .intValue();
          int y = new Integer((String) requestParams.get(clientId + ".y"))
                .intValue();
          outcome = null;
          if (washingtonRect.contains(new Point(x, y)))
             outcome = "washington";
          if (jeffersonRect.contains(new Point(x, y)))
             outcome = "jefferson";
          if (rooseveltRect.contains(new Point(x, y)))
             outcome = "roosevelt";
          if (lincolnRect.contains(new Point(x, y)))
             outcome = "lincoln";
       public String act() {
          return outcome;
    }

    final JList list = new JList(dataModel);
    MouseListener mouseListener = new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
             if (e.getClickCount() == 2) {
                 int index = list.locationToIndex(e.getPoint());
                 System.out.println("Double clicked on Item " + index);
    list.addMouseListener(mouseListener);

  • How to retrieve 'top 5 timed events' from AWR

    Hello,
    I have a 10g database and awr is running every hour. How do I get the 'Top 5 Timed Events' from the awr report for every single hour on the last five days worth of awr reports? I can see the awr reports through GRID but where is the actual location of the snapshots? Instead of getting this information from awr reports, can I get 'Top 5 timed events' from the data dictionary for every hour for the last five days? Thank you in advance.

    watson2000 wrote:
    Hello,
    I have a 10g database and awr is running every hour. How do I get the 'Top 5 Timed Events' from the awr report for every single hour on the last five days worth of awr reports? I can see the awr reports through GRID but where is the actual location of the snapshots? Instead of getting this information from awr reports, can I get 'Top 5 timed events' from the data dictionary for every hour for the last five days? The "Top 5" comes from combining information about system events and the time model statistics. The information is stored in a number of tables in the SYS schema with names starting with WRH$, but also exposed in a set of views starting with DBA_HIST.
    To reconstruct the Top 5 hourly for the last five days, you will need to access DBA_HIST_SYSTEM_EVENTS (system events) DBA_HIST_SYS_TIME_MODEL (time model) and DBA_HIST_SNAPSHOT (list of snapshot ids and times).
    It won't be a trivial query, as you need to collect the "DB CPU" entry from dba_hist_system_time_model, union it with the dba_hist_system_events, then take the top 5 for each snapshot from the result. You'll probably need to look at subquery factoring and analytic functions to make this as efficient as possible.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Firing an action event

    Hi,
    is it possible somehow fire an action event from one managed bean method to an action listener which is in another managed bean?

    Hi,
    action events are bound to a component. A good article on events is written by Hans Bergsten.
    http://www.onjava.com/lpt/a/5066
    In your case, wouldn't it be easier to create a handle from one managed bean to the other in providing the reference to the second as a managed property?
    Frank

  • Is there a way to trigger button's action listeners from key events?

    I rarely do GUI programming, especially not in Java. But now I am working on a GUI app and would like to get some help.
    Say I have a simple GUI consists of a JFrame, and a bunch of buttons on its JToolBar. The buttons on the JToolBar are for navigation of a set of documents, first, prev, next, last etc. All buttons are assigned action command strings, and their all trigger the same instance of action listener. inside of the action listener, it does the correct navigation based on the action command from the event.
    but some users want to be able to use the keyboard to do the navigation, because they think clicking the buttons are too slow.
    So is there a graceful way to receive the different key press events and trigger corresponding navigation actions (hopefully it reuses the code that is already there, e.g. the action listener)? thanks.
    -- Jim

    but some users want to be able to use the keyboard to do the navigation, because they think clicking the buttons are too slow. That is always the case in any GUI. Any application should be designed to use either the mouse or the keyboard.
    All buttons are assigned action command strings,That is not the way the GUI should be designed.
    Instead you should be creating Actions. Then you can add the Action to a button and you can associate the Action with a KeyStroke which is called "Key Binding". This is the way all Swing components work. You can read the [url http://download.oracle.com/javase/tutorial/uiswing/TOC.html]Swing tutorial for more information and examples. Start with the section on:
    a) How to Use Actions
    b) How to Use Key Bindings

  • Temparally remove rows from a ADF table by action event of a jsf page.

    Hello Developers,
    I needed to temporally remove rows of a ADF table when execute action event of corresponding page.
    So in this case my task can describe by following steps,
    (1). I created a ADF table using <af:table> on a jsf page.
    (2). The data populated using a VO.
    (3). Several radio buttons added to the page for temporally remove rows from the table.
    This means one radio button check, it responsible to temporally remove rows which contain empty cell values of a identified column.
    If I check another radio button it should temporally remove identified data included rows but above removed (empty cell included rows) rows should appear in this event
    My ultimate target is temporally remove rows of a table & re call again removed rows another event without again & again query from BC.
    Pleas advice me to archive this task very sealy?
    (Are there have a way to do this using EL or coding in Manage bean ?)
    Thanks in advance..!

    Hi,
    the DCIterator gives you an option to iterate over the fetched rows (the ones you see in the table). You can try call removeAndRetain() on these rows. This will not remove or delete rows but allows you to insert these rows back to the collection.
    JavaDocs:
    * Removes the row from the collection and then retain it for insertion
    * into another location.
    * <p>
    * This method differs from <code>{@link #remove()}</code> in that
    * it just removes the row from the collection. It does not
    * remove the underlying Entity row(s) or database row(s).
    * <p>
    * This method also differs from <code>{@link #removeFromCollection()}</code>
    * in that after the row is removed from the collection, it can be inserted
    * back into the collection at another location.
    void removeAndRetain();
    Frank

  • How to set fire action event for particular rows in a table

    HI All,
    I have a requirement in which I want to set fire action event for particular rows in a table based on some condition.
    The table has columns like fullname,employee id etc.
    So i want to set fire action event for particulars rows only which will saisfy some condition.

    Atanu,
    Your approach(setting fire action for few rows) seems not possible. Better to go ahead with workaround.
    Do you want this functionality in processRequest(while page loading) or processFromRequest(on some event) method ? Give more explanation regd. your requirement ?
    In either case loop through the rows and when your condition is met write the action to be performed in controller.
    Regards,
    Anand

  • How can i set action on UITaBar and get event from that

    Hi All,
    I m doing one apps in which i have to add three UITabBarItem and this is UITabBarSystemItem.
    Now i cannot understand that how can i set action and get event from the?
    And how can i set various views on three tab bar item.
    I have to use UITabBar means i have to use UINavigationController+UITabBar
    My code id
    tabBar =[[UITabBar alloc] initWithFrame:CGRectMake(0,370,320,50)];
    tabBar.backgroundColor =[UIColor blackColor];
    UITabBarItem *search =[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
    UITabBarItem *recents =[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:1];
    UITabBarItem *favorites =[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorit es tag:2];
    tabBar.items =[[NSArray arrayWithObjects:search,recents,favorites, nil] retain];
    tabBar.selectedItem = search;
    [myView addSubview:tabBar];
    [tabBar release];
    I add a action:
    UITabBarItem *search =[[UITabBarItem alloc] InitWithTabBarSystemItem:UITabBarSystemItemSearch tag:0 action:@selector(select:)];
    So it error: Warning -no'InitWithTabBarSystemItem:tag:action:' method fount
    So any can help me regarding it?

    Thanks RickMaddy very much.
    I read and do with sample at the View Controller Programming Guide . But when run it only view TabBar with title but haven't got any TabBarItem on it. I searched a few example about TabBar and i did, but i want do a form with a button then press on button it view a form with 2 TabBarItem on TabBar and press each TabBarItem will show correlative form page 1, page 2.
    UITabBarController *tabBarControl = [[[UITabBarController alloc] initWithNibName:nil bundle:nil] autorelease];
    tabBarControl.title = @"Tab bar";
    ViewControl1 *view1 = [[[ViewControl1 alloc] initWithNibName:@"ViewControl1" bundle:nil] autorelease];
    ViewControl1 *view2 = [[[ViewControl1 alloc] initWithNibName:@"ViewControl2" bundle:nil] autorelease];
    tabBarControl.viewControllers = [NSArray arrayWithObjects:view1,view2,nil];
    [self.navigationController pushViewController:tabBarControl animated:YES];

  • How do I retain Jbutton text for action event & set img icon on Jbutton

    I need to retain the text on my button as I use this to identify the action event in actionPerformed method when the button is pressed.
    Hoe do I add an image icon to the Jbutton without effecting this?
    [/b]
    class CalcPanel extends JPanel
        implements ActionListener, CurrencyVals
    //currency panel data members
        JButton[] cb = new JButton[4];
    JPanel cbkeys = new JPanel(new GridLayout(4,1));
    //Toolkit tk = Toolkit.getDefaultToolkit();
        //Image img = tk.getImage("D:/temp/ausflag.jpg");
    public CalcPanel(){
    ImageIcon b = new ImageIcon("D:/temp/ausflag.jpg","AUS");
        cb[AUS]= new JButton(b);  //cb[AUS]= new JButton("AUS");
          cbkeys.add(cb[AUS]);
          cb[AUS].addActionListener(this);
    setLayout(new BorderLayout());
        add(display, BorderLayout.NORTH);
        add(keys, BorderLayout.CENTER);
        add(cbkeys, BorderLayout.EAST);
        add(label, BorderLayout.SOUTH);
        public void actionPerformed(ActionEvent evt){
          Object source = evt.getSource();
          int id;
          if (keyBoard) {
            if (source instanceof JButton) {
              String s = ((JButton)source).getText();
    [/b]Regards
    Synfield

    if(keyBoard) { ??! [/b]... do have cause to feel flattered?
    Copy and paste this and save a small eg;- 25px high x 50px wide Jpeg image in the same file and call it "new.jpg", then study it, this posted program (again?) to see where your code went astray.
    THEN, figure out what you want to do with your code ...keep at it!
    Sue x
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ButtonIcon extends JFrame implements ActionListener {
    String []str ={"abc","def","ghi","jkl","mno","pqr","st","uvw"};
    JButton b[] = new JButton[str.length];
       JButton on = new JButton("ON");
       JButton off = new JButton("OFF");
       JButton picture;
       JPanel panel;
       String str2="";
       Font font = new Font("Comic Sans MS" ,0, 14);
       boolean keyBoard;
       ImageIcon icon = new ImageIcon("new.jpg");
    public ButtonIcon(){
       Container c = getContentPane();
       panel = new JPanel();
       panel.setLayout(new FlowLayout());
       picture = new JButton(icon);
       for (int j=0; j<=str.length-1; j++){
             b[j]= new JButton(str[j]);
             b[j].setFont(font);
             panel.add(b[j]);
             b[j].addActionListener(this);
       on.addActionListener(this);
       off.addActionListener(this);
       panel.add(on);
       panel.add(off);
       panel.add(picture);
       c.add(panel);
       public void paint (Graphics g) {
          super.paint (g);
          Graphics2D G = (Graphics2D) g;
          G.setColor(Color.red);
          G.setFont(font);
          G.drawString(str2, 25, 150);
    public void actionPerformed(ActionEvent evt){
        String command = evt.getActionCommand();
        if (keyBoard) {
           if (evt.getSource() instanceof JButton ) {
               str2 += command;
           if (evt.getActionCommand().equals("OFF")) str2 = "";
        if(command.equals("ON")) keyBoard = true;
        if(command.equals("OFF")) keyBoard = false;
    repaint();
    public static void main (String []args){
       ButtonIcon boo = new ButtonIcon();
       boo.setSize(300,200);
       boo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
       boo.setVisible(true);

  • How do I print a list of my events from one of my calendars for tax purposes?

    How do I print a list of my events from one of my calendars for tax purposes?

    I actually began this process by creating a new calendar called "Medical" and then each event was assogned to this calendar but the program still wants to print out every day of the month for even those days that have no events.  The list view gives me the look I want and I have even tried deselecting all of the options and then reselecting them one at a time to no avail.

  • Action event automatically triggered for combo box

    Hi all,
    I am facing a typical event handling problem for combo box in Swing(Using Net Beans 5.0, jdk 1.4.2)
    While adding items to combo box it is firing action event twice instead of once irrespective of no. of items added to it.
    For eg if there are 1 or more than 1 item added to combo box it is triggerring action event twice(one just after when first item is added and one again when rest all items are added)
    and if there is no item then also it is triggering once.
    Can you please help me out.
    Thanks

    post the SSCCE code, then only it is easy to find the problem

  • Listen for Events from anywhere

    Hello!
    I have an application with a rather complicated component hierarchy.
    How can I have it so that I can listen for events from any component in any component, regardless of who is who's child?
    Thank you!

    You need a broadcasting mechanism.
    Many architecture framework offers this facility, but as a quick hack you can try something like
    public class Broadcaster extends EventDispatcher  ( singleton anti pattern   )
    instance
    then just do Broadcaster.instance.addEventListener or removeEventListener. it's a crappy singleton, but at least it does not hold any global state.
    I've also seen people use Application.application to dispatch/listen globally but really don't like it.
    Note : Use weak references or your views will never be eligible for garbage collections.

Maybe you are looking for

  • Why does opening iTunes cause my screen resolution to change automatically?

    Recently opening iTunes started automatically changing my screen resolution.  When I close iTunes the screen resolution reverts back to normal.  Does anyone now why this is happening or how I can make it stop?  I am also unable to view my music libra

  • Logic on Mac OS X Lion - dragging regions switches workspace - HELP!

    Every attempt to drag audio regions towards the right of the screen is switching to a blank workspace when the dragging cursor touches the screen boundary. My operation thus fails (of course) and I have to go back to Logic by clicking the icon in the

  • When creating pdf file am getting [700]** Message Msg700 not in .ini file ** error

    I am new to adobe output server. Am getting " [700]** Message Msg700 not in .ini file **, [397]** Message Msg397 not in .ini file **, [125]** Message Msg125 not in .ini file ** " while creating pdf file. Please help on this issue.

  • 120hz in Os X

    Hi I have a question about my mac mini late 2012 running os x mavericks on a Benq xl2420t monitor. The monitor it self has a 120hz refresh rate but iam unable to hit that in os x. The maximum im getting is 100hz using a mini display to display port c

  • Partially corrupt iPhoto Library

    I am using iPhoto 6.0.6 Recently, some of my older Rolls have had their photos seemingly disappear. They are actually moved under a folder ~iPhoto Library/Originals/2009/SomeNewRoll. This folder has 2400 photos in it, but the corresponding roll, Some