Futureproof and dynamically created button

I have been looking solution how to make buttons dynamically so that I can fetch dynamically values for buttons:
- value,onclick,class,type,request
This excellent page has very closely what I am looking: http://www.laureston.ca/2012/04/20/simple-workflow-implementation-in-apex/
but I have challenges getting the escaped special characters to work especially for the apex.submit - part.
Maybe that is just because 'copy-pasting' the plsql-region code from www-page didn't work out of the box
Application Express 4.2.3.00.08
Because dealing with the escape chars make the page easily break and there are now the new dynamic actions, I need to check what would be futureproof way of dynamically creating the buttons.
If this is anyway the most practical way to proceed, then where I should look for further information about htp.p(....) button creation examples with rich escapes?
Made small test page, where you can see one of my trials trying to get the escapes right.
user test
pass test
http://apex.oracle.com/pls/apex/f?p=1403:2
rgrds paavo
--below the code for dynamic plsql region -- very likely the escape chars are not copypasted and shown correctly:
DECLARE
--PL/SQL Dynamic Region
--thisworks too??
  v_showme varchar2(3000);
BEGIN
  for c in (select sysdate||'asdasd;asdasas'  as button_label
            , 'PIMREQUEST'  as button_request
            , 'button-gray' as button_class
            , 'button'      as button_type
            , 'P38_XPIMPOM' as button_setme
            , 'JUUSTOA'     as button_setme_value
            from dual) loop
