Scrollpane Not Working

I am trying to have a JFrame with multiple panels, one of which will allow scrolling. I assign a scrollpane to a JPanel, which will contain multiple (dynamically changing) Labels. When the number of Labels exceeds the size that the JPanel is allocated (which is the reason the scrollpane is needed in the firstplace), the scrollable feature kicks in (which is good), but the entire list of labels appears, exceeding the region allocated to the JPanel and appearing over the panels below this one. How do I correct this? Thanks!
import javax.swing.*;
import java.awt.*;
class TestScrollPane
     public static void main(String[] args)
          JFrame jf = new JFrame("Test Frame");
          jf.setLayout(new GridLayout(2,2));
          jf.setSize(400,500);
jf.add(new Label("Top Left Panel"));
JPanel jp1 = new JPanel(new BorderLayout());
          jp1.add("North", new Label("On top"));
          JPanel jp = new JPanel(new GridLayout(20,1));
          for(int i=0; i<20; i++)
               Label l = new Label(i+ "th Label");
               l.setBackground(Color.WHITE);
               jp.add(l);
          JScrollPane scrollPane = new JScrollPane(jp);
          scrollPane.setPreferredSize(new Dimension(50, 50));
          jp1.add("Center", scrollPane);
          jf.add(jp1);
          jf.add(new Label("Bottom Left Panel"));
          jf.add(new Label("Bottom Right Panel"));
          jf.setVisible(true);
}

Your problem is one of the unexpected results that come from mixing AWT and Swing visual components. My answer: don't do this -- change all of your "Labels" to "JLabels".

