Refresh my JTabbedPane??

Am trying to refresh my JTabbedPane everytime a tab is pushed but cant get it work? Can anyone help......
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("G�st", icon, g�st.getContentPane());
          tabbedPane.addTab("Reservation", icon, res.getContentPane());
          tabbedPane.addTab("V�relse",icon,v�r.getContentPane());
          tabbedPane.addTab("Opslag",icon,opslag.getContentPane());
tabbedPane.addTab("Arkiv",icon,arkiv.getContentPane());

I'm not sure what problem you're having. What version of the JDK are you using, and on what platform? I'm running JDK 1.4 on Windows with a stubbed out version of the code you posted and am not running into any problems.
Essentially, I put your code in a JDialog, passed null for the icon and created a JLabel where you pass the contentPane of another component (I'm assuming a JPanel of some sort). This seems to work fine.
Please post more information and I'll take another look.
Ken

Similar Messages

  • Please help Chaps!!! How do I refresh this?

    How do I refresh a Jtabbedpane object?
    I have a JList object in a class that extends JPanel and this
    JList object is in a JTabbedPane.
    How do I refresh each line of data being appended to the
    JLIST object!!!!

    This may or may not help, but have a go anyway. I've got some code with a JTable in a JPanel. There is also a button that when pushed adds a rows to the JTable's TableModel. Initially I found that although the row was being added it wasn't appearing in the table (actually if I minimized and then restored the app the row appeared). So, I stuck in a .repaint(), but to no avail (tried the JTable and the JPanel). Somewhere in my brain a neuron fired and I half rememdered something I read in "Mastering the JFC" about occassionally having to call .revalidate() and it worked.
    I'm looking at the code now - it's a bit of a mess. The gist is :-
    nwRwBttn.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent actnEvnt)
    //        App.this.tbl.revalidate();
            App.this.tblPnl.revalidate();
    });Obviously, I'd tried .revalidate() and on the JTable and then the JPanel to see which worked best.
    Hope it helps.

  • JTabbedPane - removing/adding tabs

    Using JDK 1.4, I am attempting to refresh a JTabbedPane based on a user selection. I have tried several approaches (removing all of the tabs from the JTabbedPane; removing the panel the JTabbedPane sits on from a larger panel). In both cases, doing a remove (JTabbedPane.removeAll for the JTabbedPane, and Panel.remove [component] for the panel), the area where the JTabbedPane should appear is blank. Here is the code I have tried (createTabs calls the addTab method; createTabPanel puts the tabbedpane on a panel):
    public void refreshWindow ( String asReportNo )
         // Remove current tab panel from main panel
         csjpMainPanel.remove ( csjpTabPanel );
         // Recreate tabs, then tab panel
         //csjtab.removeAll();
         //csjtab.revalidate();
         JTabbedPane lsjtab = createTabs ( asReportNo );
         csjtab = lsjtab;
         csjpTabPanel = createTabPanel();
         //csjtab.setVisible ( true );
         //csjpTabPanel.setVisible ( true );
         csjpTabPanel.revalidate();          
         csjpTabPanel.repaint();
         // Put tab panel back on main panel
         GridBagConstraints lgbc = new GridBagConstraints();
         lgbc.gridx = 1;
         lgbc.gridy = 0;
         lgbc.insets = new Insets ( 3, 3, 3, 3 );
         lgbc.weightx = 1.0;
         lgbc.weighty = 0.5;
         lgbc.fill = GridBagConstraints.BOTH;
         lgbc.anchor = GridBagConstraints.NORTHWEST;
         csjpMainPanel.add ( csjpTabPanel, lgbc );
         csjpMainPanel.repaint();          
    Any ideas on what I could do to make the tabbed pane visible? I saw that there was a problem with JTabbedPane in earlier releases, but this is with 1.4.
    Thanks,
    Van Williams

    yes, that's right... remove the synchronized blocks and replace them with invoke laters... If your are going to synchronize this, it has to be
    synchronized(monitor) {
    // update code
    -->
    synchronized(tabbedPane.getTreeLock()) {
    // update code
    which is still not as good as the following
    -->
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      // update code
    };

  • Refresh JTabbedPane when tab is pushed?

    My JtabbedPane is working fine, but the problem is that my last JFrame in my JtabbedPane called arkiv has to get updated everytime its tab is pushed and i cant get to work .I tried repaint() ,removeAll() but cant get it to work...
    Can anyone help me with this?

    I first posted in the wrong spotSo what was wrong the the suggestion given?
    But, I need the table refresh if tab1 data is changed.I said you update the TableModel. Thats all there is to it. No need to repaint or anything, the model is responsible for telling the table to repaint itself.
    You can
    a) update the TableModel directly using setValueAt(...), insertRow(...), removeRow(...) etc, or
    b) recreate the entire TableModel from scratch and then use:
    table.setModel( newlyCreatedModel );
    Where is your SSCCE program. We don't want to see you database code. An SSCCE will hardcord the data to simulate a database query. That way you can post working code.

  • How to diable JDialog on refresh of a data in a tab

    Hi,
    I have an application which has a tab1 which contains a Jtable.On clicking a cell in Jtable a JDialog appears showing some more info on the cell clicked.
    Now i want to do this...
    When i refresh the tab1 the corresponding Jdialog should become empty without any value, assuming that tab1 content has changed.
    How i can go about doing the above?
    A simple code snippet/idea would be of great help.
    Thanks.

    Continued code
    fetch();
                        fetch2();
                        /*table.tableChanged(new TableModelEvent(table.getModel()));
                        if (pane != null) {
                             pane.setMessage("");
                        table.repaint();
                        table2.tableChanged(new TableModelEvent(table2.getModel()));
                        if (pane2 != null) {
                             pane2.setMessage("");
                        table2.repaint();*/
              lookup.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        /*if(b1!= true){
                             System.out.println("Coming");
                             JTabbedPane tabbedPane = new JTabbedPane();
                             JPanel phones = new JPanel();
                             mtm = new DefaultTableModel(columnNames, 2);
                             JTable table = new JTable();
                             table =  new JTable(mtm);
                             //JPanel phones = new JPanel();
                             JScrollPane scroller = new JScrollPane();
                             JPanel p = new JPanel(new BorderLayout());
                             JPanel topPanel = new JPanel();
                             JButton lookup = new JButton("Lookup");
                             scroller = new JScrollPane(table);
                             topPanel.add(lookup);
                             phones.add(scroller);
                             tabbedPane.addTab("Phones", phones);
                             p.add(topPanel, BorderLayout.NORTH);
                             p.add(tabbedPane, BorderLayout.CENTER);
                             setContentPane(p);
                             pack();
                             di = new Dbi();
                             fetch();
                             if (pane != null) {
                                  pane.setMessage("");
                             table.repaint();
                             b1=true;
                             System.out.println("Going");
                        fetch();
                        table.tableChanged(new TableModelEvent(table.getModel()));
                        if (pane != null) {
                             pane.setMessage("");
                        table.repaint();
                        //table.setModel(new DefaultTableModel(0, 0));
                        //b1=false;
              lookup1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        fetch2();
                        table2.tableChanged(new TableModelEvent(table2.getModel()));
                        if (pane2 != null) {
                             pane2.setMessage("");
                        table2.repaint();
                        //table.setModel(new DefaultTableModel(0, 0));
         public void fetch() { // time-consuming task should be run
              Thread t = new Thread() { // in a separate thread
                   public void run() {
                        dbResult = di.getQueryResult("QUERY!!!!!");
                        mtm.setDataVector(dbResult, cnv);
              t.start(); // actionPerformed() immediately returns, not blocking GUI
         public void fetch2() { // time-consuming task should be run
              Thread t = new Thread() { // in a separate thread
                   public void run() {
                        dbResult = di2.getQueryResult("QUERY!!!!!");
                        mtm2.setDataVector(dbResult, cnv);
              t.start(); // actionPerformed() immediately returns, not blocking GUI
         public static void main(String[] args) {
              TestJava frame = new TestJava();
              frame.setVisible(true);
    class Dbi{ // make it a separate public class
         // meaningfull constructors, db connecton etc.
         public Vector<Vector> getQueryResult(String query) {
              Vector<String> v1 = new Vector<String>();
              Vector<String> v2 = new Vector<String>();
              Vector<String> v3 = new Vector<String>();
              Vector<String> v4 = new Vector<String>();
              v1.addAll(Arrays.asList(new String[] { "Tim Marshall",
                        "http://tim.marshall/", "Never never land" }));
              v2.addAll(Arrays.asList(new String[] { "Com Commercial",
                        "http://com.comcom/", "Land of gold" }));
              v3.addAll(Arrays.asList(new String[] { "Love Lovable",
                        "http://love.neverhate/", "Sun lotus state" }));
              v4.addAll(Arrays.asList(new String[] { "War Monger",
                        "http://war.momongers/", "Fire and ice city" }));
              Vector<Vector> v0 = new Vector<Vector>();
              v0.add(v1);
              v0.add(v2);
              v0.add(v3);
              v0.add(v4);
              return v0;
         // other important methods
    class Dbi2{ // make it a separate public class
         // meaningfull constructors, db connecton etc.
         public Vector<Vector> getQueryResult(String query) {
              Vector<String> v1 = new Vector<String>();
              Vector<String> v2 = new Vector<String>();
              Vector<String> v3 = new Vector<String>();
              Vector<String> v4 = new Vector<String>();
              v1.addAll(Arrays.asList(new String[] { "Ran Rand",
                        "http://tim.marshall/", "Never never land" }));
              v2.addAll(Arrays.asList(new String[] { "Jim Corbet",
                        "http://com.comcom/", "Land of gold" }));
              v3.addAll(Arrays.asList(new String[] { "Ram Jim",
                        "http://love.neverhate/", "Sun lotus state" }));
              v4.addAll(Arrays.asList(new String[] { "Click Thick",
                        "http://war.momongers/", "Fire and ice city" }));
              Vector<Vector> v0 = new Vector<Vector>();
              v0.add(v1);
              v0.add(v2);
              v0.add(v3);
              v0.add(v4);
              return v0;
         }

  • JTabbedPane : JPanel transparent to 2D drawings

    Hi.
    I am using ptolemy/ptplot package for 2D graphics. I use a JTabbedPane to managae my plots by pages. Each plot is updated continuously by a Thread which get data from a datatbase.
    The problem: when a plot is refreshed in a hidden Tab, the plot appears also in the selected Tab. Only
    the data points appear, not the axes and the background. Result: I have a supperposition of "undesired
    plots" on the selected Tab.
    Please some one tell me how to solve this problem ?
    N.B.: I don't have a real experience with Java 2D.
    Christophe.

    Hi.
    I have found a workaround : my JTabbedPane now implements ChangeListener and "pauses" the plotting
    when a new Tab is selected. Only the plots on the selected Tab are refreshed the other are "paused".
    Thanks to hpsmartyz for the reply but I am new to Java2D, and I was not ready to modify the plot
    package I am using and implements his solution.
    Christophe.

  • JTabbedPane and its accompanying ChangeListener.

    Hi all,
    I have a JTabbedPane with two tabs and a ChangeListener. If I click on a single Tab I check in the stateChanged-Method via "((JTabbedPane)event.getSource()).getSelectedIndex()==0" the selected Index of the tab.
    This works fine.
    But If I generate a PopUp-Event in a selected tab the program branch also in the TabbedPane-Change-Listener and if I check now via "((JTabbedPane)event.getSource()).getSelectedIndex()==0" the selected index is not correct !?
    What goes wrong ?
    incs

    Ok. The problem is solved ! The changelistener-method was access through a refresh event and not through a "chlick-tabbedpane-event".

  • JTabbedPane - Switching tabs erases drawn graphics2d.

    We are using JPanes in a JTabbedPane for a web interface application.
    When switching to a tab in the JTabbedPane that already has Graphics2D components drawn on a JPane (lines, etc.), the drawn information disappears.
    We currently have the paint() method overrided in the JPane where we are actually drawing graphics.
    One work around we have tried was to place code in the JTabbedPane's componentlistener to run when it detects we've switched tabs. That didn't work as the code that runs is done prior to the final refresh of the JTabbedPane, which removes any drawn information.
    We had to place a refresh button on the JPane for the user to click (or any other even trigger) to re-draw the information in order for the image/graphics to be seen.
    How can we avoid this event-only displaying of our graphics? Is there another tab-switching trigger we are unaware of?

    You might have misunderstood how painting works: The information will NOT be retained after being drawn - there is not an "image" for each JPanels that keep the information drawn onto it. If you minimize the application, then restore it, you need to paint it again. If the user have put another window on top of your application, and then moves it, you will have to paint again. If you switch tabs or similar internally in your application, you will also have to paint again. This style is called "immediate mode"-type painting (Which can be compared to "retained mode" painting, whereby there actually is an image that will keep the information between changes. "Scene graph" approaches (which is what JavaFX does AFAIK, and also Java3D) is another "retained mode"-like mode.).
    Thus, one will have to paint everything for every display (The "clip area" in the graphics object defines how much you need to draw - e.g. if the user had a window partially over the application). You accomplish this by overriding paintComponent(Graphics g) on the component, which will be invoked every time the component needs to be redrawn.

  • JTabbedPane question. Please give advice.

    I am writing some applicaiton which includes a jTabbedPane.(with 4 tabs)
    Say I have tab A,B,C,D. Which contains panelA, panelB, panelC and panelD under each tab.
    I would like to refresh corresponding panel when user click on the tab.
    I tried panelB's focusGained event, but it doesn't work right. I would have to click on some control of other panel for it to work.
    How do I trigger a function which user click on B tab? not some control in panelB.
    I am new to swing. please give some advice.
    Thanks

    Add a changeListener to your JTabbedPane which forwards an update to your panels when the current tab is changed,
    ... or ...
    put your updating in a overridden setVisible() in your panels, since the JTabbedPane uses visibility to control which tab gets shown.

  • Can not refresh view data in STRUST

    I am using the JSP (STRUTS) for developing my App.
    I get a list of contact. In bellow it, I make a link for each contacts.
    When i view details of one contact. On click link below.
    My pages:
    listcontact.jsp
    contactdetails.jsp
    When i request a details of contact from list contact -> View successfull.
    But when i refresh the contactdetails.jsp page. I got a message error:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.
    I have to use:
    response.setHeader("Cache-Control","no-store");
    response.setHeader("Pragma","no-cache");
    But can't refresh any way this page.
    Plase show me the way to solve it.
    Thanks
    Vu Nguyen

    hi,
    Here are codes
    listdata = new CompanyListData();
    companyList = (ArrayList) session.getAttribute("datalist_company");
    if (companyList == null)
    companyList = (ArrayList) listdata.getCompanyList(datasource);
    session.setAttribute("total", companyList.size()+ " companies");
    session.setAttribute("datalist_company", companyList);
    return (mapping.findForward("success"));
    And for details:
    if ((addressItem==null && companyName!=null)||(addressItem==null&& companyId!="0"))
    addressData = new AddressDetailData();
    addressItem = addressData.getAddressItem(datasource, companyId);
    session.setAttribute("addressDetail", addressItem);
    I got companyID by:
    String companyId = request.getParameter("companyId");
    return (mapping.findForward("success"));
    Please gest the problems that.
    Thanks,

  • Same EPM Excel Report takes time to open and refresh on 1 system while it opens and refreshes faster on other system

    Hi All ,
    I am facing an issue where the EPM Excel Templates on SERVER ROOT FOLDER take time to open on 1 system . It also takes great amount of time to REFRESH . While on an another system the same Report opens rather quickly and refreshes also quickly .
    Regards,
    SHUBHAM

    Hi Shubham,
    Now day excel problems are due to some MS update.  Not sure but  have a look at below note.
    2107965 - Issues in EPM Add-in after installing Microsoft updates

  • Refreshing the Data from a embed view in a view container

    Hi everybody
    I would like to know how can I do to refresh all data from a View with a view container the problem is:
    that I have a window that has a view at the same time this has a view container.  The Main view brings the data of editable elements when I select one element of the main view the view container brings a list for that element (dependencies) but only the first time a choose an element loads the correct data, when I choose another one it brings the same old data and doesn't make the call for the wdDoInit() method.
    The question is:
    How do I force the view to refresh all the data or call again the wdDoInit() method?
    Thank you for your help

    Aida,
    Lets say you have two components C1 and C2 and you want method from C1 to be available in C2 then follow these steps:-
    1) Goto the Interface Controller of C1 and create a method there lets say doSomething
    2) Then goto C2. There you can see Used Web Dynpro Components --> Right click Add Used Component --> Give some name say C1Comp --> Click browse and select C1 --> Click Finish.
    3) Next goto Component Controller of C2 --> Properties --> Click Add and check if C1 is added. If not then select the checkbox and select OK.
    4) Now goto Implementation tab of C2 and lets say wdDoInit you can write following code:-
    wdThis.wdGetC1CompInterface().doSomething();
    Chintan

  • Not able to refresh the data in a table

    Hi In my application i fill data in a table on clikc of a button ..
    Following are the line of code i have user
    RichColumn richcol = (RichColumn)userTableData.getChildren().get(0);                                           (fetch the first column of my table)
    richcol.getChildren().add(reportedByLabel);                                                                   (reportedByLabel is a object of RichInputText)
    AdfFacesContext adfContext1 = AdfFacesContext.getCurrentInstance();
    adfContext1.addPartialTarget(richcol);
    adfContext1.addPartialTarget(userTableData);
    But on submit of that button table data is not refreshed after adding partial trigger on that table as well as that column also .... any idea??
    Edited by: Shubhangi m on Jan 27, 2011 3:50 AM

    Hi,
    The Code that you have shown adds an additional inputText component to the first column of a table.
    Is that your intention?
    If yes, please use the following code snippet to achieve your functionality:
    JSPX Code:
    <af:form id="f1">
    <af:commandButton text="Add Column" id="cb1"
    actionListener="#{EmployeesTableBean.onAddColumn}"/>
    <af:table value="#{bindings.Employees.collectionModel}" var="row"
    rows="#{bindings.Employees.rangeSize}"
    emptyText="#{bindings.Employees.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.Employees.rangeSize}"
    rowBandingInterval="0"
    selectedRowKeys="#{bindings.Employees.collectionModel.selectedRow}"
    selectionListener="#{bindings.Employees.collectionModel.makeCurrent}"
    rowSelection="single" id="t1"
    binding="#{EmployeesTableBean.table}">
    <af:column sortProperty="EmployeeId" sortable="false"
    headerText="#{bindings.Employees.hints.EmployeeId.label}"
    id="c1">
    <af:outputText value="#{row.EmployeeId}" id="ot2">
    <af:convertNumber groupingUsed="false"
    pattern="#{bindings.Employees.hints.EmployeeId.format}"/>
    </af:outputText>
    </af:column>
    <af:column sortProperty="FirstName" sortable="false"
    headerText="#{bindings.Employees.hints.FirstName.label}"
    id="c2">
    <af:outputText value="#{row.FirstName}" id="ot1"/>
    </af:column>
    <af:column sortProperty="LastName" sortable="false"
    headerText="#{bindings.Employees.hints.LastName.label}"
    id="c3">
    <af:outputText value="#{row.LastName}" id="ot3"/>
    </af:column>
    </af:table>
    </af:form>
    Bean:
    public class EmployeesTableBean {
    private RichTable table;
    public EmployeesTableBean() {
    public void setTable(RichTable table) {
    this.table = table;
    public RichTable getTable() {
    return table;
    public void onAddColumn(ActionEvent actionEvent) {
    RichInputText newRichInputText = new RichInputText();
    newRichInputText.setId("new");
    newRichInputText.setValue("Name:");
    RichColumn richcol = (RichColumn)table.getChildren().get(0);
    richcol.getChildren().add(newRichInputText);
    AdfFacesContext adfContext1 = AdfFacesContext.getCurrentInstance();
    adfContext1.addPartialTarget(table);
    Thanks,
    Navaneeth

  • Not having to refresh the data in the main report but only in the subreport

    Hi SAP,
    I have a report that uses a stored procedure in the main report and uses regular database tables in the subreport.  The data returned from the stored procedure reports information from the month-end database (a cutoff point from the previous month's numbers) while the subreport reports information from the live database.  This report gets run everyday to show the changes in numbers from the live database.  Obviously the numbers from the month-end database remainds static until the next month's cutoff database is created. 
    My problem is that everyday when I run the report, the data needs to refresh from both the stored procedure in the main report and the live database tables in the subreport.  How can I leave the data returned from the stored procedure static or as is without refreshing the stored procedure returned data and just have the subreport data refresh itself?  The stored procedure really puts a strain on the database and I would like to cut-out the time to process the report as well.  Does anyone have any ideas?
    Zack

    Hi Zack,
    Try the following under Report options.
    1. Clear the check box of "Verify Stored Procedures on First Refresh" in the Main report.
    2. Select the check box of "Verify on First Refresh" in  the sub report.
    Hope this helps.

  • Can not refresh ValueObject after altering database table

    Hello All,
    In FB4, in order to refresh a service, I used to
    - select a service operation
    - select configure return type
    - select auto-detect
    - hit next and on the follow page select the existing ValueObject
    ...it would update.
    As far as I can see, this does not work in FB4.5.  Instead, after selecting auto-detect and clicking next:
    There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again.
    Reason: Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in...
    Is there a way to refresh a ValueObject.  Clicking refresh is a no go.
    Thanks for your help!
    J

    hey jay.  did you ever figure out how to update your valueObject?  I just posted a similar discussion "changing php-service in FD breaks AS3 service class and valueObjects" here: http://forums.adobe.com/thread/882288
    maybe we'll get a reply....

Maybe you are looking for

  • How to sync multiple iPods & iPhones to one iMac?

    Ok, so my problem is that my whole family syncs their Apple electronics to one computer and we all get our information mixed up. For example, my notes end up on my brother's iPod while my dad's contacts, end up on my iPod. Please help me get this all

  • Is there a way to prevent apps from reopening on startup?

    I like to shut my computer down without closing each app but I don't want to have them all reopen on start up. Is there a way to prevent apps from reopening on startup without having to close them all before shutting down? I found the checkbox to pre

  • Seeburger sFTP receiver adapter error: Socket Write Error, EOF Received

    Hello experts, We have a sFTP to sFTP scenario for which we are getting below error every time the scenario is executed. Error Messages are as follows: Put File: Could not connect to remote host, Reason: Unexpected termination; software caused connec

  • Variables for prior and next periods in logic

    Hi, I'd like to do something that I would have thought should be quite simple, but I just haven't managed to get it right. In Category, we use the properties Year and Month. For example: Member  Year     Month Actual     2014     APR SP          2016

  • Can't subscribe because i'm french but living in china !

    Hi, I'm French, with French VISA card registered in France and/or French paypal account, but i'm living in China for work. I'd like to simply subscribe to the montly program, and i can't ! It's saying that it's not open in China... Even when i'm usin