htp.p('<button value='''||c.button_label||''' onclick=\"apex.submit('''||c.button_request||''');'' class='''||c.button_class||''' type='''||c.button_type||'''>
<span>'||c.button_label||'</span>
</button>');
  end loop;
END;

Hi Paavo,
Your right about the button_id. It's value comes from an input parameter. The button won't show up in the "When button pressed"-list_of_values. This is not only because you write the id yourself, but more because the entire button is created on the fly. The button isn't stored internal in an apex table, that's why it won't show up in a list of values.
If you want to trigger a dynamic action with the button, you can use a jQuery selector as triggering element. Here you can refer to the button_id using the '#' as jQuery marker for ID, e.g. '#myButton'.
What the button that you render does, depends on what you put in the p_link parameter. A normal save button would submit the page with condition 'SAVE', you can do that by setting p_link to 'apex.submit("SAVE")'. If the button should do a page redirect, you set p_link to 'http://www.page2go.com', or whatever url you wish to redirect to.
The text you put in the button attributes is added as HTML element definition, so if you set p_attrs to 'alt="alternate text"', that will be added to the html of your button.
An example for a conditional button call could be:
      if p_order_id is null
      then
        create_button
          ( p_id        => 'newOrder'
          , p_link    => 'javascript:apex.submit("CREATE"');'
          , p_label     => 'New Order'
          , p_css       => 'customButton'
      else
        create_button
          ( p_id        => 'updateOrder'
          , p_link    => 'javascript:apex.submit("SAVE"');'
          , p_label     => 'Update Order'
          , p_css       => 'customButton'
      end if;     
This would create a 'CREATE' button for a new order (p_order_id is null), or a 'SAVE' button for an existing order.
Regarding your ps: if you mean can you conditionaly create a button using dynamic actions? Then the answer would be yes. Yes you can use the create_button procedure in a dynamic action, however by writing it as stored procedure in the database, or in a database package, you can easily reuse your code and still have only one version of your procedure that you need to maintain.
Regards,
Vincent
http://vincentdeelen.blogspot.com

Similar Messages

  • Accessing Dynamically created Button

    Hi,
    Can someone give me an example how to access dynamically created button? 
    I know how to create a button dynamically but don't know how to access from AS3.
    Thanks!

    Hi,
    Please go through following links.
    1) http://www.daveoncode.com/2009/05/20/objectcollector-accessing-dynamic-generated-flex-obje cts-by-id/
    2) http://stackoverflow.com/questions/6740813/flex-assigning-events-to-dynamically-created-bu ttons
    3) http://www.justskins.com/forums/adding-click-event-to-35785.html
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • Dynamically create button

    Good evening,
    Can you help me,
    How can i dynamically create button?
    Can you give me example code, and how i can make event for this button.
    Regards.
    Points garantied.

    <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/11/ba74412cba127de10000000a155106/frameset.htm">Sap Library</a>

  • For loop and xml - how to point the right content in a XML file with a dynamically created button?

    Hi Everybody,
    as my first experience in AS3 I'm bulding a photo multigallery. In that gallery I have some buttons, each one pointing to its respective set of images.
    Each button is created with the for loop, that picks the information from a XML file. From this XML I get the text of the button, the position etc. What I did with some sucess. But there is a scary problem: I don't know how to make each button load the respective and unique set of images.
    I've tryied several different methods, with no effect, to make each loop to give to each button an unique identity to load the respective set of images.
    I imagine that the solution pass by the use of arrays. I wrote some code, and I guess that I'm almost there (but not sure). Here is my AS3 code until now:
    // CREATE MENU CONTAINER //
    var menuContainer:MovieClip = new MovieClip();
    menuContainer.x=10;
    menuContainer.y=300;
    addChild(menuContainer);
    // CREATE IMAGES CONTAINER //
    var imagesContainer:MovieClip = new MovieClip();
    imagesContainer.x=10;
    imagesContainer.y=10;
    addChild(imagesContainer);
    //// LOAD XML ////
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, whenLoaded);
    xmlLoader.load(new URLRequest("XML/roiaXML.xml"));
    var xml:XML;
    function whenLoaded(evt:Event):void {
         xml=new XML(evt.target.data);
         var mySetsList:XMLList=xml.children();
         //// MENU BUTTONS ////
         // CREATE ARRAYS //
         var totalArray:Array = new Array();
         var setNodesArray:Array = new Array();
         var setNamesArray:Array = new Array();
         // POSITIONING BUTTONS INSIDE MENU CONTAINER//
         var rowsQuantity:Number=3;
         var columnsQuantity:Number=Math.ceil(mySetsList.length()/rowsQuantity);
         var cellWidth:Number=160;
         // CREATE BUTTONS //
         for (var i:int=0; i< mySetsList.length(); i++) {
              var newSetButtonMC:setButtonMC=new setButtonMC();
              //what do I do here to make it works? To give each button created a unique id.
              setNodesArray.push(i);
              //trace(setNodesArray);
              var imageNodesArray:Array = new Array();
              for (var j:int=0; j<mySetsList[i].IMAGE.length(); j++) {
                   imageNodesArray.push(mySetsList[i].IMAGE[j].attribute("imageTitle"));
              totalArray.push(imageNodesArray);
              newSetButtonMC.setButtonText.text=mySetsList.attribute("galeriaTitle")[i];
              newSetButtonMC.setButtonText.autoSize=TextFieldAutoSize.LEFT;
              var cellX:Number=Math.floor(i/rowsQuantity);
              var cellY:Number=i%rowsQuantity;
              newSetButtonMC.x=cellX*cellWidth;
              newSetButtonMC.y=cellY*(newSetButtonMC.height+10);
              newSetButtonMC.addEventListener(MouseEvent.CLICK, onClick);
              menuContainer.addChild(newSetButtonMC);
         totalArray.push(setNodesArray);
         //// MENU BUTTONS ACTIONS ////
         function onClick(mevt:MouseEvent):void {
              trace(totalArray [0][0]);
              trace(totalArray [0][0]);
              // in the line above I achieved some success loading a specific info from XML.
              // but I don't know what to do with it.
              //what do I do here? To make each button to load its own node from XML.
    Here is my XML:
    <GALERIA galeriaTitle="galeria 01">
      <IMAGE imageTitle="imageTitle01">feio.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle02">muitofeio.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle03">aindamaisfeio.jpg</IMAGE>
    </GALERIA>
    <GALERIA galeriaTitle="galeria 02">
      <IMAGE imageTitle="imageTitle01">estranho.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle02">maisestranho.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle03">aindamaisestranho.jpg</IMAGE>
    </GALERIA>
    Thanks everyone . ABSTRATO

    you can assign each newSetButtonMC and ivar property that points to its i value or, even easier:
    // CREATE MENU CONTAINER //
    var menuContainer:MovieClip = new MovieClip();
    menuContainer.x=10;
    menuContainer.y=300;
    addChild(menuContainer);
    // CREATE IMAGES CONTAINER //
    var imagesContainer:MovieClip = new MovieClip();
    imagesContainer.x=10;
    imagesContainer.y=10;
    addChild(imagesContainer);
    //// LOAD XML ////
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, whenLoaded);
    xmlLoader.load(new URLRequest("XML/roiaXML.xml"));
    var xml:XML;
    function whenLoaded(evt:Event):void {
         xml=new XML(evt.target.data);
         var mySetsList:XMLList=xml.children();
         //// MENU BUTTONS ////
         // CREATE ARRAYS //
         var totalArray:Array = new Array();
         var setNodesArray:Array = new Array();
         var setNamesArray:Array = new Array();
         // POSITIONING BUTTONS INSIDE MENU CONTAINER//
         var rowsQuantity:Number=3;
         var columnsQuantity:Number=Math.ceil(mySetsList.length()/rowsQuantity);
         var cellWidth:Number=160;
         // CREATE BUTTONS //
         for (var i:int=0; i< mySetsList.length(); i++) {
              var newSetButtonMC:setButtonMC=new setButtonMC();
              //what do I do here to make it works? To give each button created a unique id.
              setNodesArray.push(i);
              //trace(setNodesArray);
              var imageNodesArray:Array = new Array();
              for (var j:int=0; j<mySetsList[i].IMAGE.length(); j++) {
                   imageNodesArray.push(mySetsList[i].IMAGE[j].attribute("imageTitle"));
             nextSetButtonMC.imageArray = imageNodesArray;
              //totalArray.push(imageNodesArray);
              newSetButtonMC.setButtonText.text=mySetsList.attribute("galeriaTitle")[i];
              newSetButtonMC.setButtonText.autoSize=TextFieldAutoSize.LEFT;
              var cellX:Number=Math.floor(i/rowsQuantity);
              var cellY:Number=i%rowsQuantity;
              newSetButtonMC.x=cellX*cellWidth;
              newSetButtonMC.y=cellY*(newSetButtonMC.height+10);
              newSetButtonMC.addEventListener(MouseEvent.CLICK, onClick);
              menuContainer.addChild(newSetButtonMC);
         totalArray.push(setNodesArray);
         //// MENU BUTTONS ACTIONS ////
         function onClick(mevt:MouseEvent):void {
              var mc:setButtonMC=setButtonMC(mevt.currentTarget);
    for(i=0;i<mc.imageArray.length;i++){
    trace(mc.imageArray[i]);
    Here is my XML:
    <GALERIA galeriaTitle="galeria 01">
      <IMAGE imageTitle="imageTitle01">feio.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle02">muitofeio.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle03">aindamaisfeio.jpg</IMAGE>
    </GALERIA>
    <GALERIA galeriaTitle="galeria 02">
      <IMAGE imageTitle="imageTitle01">estranho.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle02">maisestranho.jpg</IMAGE>
      <IMAGE imageTitle="imageTitle03">aindamaisestranho.jpg</IMAGE>
    </GALERIA>
    Thanks everyone . ABSTRATO

  • Adding f:Attribute dynamically to a dynamically created Button

    Hi ,
    I am trying to dynamically create a CommandButton and attach a f:Attribute to the same. But somehow I am not able to get hold of the correct API to do the same -
    >RichCommandButton button=new RichCommandButton();
    >button.setText("Ok");
    >AttributeTag attr=new AttributeTag();
    >attr.setValue("DC_OPERATION_BINDING", "bindings.DENY");
    >button.getChildren().add(attr);
    The issue is that the add method expects a UIComponent and attr is of type com.sun.faces.taglib.jsf_core.AttributeTag

    gues u can use it like
    button.getAttributes().put(DC_OPERATION_BINDING", "bindings.DENY");
    {code}
    http://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/component/UIComponent.html#getAttributes%28%29                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • (Urgent) Dynamically created buttons: which one?

    I need to dynamically create an array of gridpanels. There is a button and some other components on each gridpanel. I need to implement an action handler for the button (using method binding). But how do I know which button fires the event?
    Thanks a lot!

    Hi,
    One of the possible solutions is:
    Have a hidden field in the form. For each of the buttons write a javascript onclick event method in which the id of the button clicked is assigned to the hidden field. The value of this hidden field is available in the method handler. This helps in identifying which button was clicked.
    Hope this helps
    Cheers
    Giri

  • Dynamically creating buttons or hyperlinks

    Hi all,
    I am new to JSF and I am having some trouble. Hope you can help.
    Situation: I have a database that contains contacts (i.e. names, addresses, telephone numbers, etc). I want to display a list of contacts in a table. For each item of this list I want a link in order to come to a detail screen of this item.
    Creating a table that displays the names is no problem. However, the button (or hyperlink) seems to be problematic. I have looked in the archives and have found some people asking similar questions, but no alternative approach was really described. (See http://forum.java.sun.com/thread.jsp?forum=427&thread=448135) I am wondering what the best approach is at this moment in time.
    Patrick

    Roger,
    Thanks for the suggestion. Unfortunatley, JSF does not do what you suggest. The id's that it generates are all the same.
    Here is the jsf page:
    <f:use_faces>
    <h:form formName="form1" id="form1">
    <h:panel_list id="contacts" >
    <h:panel_data id="contact" var="contact" valueRef="searchDatabase.queryResult">
    <h:command_hyperlink actionRef="searchDatabase.select" label="View Details" commandName="submit">
    <f:parameter name="contactID" valueRef="contact.contactID" />
    </h:command_hyperlink>
    </h:panel_data>
    </h:panel_list>
    </h:form>
    </f:use_faces>
    And here is the resulting html:
    <form method="post" action="/wc2/faces/protected/search_database_result_test.jsp">
    <table border="0" cellspacing="0" cellpadding="6" >
    <tr>
    <td><a href="# onmousedown="document.forms[0.id0.value='submit'; document.forms[0].submit()">View Details</a><input type="hidden" name="id0"/><input type="hidden" name="contactID" value="1216"/></td>
    </tr>
    <tr>
    <td><a href="#" onmousedown="document.forms[0].id0.value='submit'; document.forms[0].submit()">View Details</a><input type="hidden" name="id0"/><input type="hidden" name="contactID" value="1432"/></td>
    </tr>
    <tr>
    <td><a href="#" onmousedown="document.forms[0].id0.value='submit'; document.forms[0].submit()">View Details</a><input type="hidden" name="id0"/><input type="hidden" name="contactID" value="1511"/></td>
    </tr>
    <tr>
    <td><a href="#" onmousedown="document.forms[0].id0.value='submit'; document.forms[0].submit()">View Details</a><input type="hidden" name="id0"/><input type="hidden" name="contactID" value="2871"/></td>
    </tr>
    </table>
    </form>
    See the problem... all id's are the same, i.e. "id0".
    Patrick

  • Creating a Function logic for dynamically created XML buttons

    Hi!
    It's me...... again! Now I've dynamically created some buttons using XML. They're spread around the stage and I've modified a tooltip script to give each button a tooltip on Mouse_Over. But to se the logic and make it work using AS3 is hard (for me). I want a function that accept to parameters: Tooltip text and  Object to tooltip.
    In my code I get this error msg when initiating the function on dynamically created buttons:
    1118: Implicit coercion of a value with static type flash.display:Sprite to a possibly unrelated type flash.display:MovieClip.
    I beleive there are more than one thing here needing a fix.
    Can someone have a look and give me a pointer?
    Thanks
    function contentTooltip(ttt:String, ttclip:MovieClip):void {
        ttclip.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
        function mouseOverHandler(e:MouseEvent):void {
            ttip.descr.text=ttt;
            ttip.x=stage.mouseX;
            ttip.y=stage.mouseY-15;
            ttclip.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
            ttclip.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
            ttip.visible = true;
        function mouseOutHandler(e:MouseEvent):void {
            ttip.visible = false;
            ttclip.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
            ttclip.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
        function mouseMoveHandler(e:MouseEvent):void {
            ttip.x=stage.mouseX;
            ttip.y=stage.mouseY-15;
    contentTooltip("Scale button",scale_btn);
    contentTooltip("Hide button",hide_btn);

    I totally agree with what Ned says and suggests. Nevertheless, I would like to support your thinking process.
    From the way you wrote the tooltip functionality it is apparent to me that you conceptualize as a programmer. Again, as Ned said, nested functions are evil. BUT, in a way, what classes accomplish is encapsulation/nesting of properties and functions under the same umbrella. It actually feels that what timeline does in general is nesting named functions within a single function we have no access to.
    How you wrote the code is actually a blueprint for a class that could handle the functionality. You, perhaps, are very ready to start coding with classes - not on the timeline.
    With that said, for the sake of theory, here is how your functionality can be rewritten on timeline:
    scale_btn.toolTip = "Scale button";
    test_btn.toolTip = "Test button";
    hide_btn.toolTip = "Hide button";
    scale_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    test_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    hide_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    var overTarget:MovieClip;
    function mouseOverHandler(e:MouseEvent):void {
         overTarget = e.currentTarget;
         ttip.descr.text = overTarget.toolTip;
         ttip.x = stage.mouseX;
         ttip.y = stage.mouseY - 15;
         overTarget.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
         overTarget.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
         setChildIndex(ttip, numChildren - 1);
         ttip.visible = true;
    function mouseOutHandler(e:MouseEvent):void {
         ttip.visible = false;
         overTarget.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
         overTarget.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 
    function mouseMoveHandler(e:MouseEvent):void {
         TweenMax.to(ttip, .5, { x:stage.mouseX, ease:Quart.easeOut } );
         TweenMax.to(ttip, .5, { y:stage.mouseY - ttclip.height / 2, ease:Quart.easeOut } );
         //ttip.x=stage.mouseX;
         //ttip.y=stage.mouseY-ttclip.height/2;

  • I need to create Buttons dynamically Please Help

    I am currently developing a card game. I represent my cards as buttons. But as the player draws more cards from the deck I have to generate buttons dynamically at run-time. I could use arrays of buttons and store new buttons inside that arrays of buttons. But the only problem is I need ActionListener for each of my buttons. How do you create ActionListener for each different dynamically created buttons? Please Help.

    Here is my code. I just do not understand how to create those functions dynamically that functions different each time.
    Here is my code please take a look.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class run108{
    JButton setbutton;
    JButton ButtonUp;
    JButton ButtonDeal;     
    JButton slot1;
    JButton slot2;
    JButton slot3;
    JButton slot4;
    JButton slot5;
    JButton slot6;
    JButton slot7;
    cards[] card = new cards[55];
    public static void main(String[] argv)
         run108 startgui = new run108();
         startgui.createframe();     
    void createframe()
         //Standard of way of creating Frame
         JFrame frame = new JFrame("108");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setLocation(300,200);// Tells the startup position;
         //Adding Panels to the framework
         JPanel panelA = new JPanel();
         panelA.setBackground(Color.white);
         panelA.setLayout(new BoxLayout(panelA,BoxLayout.Y_AXIS));
         JPanel panelB = new JPanel();
         JPanel panelC = new JPanel();
         //Adding buttons with card images
         JLabel label1 = new JLabel("       Set of Cards");
         panelA.add(label1);
         ImageIcon pic1 = new ImageIcon("cards/backd.png");
         setbutton = new JButton(pic1);          
        panelA.add(setbutton);
        ImageIcon picdeal = new ImageIcon("cards/deal.png");
         ButtonDeal = new JButton(picdeal);
         panelA.add(BorderLayout.CENTER, ButtonDeal);
        ButtonDeal.addActionListener(new DealListener());
         JLabel label2 = new JLabel("       Your Target");
         panelA.add(label2);
         ButtonUp = new JButton(pic1);          
        panelA.add(BorderLayout.CENTER, ButtonUp);
        frame.add(BorderLayout.WEST,panelA);
        // Adds 7 initial card slots.
         ImageIcon pic2 = new ImageIcon("cards/backc.png");
         slot1 = new JButton(pic2);
        panelB.add(slot1);          
        slot1.addActionListener(new Slot1Listener());
        slot2 = new JButton(pic2);
        panelB.add(slot2);
        slot2.addActionListener(new Slot2Listener());
         slot3 = new JButton(pic2);
        panelB.add(slot3);
        slot3.addActionListener(new Slot3Listener());
         slot4 = new JButton(pic2);
        panelB.add(slot4);
        slot4.addActionListener(new Slot4Listener());
         slot5 = new JButton(pic2);
        panelB.add(slot5);
        slot5.addActionListener(new Slot5Listener());
         slot6 = new JButton(pic2);
        panelB.add(slot6);
        slot6.addActionListener(new Slot6Listener());
         slot7 = new JButton(pic2);
        panelB.add(slot7);
        slot7.addActionListener(new Slot7Listener());
        frame.add(BorderLayout.CENTER,panelB);
        // This has to be added @ the end to show the components
        //that were added after on. If it is placed before the components
        //the components shall not appear since they sit on the frame
         frame.setSize(600,500);
         frame.setVisible(true);
    class DealListener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot1Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot2Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot3Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot4Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot5Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot6Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot7Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    }

  • Scroll bars & creating buttons problem

    I am trying to create a basic photo browser. The upper area is the enlarged view of the image. The lower portion is a scrollable view of the thumbnails in the directory chosen. I have most of it working...except that the scrollable view doesn't scroll, and the buttons that I created don't cause the image to show up in the main view port.
    There is the main window, divided into two parts: upper and lower. The upper part is the main view, as described above. The lower part is a panel. That lower panel contains two things, another panel and a button. This panel inside the lower section contains the scrollable window; this scrollable window is a viewport onto another panel that contains the dynamically created buttons (which are thumbnails of the images in the directory).
    I was trying to force the scrollbar policy to always show the horizontal bar (that is the only one I want visible) but that wasn't working either; I would get compiler errors when that was included. I have tried adjusting sizes of things, and the order that things are added to the main JFrame.
    Any suggestions would be appreciated.
    Here is the code:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import java.io.FileFilter;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.border.EtchedBorder;
    import javax.swing.filechooser.FileNameExtensionFilter;
    * PhotoGUI Browse
    * Description:  Generate a GUI interface for viewing a large view of an image and previews of thumbnails
    * in a directory.  There are two parts to the GUI:  large upper section for main viewing, and a short lower
    * section for viewing the thumbnail previews.  The lower section is also split into two parts:  the left part
    * is a scrollable pane where the thumbnails will be previewed, and then a small section to the right where
    * a button for changing directories will be present.  (I wanted the button to always be visible so didn't
    * put it in the scrollable area.)
    public class PhotoGUI extends JFrame {
         final int SIZE = 75;     //scaling size for images in thumbnail browser
         boolean firstRunThrough = true;               //Changes behavior of directory requester
         private JPanel thumbs;
         private JPanel pickNThumbs;
         private ImagePanel bigView ;
         private JScrollPane scroller;
         private JButton pickDirButton;
         private thumbSelectedListener thumbPicksNose;
         public PhotoGUI () {
              this.setDefaultCloseOperation (EXIT_ON_CLOSE);
              this.setSize(600,600);       //Starting size of the overall container.
              this.setTitle("Eye Photo photo browser");
              //The upper portion of the GUI, where the large view of the image will be held
              bigView = new ImagePanel();       
              //bigView.setSize (600,500);
              //The bottom section of the GUI; will hold the thumbnail previews
              //(in a scrollable panel) and a button for changing directories.
              pickNThumbs = new JPanel();             
              pickNThumbs.setBackground(Color.WHITE);
              pickNThumbs.setSize(600,100);
              pickDirButton = new JButton("Pick directory...");
              //pickDirButton.setSize(75,150);
              dirPickListener dirButton = new dirPickListener ();
              pickDirButton.addActionListener(dirButton);
              thumbs = new JPanel();              //The panel that will hold the thumbnail previews
              scroller = new JScrollPane(thumbs);       //Setting the scroll bar pane to view the thumbnail panel
              //scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
              //scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              // scroller.setSize(525,100);          
              scroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
              pickNThumbs.add(scroller);
              pickNThumbs.add(pickDirButton);
              this.add(bigView);
              this.add(pickNThumbs, BorderLayout.SOUTH);
              String pickedDir = pickDir();               //Setting up the while loop so it will keep requesting
              if (pickedDir.equals("-1")) {
                   if (firstRunThrough)   System.exit(0);          //End program if they don't pick a dir the first time through.
              }else {
                   thumbsUp(pickedDir);                  //They picked good Dir; populate thumbnails
                   firstRunThrough = false;
         public String pickDir () {          
              // This is the file chooser method. 
              JFileChooser dirPicker = new JFileChooser();
              dirPicker.setDialogTitle("Pick a directory");
              dirPicker.setApproveButtonText("Open directory");
              dirPicker.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              int x = dirPicker.showOpenDialog(getParent());   //maybe I don't need this?
              if (x == JFileChooser.APPROVE_OPTION) {
                   return dirPicker.getSelectedFile().getAbsolutePath();
              } else return "-1";              //Just to cover all possible conditions
         public void thumbsUp (String chosenDir) {
              // Thumb populater method.  It adds each thumb-button to the scroller panel
              thumbs.removeAll();         //Need to remove old directory's buttons
              File selectedDir = new File(chosenDir);
             FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG/GIF/BMP/PNG Images", "bmp", "jpg", "jpeg", "gif", "png");
              File [] dirEntries = selectedDir.listFiles();
              for (File tempFile : dirEntries) {    
                   if (filter.accept(tempFile) && tempFile.isFile()) {       //That way I only get certain types
                        JButton howToNameMultipleButtons = new JButton();
                        howToNameMultipleButtons.setActionCommand(tempFile.getAbsolutePath());
    //                    System.out.println(tempFile.getAbsolutePath());
    //                    System.out.println(howToNameMultipleButtons.getActionCommand());
                        howToNameMultipleButtons.setIcon(new ScaledIcon(tempFile.getAbsolutePath(), SIZE));
                        howToNameMultipleButtons.addActionListener(thumbPicksNose);
                        thumbs.add(howToNameMultipleButtons);
              this.setVisible(true);   //Down here so first run through program opens Dialog before showing
         public class dirPickListener implements ActionListener {
              public void actionPerformed (ActionEvent ae) {
                   thumbsUp(pickDir());     //Opens Dir selection dialog and feeds the thumbnail populater
         public class thumbSelectedListener implements ActionListener {
              public void actionPerformed (ActionEvent ae) {
                   String thumbPicked = ae.getActionCommand();    //Should return path string of thumbButton clicked
                   // System.out.println(ae.getActionCommand());    //TSing step; to see if this bit even fires off.
                   bigView.setImage(thumbPicked);
                   bigView.setToolTipText(thumbPicked);
                   //  bigView.setBackground(Color.GREEN);
    }

    Ah! I got some of it figured out at least...
    Setting the preferred size parameter has caused the scroll bars to display! :) Thanks for the hint on that.
    But I get an error when I try and use the scrollbar policy settings. Here are the results:
    Exception in thread "main" java.lang.IllegalArgumentException: invalid verticalScrollBarPolicy
         at javax.swing.JScrollPane.setVerticalScrollBarPolicy(Unknown Source)
         at javax.swing.JScrollPane.<init>(Unknown Source)
         at PhotoGUI.<init>(PhotoGUI.java:70)
         at PhotoBrowser.main(PhotoBrowser.java:15)And the code I used:
    scroller = new JScrollPane(thumbs,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS,
                        ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);       //Setting the scroll bar pane to view the thumbnail panel
              Edited by: Mole_Hunter on Feb 1, 2010 9:57 AM

  • Regarding create button

    Hi,
    i am developing one scree,in that screen create button is not working.
    Situation:
    top of the page SelectOneChoice(these values are fixed values).below this one creation form(only one input text box and Create button).this is from view object.below this one ADF Table(editabale).this is from same view object.this table is dynamically populated with selectOneChoice.i am using binding concept here.
    Problem:
    when i select list value then corresponding table result is coming.in between these two i have one input texbox and create button.if i enter value in to input textbox and press create button extra row sholud add in the table and that should visible.but in my screen value enter the input textbox and create methot is executed but not showing any row in this table.
    sample screen simulation:
    selectOneChoice:--------------------------------
    inputText(name)----------------------Create Button
    Table
    name is the one column in table.if i enter name value and press create button then sholud display inserted row in top of the table(before commit).

    Hi,
    i assigned "SelectOneChoice" component id value 'table_id' to table PartialTrigger value 'table_id'.because table is come form choicelist value(VO sql_statement is binding with SelectOneChoice value).
    now i am trying to assing same id(table_id) to create butten id then it showing Alert error Box like this "Could not set id to table_id,Unmatched braces in the pattern".
    what i have to do now?
    Thanks,

  • DVD-SP on MBPro - can't open file or create buttons in new one

    This is quite bizarre.
    I've recently installed FCS2 on a new MBPro - latest OS, QT, etc...
    For some reason, I can't create a button on a menu. I can't drag to create one - it never even shows the box. When I drag a shape on and choose "Create Button" - nothing happens.
    When I try to open an existing project from another system, it hangs up during "Loading Menus".
    I've even deleted the APP, the PREFs, and the RECEIPTS, then re-installed the program from scratch - and the exact same thing happens.
    Any ideas?

    Without system info or other details we can't tell you anything. Most likely this is a permissions issue where PS cannot access the templates for new documents or other configuration data nor may it be able to create its swap files. Look into that and verify your file permission as well as turn off security tools that may block this stuff. also run as admin to test.
    Mylenium

  • Importing compressed movie and attaching to button

    I need help. I've got a final cut pro 4.5 movie that i've compressed through Compressor 1.2.1 that is 3.14 GB. I've set up my menu through DVD Studio Pro 2.0 and everything and have no trouble attaching the audio to the play button, but everytime I try to attach the movie to the button the pinwheel comes up and its like my computer freezes. I'm not sure what's wrong, is my project too big or what's going on? Any advice would be great!

    Sorry, I will try to explain better. I made a very simple menu with one picture, a title and a play movie button. As I said before, I am new to DVDSP, but I was told all I had to do was drag my movie from my movies folder over the Play movie button and click 'create button and track' to make the movie play when you click the play movie button. I think you are correct and the media might be damaged, because when I've tried to play the compressed mpeg2 file it opens in compressor and says 'Alert Error trying to open source media file.
    I've tried compressing it twice already (which takes 7hrs) and I'm not sure what I'm doing wrong. I've called apple and they said to check my setting which I have done. Could it have anything to do with my project being shot with two different cameras, one 24p and the other a normal sony video camera?

  • Create button choices and dynamically assign actions to them.

    Hi,
    I'm currently working on SAP Commercial Project Management which use Floor Plan Manager.
    Here, I've to create button choices and assign some actions to the button choice values dynamically.
    Please let me know, what's the process to do that .
    Regards,
    Arnab

    chk this
    Passing default value to bind variable on page load.
    http://adfcodebits.blogspot.com/2010/03/bit-2-setting-bind-variable-value.html

  • Creating dynamic Radio Buttons and Buttons

    Hello All,
    Presetly I am working on below functionality:
    I have an ArrayCollection which is like
    var sampleCollection:ArrayCollection = new ArrayCollection( [ {"filterID:1", filterName:"Occupied" },  {"filterID:2", filterName:"Unccupied" }] );
    Now my requirement is to create a RadioButton  and a Normal Button for every element in the ArrayCollection.
    So basically the UI will be "RadioButton, Occupied, Button, Button".
    Can someone help me in this respect.
    Thanks in advance,
    Nirmal Kumar Bhogadi.

    HI Nirmal,
    If u want to create the radiobuton and abutton according to the arraycollection data then u follow the following principle.
    Take a vbox. this is contains all the rasio button.
    then do a loop to the arraycolection upto it's length.
    and create the the radio button and add into vbox;
    ex
    <mx:Vbox id ="container"/>
    script:-
    privare var aa:arrayCollection =  ur arraycollection;
    private function addChild():void
         for(var i:int=0; i<aa.length; i++)
              container.addchild(new radioButton());
    I think this hint will help u. if u get ur answer please give me points
    Thanks
    Niranjan Swain

Maybe you are looking for

  • Create user both in the satellite system and in solman

    Hi I wonder if I need to open all my user's that are in the satellite system (ECC) in the solution manager for the purpose of create support message or I can only create them as BP? If I don't need to open them, What is the proper way to configure th

  • Mac Mini wireless to PS3?????

    I'm using my mac mini as a router for my home. I have my comcast internet ethernet plugged into the Mac Mini and I share the internet signal through the airport. I have multiple PC's connected and streaming internet fine, but when the Playstation 3 t

  • ASN REPORT NEEDED

    Hi, I need an ASN report that shows ASN number the expected arrival date as well as material,vendor,quantity,current price and value. Can anyone please let me know if there is a standard report that can do this. If not can anyone propose me how this

  • T400: system freezing

    I just got a new Lenovo T400, and its operation system is window vista 32 bit. It works pretty good, but there is a problem that makes me very umcomfortable. When I was working with this computer, it was  suddenly freezed and the best solution was to

  • Why do we need BlazeDS?

    HI, Could you please explaing why do we need BlazeDS. When do we go for BlazeDS or LCDS? Can't we make use of the httpservice, remoteobject and webservices that is available in Flex. Please explain.