Similar Messages

  • Force label width inside a scrollpane not working

    hello
    I have 7 buttons in a grid 7x1 one on top of another inside a scrolpane. i want to be able to scroll left/right 7200pixels but i can't get the scrollpane to be 7200 wide. if i make a component 7200 wide inside it, it does, but runs off the side. unless i put a 7200wide graphic as a label on that button, then i can traverse 7200 left and right with the jscrollbar. i am goign to want to select the number in the future though...have it be 1000 wide or 100000 wide on the fly....with a solid graphic that seems a kinda clunky way to do it. any ideas? i guess i need to find a way to force the scroll bar to always exist with X width.
    thanks in advance

    ignore me. i'm an idiot. the panel's preferred size was what was important, not the buttons inside it.

  • Buttons not working within movieclip inside scrollpane

    hey I have a couple buttons that work outside of the ScrollPane but dont work within it. This is my exact code, how do i get them to work?
    scrollPane.source = myContent;
    scrollPane.setSize(173,500);
    K1Button.addEventListener(MouseEvent.CLICK, playVid);
    function playVid(e:MouseEvent):void{
    myVideoPlayer2.myFLV2.source = "video/K.mp4";
    myVideoPlayer2.myFLV2.play();
    T1Button.addEventListener(MouseEvent.CLICK, playVid2);
    function playVid2(e:MouseEvent):void{
    myVideoPlayer2.myFLV2.source = "video/T.flv";
    myVideoPlayer2.myFLV2.play();

    still cant get this any ideas?
    cant seem to get the buttons within the content movieclip to work.
    they are supposed to play a video when clicked.
    they do exhibit the rollover glow action, just not the down action of playing the movie.
    if i take them outside the scrollpane they work fine.

  • Lookup for elements in ScrollPane does not work

    Tried to select my flowpane, result is null. With removing the scrollpane it works as expected.
    Quote description of lookup method:
    "Finds this Node, or the first sub-node, based on the given CSS selector. If this node is a Parent, then this function will traverse down into the branch until it finds a match. If more than one sub-node matches the specified selector, this function returns the first of them. "
    VBox vbox = (VBox )FXMLLoader.load(TestClass.class.getResource(fxml));
    vBox.lookup("#elementsPane");
    <VBox xmlns:fx="http://javafx.com/fxml">
        <ScrollPane fitToHeight="true" fitToWidth="true" VBox.vgrow="ALWAYS">
            <FlowPane fx:id="elementsPane" VBox.vgrow="ALWAYS" vgap="4" hgap="4" alignment="BASELINE_CENTER">
                <styleClass>
                    <String fx:value="elementsPane" />
                </styleClass>
            </FlowPane>
        </ScrollPane>
    </VBox>

    Seems like a bug. Scrollpane childs list is empty, my flowpane is at scrollpanes content.

  • Command button not working

    Hi,
    I have a
    <h:panelGrid><td><h:commandButton id="aButton" value="Add" action="#{hubreceivingbean.createRecord}" /></td></h:panelGrid> this is not working, I'm not sure what wrong I'm doing, my code is
    ============ hubReceiving.jsp=======================
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <tiles:importAttribute scope="request"/>
    <f:view>
    <f:loadBundle basename="com.fcpa.him.columnheading" var="chdr"/>
    <f:loadBundle basename="com.fcpa.him.Messages" var="msg"/>
    <div id="location"></div>
    <div class="bfrm" style="width: 720px;" >
    <div style="height: 600px" class="cv_c">
    <h:form id="rcvTxn">
    <h:panelGroup>
    <h:panelGrid columns="1">
    <h:panelGrid>
    <h:dataTable >
    <h:column>
    <f:facet name="header">
    <td> <h:outputFormat style="width: 730px;" value="Receiving"/></td>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:panelGrid>
    <h:panelGrid columns="3">
    <h:panelGrid columns="5" style="width: 560px">
    <h:column>
    <h:panelGrid><td><h:outputText id="errorMessage" value="#{hubreceivingbean.errorMessage}" style="color: red; font-weight: bold;" /></td></h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText id="hRcvDate" value="Receiving Date:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hHubName" value="Receiving At:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPackageType" value="Package Type:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPackageValue" value="Scan / Enter:" style="width: 90px" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText id="vRcvDate" value="#{hubreceivingbean.date}" style="width: 130px"/></td></h:panelGrid>
    <h:panelGrid><td><h:selectOneMenu id="vHubName" value="#{hubreceivingbean.hubName}" style="width: 130px">
    <f:selectItems value="#{hubreceivingbean.hubList}"/>
    </h:selectOneMenu></td></h:panelGrid>
    <h:panelGrid><td><h:selectOneMenu id="vPackageType" value="#{hubreceivingbean.sourceType}" style="width: 130px" onchange="submit()" >
    <f:selectItems value="#{hubreceivingbean.sourceTypeList}" />
    </h:selectOneMenu></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vPackageValue" value="#{hubreceivingbean.sourceValue}" style="width: 130px" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText style="width: 80px"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hTxnNum" value="Txn ID:" style="width: 80px"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPartNumber" value="Part Number:" style="width: 80px; #{hubreceivingbean.componetEnableDisableStyle};"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hQty" value="Quantity:" style="width: 80px; #{hubreceivingbean.componetEnableDisableStyle};"/></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText style="width: 130px" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vTxnNum" value="#{hubreceivingbean.rcvTxnHeaderID}" style="width: 130px" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vPartNum" value="#{hubreceivingbean.partNumber}" style="width: 130px; #{hubreceivingbean.componetEnableDisableStyle};" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vQty" value="#{hubreceivingbean.quantity}" style="width: 130px; #{hubreceivingbean.componetEnableDisableStyle};" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    </h:panelGrid>
    <h:panelGrid>
    <f:subview id="rtMenu">
    <tiles:insert definition="mainMenu" flush="false"/>
    </f:subview>
    </h:panelGrid>
    </h:panelGrid>
    <h:panelGrid><td><h:commandButton id="aButton" value="Add" action="#{hubreceivingbean.createRecord}" /></td></h:panelGrid>
    <h:panelGrid>
    <h:dataTable styleClass="standard">
    <h:column >
    <f:facet name="header">
    <td> <h:outputFormat style="width: 70px; " value="#{chdr.rcvRefType}"/></td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 80px;" value="#{chdr.rcvRefTypeValue}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 80px;" value="#{chdr.palletNumber}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 175px;" value="#{chdr.partNumber}"/></td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 75px;" value="#{chdr.asnQty}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 75px;" value="#{chdr.rcvQty}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 100px;" value="#{chdr.remarks}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 50px;" value="#{chdr.delete}"/> </td>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:panelGrid>
    <h:panelGrid styleClass="scrollPane" columns="1" style="width: 720px;">
    <h:panelGroup>
    <f:verbatim><DIV STYLE="overflow: auto; height: 170px;" styleClass="standard"></f:verbatim>
    <h:dataTable value="#{hubreceivingbean.rcvDataArray}" var="databean" styleClass="standard">
    <h:column>
    <h:outputText style="width: 70px;" value="#{databean.referenceType}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 80px;" value="#{databean.referenceValue}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 80px;" value="#{databean.palletNumber}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 175px;" value="#{databean.partNumber}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 75px;" value="#{databean.asnQuantity}" />
    </h:column>
    <h:column>
    <h:inputText id="rcvQty" style="width: 75px;" value="#{databean.rcvQuantity}" required="true"/>
    <h:message for="rcvQty" errorClass="errors" />
    <f:attribute name="rcvQty" value="Please Enter" />
    </h:column>
    <h:column>
    <h:inputText style="width: 100px;" value="#{databean.rcvComments}" />
    </h:column>
    </h:dataTable>
    <f:verbatim></DIV></f:verbatim>
    </h:panelGroup>
    </h:panelGrid>
    </h:panelGrid>
    </h:panelGroup>
    </h:form>
    </div>
    </div>
    </f:view>
    ====================HubReceivingBean.java=================
    * HubReceivingBean.java
    * Created on February 1, 2006, 6:09 PM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package com.fcpa.him;
    * @author vburla
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import javax.faces.model.SelectItem;
    import javax.faces.application.*;
    import javax.faces.context.FacesContext;
    import java.util.Locale;
    import javax.servlet.jsp.jstl.sql.ResultSupport;
    import javax.servlet.jsp.jstl.sql.Result;
    import javax.faces.component.UIComponent;
    import javax.faces.component.UIComponentBase;
    import javax.faces.component.UIInput;
    import javax.faces.component.UIViewRoot;
    import javax.faces.validator.*;
    import javax.faces.el.ValueBinding;
    import java.io.Serializable;
    import javax.swing.JOptionPane;
    import java.net.*;
    import com.fcpa.reportal.*;
    import com.fcpa.eapps.*;
    public class HubReceivingBean {
    private String sourceType;
    private String sourceValue;
    private String rcvTxnHeaderID;
    private Date date = new Date();
    private static ArrayList sourceList;
    private static ArrayList hubList;
    private SysLogger log;
    private JDBCConnPool db;
    private String hubName;
    private boolean hubNameEditable =true;
    private ArrayList rcvDataArray = new ArrayList();
    private String componetEnableDisableStyle = "display:none";
    private String txnRefEnableDisable = "display:none";
    private String partNumber;
    private String quantity;
    private String useDataSource = "Y";
    private String errorMessage;
    //private static final String[] SOURCE_TYPE = { "CARTON", "PALLET", "INVOICE","IO"};
    //private static final String[] COLUMN_NAMES = {"Ref_Type","Ref_Value","Part_Number","ASN_Qty","RCV_Qty","Notes"};
    /**Create connection */
    public void setJdbcConnPoolClass(JDBCConnPool j) {
    this.db = j;
    public JDBCConnPool getJdbcConnPoolClass() {
    return this.db;
    public void setSysLoggerClass(SysLogger s) {
    this.log = s;
    public SysLogger getSysLoggerClass() {
    return this.log;
    /** Creates a new instance of HubReceivingBean */
    public HubReceivingBean(){
    private void fillRcvDataArray() throws Exception{
    if ( (getRcvTxnHeaderID()!="") && (getRcvTxnHeaderID()!=null) ){
    String strSQLstr = "SELECT lines.txn_line_id Txn_Line_ID, lines.reference_type Ref_Type,lines.reference_value Ref_Value,"+
    " lines.pallet_number Pallet_Number, lines.part_number Part_Number,lines.asn_quantity ASN_Qty,"+
    " lines.received_quantity RCV_Qty,lines.comments Notes "+
    " FROM hif_rcv_txn_headers headers, hif_rcv_txn_lines lines "+
    " WHERE headers.txn_header_id = lines.txn_header_id "+
    " AND headers.txn_header_id = "+getRcvTxnHeaderID()+
    " AND nvl(headers.txn_complete_flag,'N') = 'N' "+
    " ORDER BY lines.txn_line_id desc";
    System.out.println("Inside fill data-strSQLstr: "+strSQLstr);
    ResultSet rs = db.getResultSet(strSQLstr);
    while (rs.next()){
    RcvTableDataBean bean = new RcvTableDataBean();
    bean.setTxnLineID(rs.getString("Txn_Line_ID"));
    bean.setReferenceType(rs.getString("Ref_Type"));
    bean.setReferenceValue(rs.getString("Ref_Value"));
    bean.setPalletNumber(rs.getString("Pallet_Number"));
    bean.setPartNumber(rs.getString("Part_Number"));
    bean.setAsnQuantity(rs.getString("ASN_Qty"));
    bean.setRcvQuantity(rs.getString("RCV_Qty"));
    bean.setRcvComments(rs.getString("Notes"));
    rcvDataArray.add(bean);
    public ArrayList getRcvDataArray()throws Exception {
    rcvDataArray.clear();
    fillRcvDataArray();
    return rcvDataArray;
    // PROPERTY: current date
    public void setDate(Date newValue) { date = newValue; }
    public String getDate() {
    Date now = new Date();
    DateFormat df = DateFormat.getDateInstance();
    String s = df.format(now);
    System.out.println("Today is " + s);
    return s;
    // PROPERTY: Hub Name
    public void setHubName(String newValue) {
    // System.out.println("Inside setSourceType");
    hubName = newValue; }
    public String getHubName() {
    //System.out.println("Inside getSourceType");
    return hubName; }
    // PROPERTY: source type
    public void setSourceType(String newValue) {
    // System.out.println("Inside setSourceType");
    sourceType = newValue; }
    public String getSourceType() {
    //System.out.println("Inside getSourceType");
    return sourceType; }
    // PROPERTY: source value
    public void setSourceValue(String newValue) {
    //System.out.println("Inside setSourceValue");
    sourceValue = newValue; }
    public String getSourceValue() {
    //System.out.println("Inside getSourceValue");
    return sourceValue; }
    // PROPERTY: source type
    public void setRcvTxnHeaderID(String newValue) {
    // System.out.println("Inside setSourceType");
    rcvTxnHeaderID = newValue; }
    public String getRcvTxnHeaderID() {
    //System.out.println("Inside getSourceType");
    return rcvTxnHeaderID; }
    // PROPERTY: Enable Disable
    public void setComponetEnableDisableStyle(String newValue) {
    // System.out.println("Inside setSourceType");
    componetEnableDisableStyle = newValue; }
    public String getComponetEnableDisableStyle() {
    //System.out.println("Inside getSourceType");
    return componetEnableDisableStyle; }
    // PROPERTY: Enable Disable Txn Ref
    public void setTxnRefEnableDisable(String newValue) {
    // System.out.println("Inside setSourceType");
    txnRefEnableDisable = newValue; }
    public String getTxnRefEnableDisable() {
    //System.out.println("Inside getSourceType");
    return txnRefEnableDisable; }
    // PROPERTY: part Number
    public void setPartNumber(String newValue) {
    // System.out.println("Inside setSourceType");
    partNumber = newValue; }
    public String getPartNumber() {
    //System.out.println("Inside getSourceType");
    return partNumber; }
    // PROPERTY: Quantity
    public void setQuantity(String newValue) {
    // System.out.println("Inside setSourceType");
    quantity = newValue; }
    public String getQuantity() {
    //System.out.println("Inside getSourceType");
    return quantity; }
    // PROPERTY: UseData Source
    public void setUseDataSource(String newValue) {
    // System.out.println("Inside setSourceType");
    useDataSource = newValue; }
    public String getUseDataSource() {
    //System.out.println("Inside getSourceType");
    return useDataSource; }
    // PROPERTY: Error Message
    public void setErrorMessage(String newValue) {
    // System.out.println("Inside setSourceType");
    errorMessage = newValue; }
    public String getErrorMessage() {
    //System.out.println("Inside getSourceType");
    return errorMessage; }
    // PROPERTY: User ID
    public String getUserID() {
    // System.out.println("Inside setSourceType");
    return("1048"); }
    // PROPERTY: Hub Name Editable
    public boolean isHubNameEditable() {
    return hubNameEditable; }
    public void setHubNameEditable(boolean newValue) {
    hubNameEditable = newValue; }
    //PROPERTY: Hub List
    public Collection getHubList() throws Exception {
    log.general("Inside getSourceTypeList");
    String strSQLstr = " SELECT hub_name hubName "+
    " FROM eaf_hub_master "+
    " WHERE nvl(enabled_flag,'N') = 'Y' "+
    " AND nvl(end_date_active,sysdate+1) > sysdate";
    ResultSet sl = db.getResultSet(strSQLstr);
    hubList = new ArrayList();
    int hubCt = 0;
    while (sl.next()){
    hubCt = hubCt + 1;
    hubList.add(new SelectItem(sl.getString("hubName")));
    //System.out.println("hubCt: "+hubCt);
    if (hubCt > 1) {
    setHubNameEditable(true);
    // System.out.println("Setting setHubNameEditable as true");
    } else{
    setHubNameEditable(false);
    // System.out.println("Setting setHubNameEditable as false");
    setHubName("One Hub");
    return(hubList);
    //PROPERTY: source List
    public Collection getSourceTypeList() throws Exception {
    System.out.println("Inside getSourceType:"+getSourceType());
    String sourceType = getSourceType();
    System.out.println("sourceType:"+sourceType);
    if (sourceType != null){
    if (sourceType.equals("OTHERS")){
    System.out.println("Inside getSourceType for OTHERS");
    setComponetEnableDisableStyle("");
    setUseDataSource("N");
    }else {
    System.out.println("Inside getSourceType for not OTHERS");
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    }else{
    System.out.println("Source Type is null");
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    setErrorMessage(null);
    log.general("Inside getSourceTypeList");
    String strSQLstr =" SELECT lookup_code sourceType "+
    " FROM hif_lookup_values "+
    " WHERE lookup_type = 'RCV_SOURCE_TYPE' "+
    " AND nvl(enabled_flag,'N') = 'Y' "+
    " AND nvl(end_date_active,sysdate+1) > sysdate ";
    ResultSet sl = db.getResultSet(strSQLstr);
    sourceList = new ArrayList();
    while (sl.next()){
    sourceList.add(new SelectItem(sl.getString("sourceType")));
    return(sourceList);
    //PROPERTY: validate and insert data
    public void createRecord() throws Exception{
    updateTxn();
    System.out.println("Inside createRecord");
    System.out.println("getSourceValue()"+getSourceValue());
    if ( !(getSourceValue()!="")){
    System.out.println("getSourceValue()"+getSourceValue());
    //JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please Scan / Enter value for "+getSourceType());
    } else if ((getUseDataSource()=="N") &&
    (!(getPartNumber()!="")||!(getQuantity()!=""))) {
    System.out.println( "Please Enter Part Number and Quantity");
    //JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please Enter Part Number and Quantity" );
    else{
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("Hub Name"+getHubName());
    String insertQuery = "begin "+
    " hif_rcv_pkg.create_record(?,?,?,?,?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.registerOutParameter(3,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getHubName());
    cs.setString(7,getSourceType());
    cs.setString(8, getSourceValue());
    cs.setString(9,getUseDataSource());
    cs.setString(10,getPartNumber());
    cs.setString(11,getQuantity());
    cs.execute();
    con.commit();
    String txnHeaderID = cs.getString(3);
    String errorCode = cs.getString(1);
    String errorMessage = cs.getString(2);
    if (errorMessage != null) {
    setErrorMessage(errorMessage);
    } else{
    if (txnHeaderID != null ){
    setRcvTxnHeaderID(txnHeaderID);
    txnRefEnableDisable= " ";
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    setSourceValue(null);
    setPartNumber(null);
    setQuantity(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void updateRcvQty() throws Exception{
    System.out.println("Inside updateRcvQty");
    //System.out.println("RcvRecord: "+rcvRecord.toString());
    updateTxn();
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("getRcvTxnHeaderID: "+getRcvTxnHeaderID());
    System.out.println("");
    String insertQuery = "begin "+
    " hif_rcv_pkg.update_rcv_qty (?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getSourceType());
    cs.setString(7,getSourceValue());
    cs.executeUpdate();
    con.commit();
    //setSourceValue(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void deleteRecord() throws Exception{
    updateTxn();
    System.out.println("Inside deleteRecord");
    //System.out.println("RcvRecord: "+rcvRecord.toString());
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("");
    String insertQuery = "begin "+
    " hif_rcv_pkg.delete_record (?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getSourceType());
    cs.setString(7, getSourceValue());
    cs.executeUpdate();
    con.commit();
    setSourceValue(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void updateTxn()throws Exception{
    System.out.println("Inside updateTxn");
    int len = rcvDataArray.size();
    Connection con = db.getConnection();
    try{
    for (int i = 0; i < len; i++) {
    RcvTableDataBean bean = (RcvTableDataBean)rcvDataArray.get(i);
    try{
    System.out.println("Updateing Reference Value: "+ bean.getReferenceValue());
    System.out.println("Updateing Comment Value: "+ bean.getRcvComments());
    System.out.println("Updateing Receiving Qty: "+ bean.getRcvQuantity());
    System.out.println("Updateing Receiving Qty: "+ bean.getRcvQuantity());
    String updateQuery = "begin "+
    " hif_rcv_pkg.update_txn(?,?,?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(updateQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getIP());
    cs.setString(4,getUserID());
    cs.setString(5,getRcvTxnHeaderID());
    cs.setString(6,bean.getTxnLineID());
    cs.setString(7,bean.getReferenceValue());
    cs.setString(8,bean.getRcvQuantity());
    cs.setString(9,bean.getRcvComments());
    cs.execute();
    con.commit();
    }catch (Exception e) {
    System.out.println("Error "+ e

    1) Please use code tags in the future. Lengthy, unformatted code isn't likely to read be most people here who are trying to help you for free.
    2) Next time, please use a short, compilable example that demonstrates your problem. Again, that is a lot of code to expect a volunteer to debug.
    3) This does not appear to be a Swing question. Perhaps you should have posted this in one of the web-based forums.
    Good luck.

  • Function to change Boarder Look and feel of Jframe - Not working

    Hi all,
    In the given SSCE, the functionpublic void changeButtonColor(Component[] comps) to change the border look and feel of JFrame is not working.Please help.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Insets;
    import java.util.Vector;
    import javax.swing.AbstractButton;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JViewport;
    import javax.swing.SwingConstants;
    import javax.swing.UIManager;
    public class ScrollableWrapTest {
        public static void main(String[] args) {
            try {
                final JPanel mainPanel = new JPanel(new WrapScollableLayout(FlowLayout.LEFT, 10, 10));
                mainPanel.setBackground(Color.WHITE);
                JScrollPane pane = new JScrollPane(mainPanel);
                pane.setPreferredSize(new Dimension(320, 200));
                Vector v = new Vector();
                v.add("first");
                JButton button = null;
                for(int i =0;i<v.size();i++){
                        JPanel panel = new JPanel(new BorderLayout());
                        panel.setBackground(Color.WHITE);
                        int num = mainPanel.getComponentCount()+1;
                        button = new JButton("button" + num);
                        button.setPreferredSize(new Dimension(90, 25));
                        JLabel label = new JLabel((String)v.elementAt(i));
                        label.setHorizontalAlignment(SwingConstants.CENTER);
                        panel.add(button, BorderLayout.NORTH);
                        panel.add(label, BorderLayout.SOUTH);
                        mainPanel.add(panel);
                        mainPanel.revalidate();
                ScrollableWrapTest st = new ScrollableWrapTest();
                st.buildGUI(pane);
            } catch (Exception e) {e.printStackTrace();}
        public void buildGUI(JScrollPane scrollPane)
             JFrame frame = new JFrame("Scrollable Wrap Test");
             JFrame.setDefaultLookAndFeelDecorated(true);
            UIManager.put("activeCaption", new javax.swing.plaf.ColorUIResource(Color.LIGHT_GRAY));
            changeButtonColor(frame.getComponents());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(scrollPane, BorderLayout.CENTER);
            frame.setLocationRelativeTo(null);
            frame.pack();
            frame.setVisible(true);
        public void changeButtonColor(Component[] comps)
          for(int x = 0, y = comps.length; x < y; x++)
            if(comps[x] instanceof AbstractButton)
              ((AbstractButton)comps[x]).setBackground(Color.LIGHT_GRAY);
              ((AbstractButton)comps[x]).setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
            else if (comps[x] instanceof Container)
              changeButtonColor(((Container)comps[x]).getComponents());
        private static class WrapScollableLayout extends FlowLayout {
            public WrapScollableLayout(int align, int hgap, int vgap) {
                super(align, hgap, vgap);
            public Dimension preferredLayoutSize(Container target) {
                synchronized (target.getTreeLock()) {
                    Dimension dim = super.preferredLayoutSize(target);
                    layoutContainer(target);
                    int nmembers = target.getComponentCount();
                    for (int i = 0 ; i < nmembers ; i++) {
                        Component m = target.getComponent(i);
                        if (m.isVisible()) {
                            Dimension d = m.getPreferredSize();
                            dim.height = Math.max(dim.height, d.height + m.getY());
                    if (target.getParent() instanceof JViewport)
                        dim.width = ((JViewport) target.getParent()).getExtentSize().width;
                    Insets insets = target.getInsets();
                    dim.height += insets.top + insets.bottom + getVgap();
                    return dim;
    }Please help.
    Rony

    You are calling changeButtonColor(frame.getComponents()) before you add the JScrollPane to the content pane.
    But why not just move this to the button creation loop?
    button = new JButton("button" + num);
    button.setBackground(Color.LIGHT_GRAY);
    button.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));

  • DoClick does not work!!!

    For my simple browser I have created a button that allows you to enlarge the size of the text. Now when the page is loaded and you click this button the text size increases as desired.
    However I want the text to automatically change to large when the webpage is loaded. So after the setpage method I used largeTxt.doClick() this does not seem to work.
    Can you please help me solve this problem, my code is below.
    Thanks.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.border.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import java.util.*;
    public class simpleBrowser extends JFrame implements ActionListener, HyperlinkListener {
         public static final String HOME_DEFAULT = "http://www.cs.nott.ac.uk/~nza";
         protected String currentURL = HOME_DEFAULT;
    private BorderLayout border;
    private Container content;
    private JButton buttonGo, largeText ;
    private JTextField textURL;
    private JLabel labelEnterURL;
    private JEditorPane htmlMain;
    private JPanel panel;
    private JScrollPane scrollPane;
    private URL url;
    private String urlString;
    final JLabel statusBar = new JLabel(" ");
    String display;
         public simpleBrowser (String startPage) throws MalformedURLException, IOException {
         super("Simple Browser");
         setSize(600,500);
         addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
         we.getWindow().setVisible(false);
         System.exit(0);
         border = new BorderLayout();
         content = this.getContentPane();
         content.setLayout(border);
         buttonGo = new JButton("GO!");
         buttonGo.addActionListener(this);
         largeText = new JButton("Large Text");
         largeText.addActionListener(this);
         textURL = new JTextField(startPage, 40);
         textURL.setToolTipText("Key in the URL required here");
         labelEnterURL = new JLabel("Enter the URL:");
         url = new URL(startPage);
         htmlMain = new JEditorPane(url);
         htmlMain.setEditable(false);
         htmlMain.addHyperlinkListener(this);
         scrollPane = new JScrollPane(htmlMain);
         panel = new JPanel();
         panel.setLayout(new FlowLayout());
         panel.add(labelEnterURL);
         panel.add(textURL);
         panel.add(buttonGo);
         panel.add(largeText);
         content.add(panel, BorderLayout.NORTH);
         content.add(scrollPane, BorderLayout.CENTER);
         content.add(statusBar, BorderLayout.SOUTH);
         this.pack();
         this.setVisible(true);
    } // End constructor
    public void actionPerformed(ActionEvent e) {
         if (e.getSource().equals(buttonGo)){                    
         DisplayPage(textURL.getText());
         } // End if
         if (e.getSource().equals(largeText)){
              Thread runner = new Thread() {
              public void run() {
         HTMLDocument doc = ((HTMLDocument) htmlMain.getDocument());
              doc.setCharacterAttributes(0, htmlMain.getDocument().getLength(), doc.getStyleSheet()
                   .getDeclaration("font-size:24"), false);
    runner.start();
         } // End if
    } // End actionPerformed
    public void hyperlinkUpdate(HyperlinkEvent e) {
         HyperlinkEvent.EventType eventType = e.getEventType();
         if (eventType == HyperlinkEvent.EventType.ACTIVATED) {
         try {
              htmlMain.setPage(e.getURL());
         } catch (Exception myException) {
              htmlMain.setText("Link error");
         } // End try-catch
         } // End if
    } // End hyperlinkUpdate
    public static void main(String[] args) throws MalformedURLException, IOException {
         simpleBrowser myBrowser = new simpleBrowser(HOME_DEFAULT);
    } // End main
         public void DisplayPage(String strURL) {
         currentURL = strURL;
         textURL.setText(strURL);
         try {
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              htmlMain.setPage(strURL);
              //largeText.doClick();           
         catch (Exception exc) {
                   htmlMain.setText("");
                   statusBar.setText("Could not open starting page. Using a blank.");
         finally {
         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         } //end try
         largeText.doClick();
    } // End class

    I tried your suggesstions to change the methods as shown below but it still does not work. :(
    if (e.getSource().equals(largeText)){
              Thread runner = new Thread() {
              public synchronized void run() {
         HTMLDocument doc = ((HTMLDocument) htmlMain.getDocument());
              doc.setCharacterAttributes(0, htmlMain.getDocument().getLength(), doc.getStyleSheet()
                   .getDeclaration("font-size:24"), false);
    runner.start();
    SwingUtilities.invokeLater(runner);
         } // End if
    public void DisplayPage(String strURL) {
         currentURL = strURL;
         textURL.setText(strURL);
         //m_btnReload.setToolTipText(strURL);
         try {
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              htmlMain.setPage(strURL);
              SwingUtilities.invokeLater(new Runnable() {            
              public void run() {           
              largeText.doClick();
         catch (Exception exc) {
                   htmlMain.setText("");
                   statusBar.setText("Could not open starting page. Using a blank.");
         finally {
         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         } //end try
         //largeText.doClick();
    }

  • TableChanged() does not work with parrent table reference

    Hi,
    I used this example http://www.javalobby.org/articles/jtable/ where the cells refocus after updating, but I have rewrote it to my needs and the program throws nullpointerexception when I update any cell:(
    here is the tableChanged part of code:
        public class InteractiveTableModelListener implements TableModelListener {
            public void tableChanged(TableModelEvent evt) {
                if (evt.getType() == TableModelEvent.UPDATE) {
                    int column = evt.getColumn();
                    int row = evt.getFirstRow();
                    System.out.println("updated row: " + row + " column: " + column);
                   if((column + 1) >= model.getRowCount()){
                      table.removeColumnSelectionInterval(column,column);
                    }else{
                      table.setColumnSelectionInterval(column + 1, column + 1);
                    table.setRowSelectionInterval(row,row);
    }the table reference worked in the exaple but doesnt work in my program:(
    here is the init of the table in function initComponent:
            tableModel.addTableModelListener(new InteractiveTableModelListener());
            TableSorter sorter = new TableSorter(tableModel);
            JTable table = new JTable(sorter);the class is on the same level as the function
    i have searched all the internet for this with no results:(
    thank you for your advice!

    Yes, you are right, I wrote this post in a hurry and exhaused, that it does not work.
    I'm trying to write out a data file (now only a vector of data) in a JTable and I want to edit the rows and after I submit text in a cell, I want the caret to move one cell right, so the user can write another text, just like in MS Excel. At the end of the row the caret disapears but does not create another row.
    And I have problems with variable JTable table in the inner class that contains method tableChanged().
    Well After making an example I realized it worked and then I checked the example line by line and found out that I declare another JTable with the same name in the table initializing method,
    Then the variable couldnt work in tableChanged method... It was empty...
    I used your example from thread, you advised me:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class TableProcessing extends JFrame implements TableModelListener
         // here I declare the table
            protected JTable table;
         public TableProcessing()
              String[] columnNames = {"Item", "Quantity", "Price", "Cost"};
              Object[][] data =
                   {"Bread", new Integer(1), new Double(1.11), new Double(1.11)},
                   {"Milk", new Integer(1), new Double(2.22), new Double(2.22)},
                   {"Tea", new Integer(1), new Double(3.33), new Double(3.33)},
                   {"Cofee", new Integer(1), new Double(4.44), new Double(4.44)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              model.addTableModelListener( this );
                    // here I declare it again, which is a MISTAKE
              JTable table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
                   //  The Cost is not editable
                   public boolean isCellEditable(int row, int column)
                        int modelColumn = convertColumnIndexToModel( column );
                        return (modelColumn == 3) ? false : true;
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
          *  The cost is recalculated whenever the quantity or price is changed
         public void tableChanged(TableModelEvent e)
              System.out.println(e.getSource());
              if (e.getType() == TableModelEvent.UPDATE)
                   int row = e.getFirstRow();
                   int column = e.getColumn();
                   if (column == 1 || column == 2)
                                   // AND here is not initialised - throws NullPointerException
                        TableModel model = table.getModel();
                        int     quantity = ((Integer)model.getValueAt(row, 1)).intValue();
                        double price = ((Double)model.getValueAt(row, 2)).doubleValue();
                        Double value = new Double(quantity * price);
                        model.setValueAt(value, row, 3);
         public static void main(String[] args)
              TableProcessing frame = new TableProcessing();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

  • ScrollPane not reliable

    hey. i set up my site (dangerboydesign.net) with content
    showing up in scrollpanes. it works perfectly on my computer in all
    browsers. but on some other computers, even the same OS and
    browsers and flash plug-ins, the content of the scrollPane is not
    masked by it, and the scrolling function is not there. as this is
    my portfolio, it obviously needs to be as reliable as possible.
    does anyone know a reliable way to use scrollPanes, or should i
    just trash thosh the whole thing and go back to html?
    thanks,
    morgan

    You'll need to show your code and explain what it is supposed to be doing. If you are dynamically placing the image into the movie from the library, you should convert it to a movieclip symbol first and then assign it as Export for Actionscript, etc... Also, what do you mean when you say "when I send the swf file"?

  • Scroll pane not working on Intranet

    I used scroll pane component from flash mx 2004 professional
    . and loaded movie clip in it , when this file run on single
    machine with flash player 7 it works properly , but when I put it
    on intranet , scrollpane doesn’t work , movie get loaded in
    it , but scrollpane is not visible , to work it properly I have to
    change Internet explorer setting . In multimedia setting I have to
    ‘enable don't display online media content in the media bar
    ‘ this setting , after this scrollpane works properly , is
    there any other solution for it . or tell me why its not working
    properly , it is problem of Internet explorer version or flash
    player version.
    please give me a solution for it, its argent ,
    i m waiting for replay

    I see in a lot of forums from 2004 that this is an issue !
    and Macromedia hasnt done anything about it till now is surprising
    and frustrating! and no help to solve it either! that is ridiculous
    now!
    TP

  • Not work tablet UI on Prestigio 5080 PRO tablet

    I read that browser.ui.layout.tablet = "1" can fix this problem. But it not works. I can work only in pnone interface that is not good for my 8'' tablet.

    Would it be possible for you to share the problematic pdf and OS information  with us at [email protected] so that we may investigate?
    Thanks,
    Adobe Reader Team

  • Why self-defined access sequences of free goods can not work?

    Hi gurus,
    I have maintained access sequences of free goods self-defined.but when i creat the SO it does not work!
    when i used the standard access sequences ,it is OK .
    Can anybody tell me why?
    thanks in advance

    Dear Sandy,
    Go to V/N1 transaction select your self defined access sequence then go in to the accesses and fields and check all fields are activated.
    Make sure that these fields are flowing in your sales order.
    I hope this will help you,
    Regards,
    Murali.

  • Adobe bridge raw not working with windows vista in photoshop cc, why?

    adobe bridge raw not working in photoshop cc, is there a fix?

    Your sure your using photoshop cc on windows vista?
    I was under the impression that photoshop cc would not even install on windows vista.
    What version of camera raw do you have?
    In photoshop under Help>About Plugin does it list Camera Raw and if so which version is it?
    (click on the words Camera Raw to see the version)
    Camera raw doesn't work if it's a camera raw file or some other file type such as jpeg or tif?
    What camera are the camera raw files from?
    Officially camera raw 8.3 is the latest version of camera raw that will work on windows vista.

  • Adobe Bridge CS5 in windows 7 not working?

    Adobe Bridge CS5 in windows 7 not working. I was using bridge perfectly for last 2 years. It stops working since 3 days. I tried to install updates. Showing some error to install.
    Tried to install creative cloud..again some error. Error code : 82
    Could you please advice how I can fix my adobe bridge.

    https://www.youtube.com/watch?v=xDYpTOoV81Q&feature=youtu.be
    please check this video I uploaded..this is what happens when I click adobe bridge.. just blinks and go off. bridge not working on task manager

  • ADOBE CLOUD ON MY DESKTOP WILL NOT WORK. IT LOADS UP BUT NOTHING FILLS THE WINDOW

    ADOBE CLOUD ON MY DESKTOP WILL NOT WORK. IT LOADS UP BUT NOTHING FILLS THE WINDOW

    BLANK Cloud Screen http://forums.adobe.com/message/5484303 may help
    -and step by step http://forums.adobe.com/thread/1440508?tstart=0
    -and http://helpx.adobe.com/creative-cloud/kb/blank-white-screen-ccp.html

Maybe you are looking for