Paint() method is in infinite loop when focus is set to JTextPane

Hi All,
I am creating one JScrollPane, JPanel and JTextPane. JPanel is added to JScrollPane and JTextPane is added to JPanel. If I override paint() method in JPanel, its in infinite loop. I don't know why it is behaving like this. Can anyone solve my problem. Since, I am doing so much drawings in paint() method, its getting to slow.
Here is the code what I wrote.
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
public class TestTextPane1 extends JFrame {
     JPanel panel;
     JScrollPane pane;
     public TestTextPane1() {
          panel = new JPanel(new BorderLayout()) {
               public void paint(Graphics g) {
                    super.paint(g);
                    System.out.println("inside paint");
          JTextPane textPane = new JTextPane();
          panel.add(textPane);
          pane = new JScrollPane(panel);
          getContentPane().add(pane);
          setSize(300, 200);
          setVisible(true);
     public static void main(String [] args) {
          new TestTextPane1();
Any help will be useful for me.
Regards
Kishore.

What are you trying to do? You are adding the textPane to the panel and then overriding the paint() method. The textPane will never be painted if you do this.
In Swing, you should override the paintComponent() method, not the paint() method. See the Swing tutorial on Painting:
http://java.sun.com/docs/books/tutorial/uiswing/overview/draw.html
Don't forget to read the "Working With Graphics" link at the bottom.

Similar Messages

  • Infinite loop when using the set language context API(This would be useful for f

    Hi below is the code when execute goes into the infinite loop
    Can any body throw light on this...
    Regards,
    Ranjit
    CREATE OR REPLACE procedure draw_custom_login_page
    site2pstoretoken in varchar2 default null
    ,p_error_code in varchar2 default null
    ,ssousername in varchar2 default null
    ,p_cancel_url in varchar2 default null
    ,p_submit_url in varchar2 default null
    AS
    var_bannergif                          varchar2(80);
    var_bannertitle                     varchar2(4000);
    var_bannerinfo                     varchar2(4000);
    var_linkname                          varchar2(4000);
    var_loginuser                     varchar2(4000);
    var_loginpwd                     varchar2(4000);
    var_loginbuttton                     varchar2(4000);
    var_listlangcaption                    varchar2(4000);
    var_optioneng                         varchar2(4000);
    var_optionspanish                    varchar2(4000);
    var_optionfrench                varchar2(4000);
    p_nls_language                varchar2(5);
    l_url                                   varchar2(4000);
    l_language                               varchar(2000);
    ex                                         exception;
    BEGIN
         -- for setting the browser language
              begin
                        --if (owa_cookie.get('NLS_LANGUAGE').vals.count = 0) then
                   -- if persistent NLS cookie is not found
                   -- get the preferred browser language from environment
                   --l_language := substr(wwctx_api.get_http_accept_language,0,2);
                                  --else
                                  --l_language:='us';
                        --end if;
                                  l_language := substr(wwctx_api.get_http_accept_language,0,2);
                                  l_url :='portal30_sso.draw_custom_login_page';
                                  if (owa_cookie.get('NLS_LANGUAGE').vals.count = 0) then
                                       -- set portal language and redirect instead of just redirect
                                       wwctx_app_language.set_language(p_http_language =>
                                                      l_language,p_nls_language => wwnls_api.http_to_nls(l_language),
                                       p_nls_territory => wwnls_api.territory_from_http_language(l_language),p_requested_url => l_url);
                             else
                                       owa_util.redirect_url(l_url);
                        end if;
         exception
         when others then
                   htp.p('Error Occurred');
         wwerr_api_error_ui.show_html;
              end;
         ----up to here
    --for retrieving the NLS Language Equivalents
         begin
         var_bannergif                := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_gif',wwctx_api.get_nls_language);
         var_bannertitle                := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_message',wwctx_api.get_nls_language);
         var_bannerinfo                    := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_info',wwctx_api.get_nls_language);
         var_linkname                    := portal30.wwnls_api.get_string('CBS','banner_uilink','link_name',wwctx_api.get_nls_language);
         var_loginuser                    := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_name',wwctx_api.get_nls_language);
         var_loginpwd                    := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_password',wwctx_api.get_nls_language);
         var_loginbuttton                := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_button',wwctx_api.get_nls_language);
         --for filling up the list box
         var_listlangcaption          := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_caption',wwctx_api.get_nls_language);
         var_optioneng                    := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optioneng',wwctx_api.get_nls_language);
         var_optionspanish               := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optionspan',wwctx_api.get_nls_language);
         var_optionfrench           := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optionfrench',wwctx_api.get_nls_language);
         end;
    --Up to here
    htp.p('<HTML>');
    --htp.p('<FORM>');
    htp.p('<HEAD><TITLE>'||var_bannertitle||'</TITLE>');
    htp.p('<META content="text/html; charset=utf-8" http-equiv=Content-Type>');
    htp.p('<STYLE>.bodytext {COLOR: black; FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 11pt; fontFamily: Verdana,Arial,Helvetica}');
    htp.p('.header1 {');
         htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 14pt; FONT-WEIGHT: bold; fontFamily: Verdana,Arial,Helvetica');
         htp.p('}');
         htp.p('.large {');
              htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 18pt; FONT-WEIGHT: bold; fontFamily: Verdana,Arial,Helvetica}');
         htp.p('.small {');
              htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 8pt; FONT-WEIGHT: normal; fontFamily: Verdana,Arial,Helvetica');
         htp.p('}');
         htp.p('</STYLE>');
         htp.p('<BODY leftMargin=0 topMargin=0 MarginWidth="0" MarginHeight="0"> ');
         htp.p('<TABLE background="/images/h_wave.gif" border=0 cellPadding=0 cellSpacing=0 width="100%">');
         htp.p('<TBODY>');
         htp.p('<TR>');
    htp.p('<TD height=36>  </TD></TR></TBODY></TABLE>');
         htp.p('<TABLE border=0 cellPadding=7 cellSpacing=0 width="100%">');
         htp.p('<TR>');
    htp.p('<TD height=36><IMG alt="" border=0 height=45 width=140 src="/images/'||var_bannergif||'"></TD>');
         htp.p('<TD height=36 align=right valign=top>');
         htp.p('<form name="cbs_language_select" action="PORTAL30_SSO.wwctx_app_language.set_language" method="POST">');
         htp.p('<input type="hidden" name="p_http_language" value="">');
    htp.p('<input type="hidden" name="p_nls_territory" value="">');
    htp.p('<input type="hidden" name="p_requested_url" value="portal30_sso.draw_custom_login_page">');
         htp.p('<select name=p_nls_language value="null" onChange="javascript:fn_cbs_lang_submit(p_nls_language)">');
         htp.p('<option selected>'||var_listlangcaption||'</option>');
         htp.p('<option value="us">'||var_optioneng||'</option>');
         htp.p('<option value="e">'||var_optionspanish||'</option>');
         htp.p('<option value="f">'||var_optionfrench||'</option>');
         htp.p('</select>');
         htp.p('</form>');
         htp.p('</TD> ');
         htp.p('</TR></TBODY></TABLE>');
         --htp.p('<DIV align=center>');
         htp.p('<TABLE border=0 cellPadding=5 cellSpacing=6 width=100%>');
         htp.p('<TBODY>');
         htp.p('<TR>');
         htp.p('<TD border=0 width=30%> </TD>');
         htp.p('<TD width=50%><span class=large>'||var_bannertitle||'</span>');
              htp.p('<P class=bodytext>'||var_bannerinfo||'<P>');
         --htp.p('Oracle''s financial applications to leverage the power of a single');
         --htp.p('integrated database with common data standards and core processes. This');
         --htp.p('tool empowers employees at their desktops, enabling them to requisition');
         --htp.p('goods and services, as well as pay bills and personal expenses online via');
         --htp.p('a Web browser.');
         htp.p(''||var_linkname);
         htp.p('');
         htp.p('<P align=center><A');
              htp.p('href="https://p2pweb1d.nj.ssmb.com:3043/pls/p2pdb30_portal30_sso"');
              htp.p('</TD>');
         --htp.p('<TD class=bodytext height=25>  </TD>');
         htp.p('<TD width=20% valign=top align=right >');
                        htp.p('<TABLE cellpadding=5 BGCOLOR="#F2F2F2"');
                        htp.p('<TR><TD align=right>');
                        htp.p('<p class=small><b>'||var_loginuser||'</b> <input class=small type=text size=15 name=user value="">');
                        htp.p('<P class=small><b>'||var_loginpwd||'</b> <input class=small type=password size=15 name=password value="">');
                        htp.p('</TD></TR>');
                        htp.p('<TR><TD align=right>');
                        htp.p('<input class=small type=button size=15 name=cmd_login value='||var_loginbuttton||'>');
                        htp.p('</TD></TR>');
                        htp.p('</TABLE>');
              htp.p('</TD>');
         htp.p('</TR></TBODY></TABLE>');
              --htp.p('</DIV>');
              htp.p('</BODY>');
              --htp.p('</FORM>');
              htp.p('</HTML>');
              htp.p('<SCRIPT language=JavaScript>');
                             htp.p('var l_http_language = new Array()');
                             htp.p('var l_nls_territory = new Array()');
                        htp.p('l_http_language[1] = "en"');
                        htp.p('l_nls_territory[1] = "AMERICA"');
                        htp.p('l_http_language[2] = "fr"');
                        htp.p('l_nls_territory[2] = "FRANCE"');
                        htp.p('l_http_language[3] = "de"');
                        htp.p('l_nls_territory[3] = "GERMANY"');
                        htp.p('l_http_language[4] = "ja"');
                        htp.p('l_nls_territory[4] = "JAPAN"');
                        htp.p('l_http_language[5] = "es"');
                        htp.p('l_nls_territory[5] = "SPANISH"');
                                                 htp.p('function fn_cbs_lang_submit(field){');
                                                                --htp.p('alert (document.cbs_language_select.p_http_language.value)');
                                                      htp.p('if ( field.selectedIndex != 0 )');
                                                      htp.p('{');
                                                      htp.p('document.cbs_language_select.p_http_language.value = l_http_language[field.selectedIndex]');
                                                                htp.p('document.cbs_language_select.p_nls_territory.value = l_nls_territory[field.selectedIndex]');
                                                      htp.p('document.cbs_language_select.submit();');
                                                      htp.p('}');
                                                                                              htp.p('}');
              htp.p('</SCRIPT>');
              exception when others then
              htp.p(l_language);
              htp.p(SQLCODE);
              htp.p(SQLERRM);
    END;

    Hi below is the code when execute goes into the infinite loop
    Can any body throw light on this...
    Regards,
    Ranjit
    CREATE OR REPLACE procedure draw_custom_login_page
    site2pstoretoken in varchar2 default null
    ,p_error_code in varchar2 default null
    ,ssousername in varchar2 default null
    ,p_cancel_url in varchar2 default null
    ,p_submit_url in varchar2 default null
    AS
    var_bannergif                          varchar2(80);
    var_bannertitle                     varchar2(4000);
    var_bannerinfo                     varchar2(4000);
    var_linkname                          varchar2(4000);
    var_loginuser                     varchar2(4000);
    var_loginpwd                     varchar2(4000);
    var_loginbuttton                     varchar2(4000);
    var_listlangcaption                    varchar2(4000);
    var_optioneng                         varchar2(4000);
    var_optionspanish                    varchar2(4000);
    var_optionfrench                varchar2(4000);
    p_nls_language                varchar2(5);
    l_url                                   varchar2(4000);
    l_language                               varchar(2000);
    ex                                         exception;
    BEGIN
         -- for setting the browser language
              begin
                        --if (owa_cookie.get('NLS_LANGUAGE').vals.count = 0) then
                   -- if persistent NLS cookie is not found
                   -- get the preferred browser language from environment
                   --l_language := substr(wwctx_api.get_http_accept_language,0,2);
                                  --else
                                  --l_language:='us';
                        --end if;
                                  l_language := substr(wwctx_api.get_http_accept_language,0,2);
                                  l_url :='portal30_sso.draw_custom_login_page';
                                  if (owa_cookie.get('NLS_LANGUAGE').vals.count = 0) then
                                       -- set portal language and redirect instead of just redirect
                                       wwctx_app_language.set_language(p_http_language =>
                                                      l_language,p_nls_language => wwnls_api.http_to_nls(l_language),
                                       p_nls_territory => wwnls_api.territory_from_http_language(l_language),p_requested_url => l_url);
                             else
                                       owa_util.redirect_url(l_url);
                        end if;
         exception
         when others then
                   htp.p('Error Occurred');
         wwerr_api_error_ui.show_html;
              end;
         ----up to here
    --for retrieving the NLS Language Equivalents
         begin
         var_bannergif                := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_gif',wwctx_api.get_nls_language);
         var_bannertitle                := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_message',wwctx_api.get_nls_language);
         var_bannerinfo                    := portal30.wwnls_api.get_string('CBS','banner_uitext','banner_info',wwctx_api.get_nls_language);
         var_linkname                    := portal30.wwnls_api.get_string('CBS','banner_uilink','link_name',wwctx_api.get_nls_language);
         var_loginuser                    := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_name',wwctx_api.get_nls_language);
         var_loginpwd                    := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_password',wwctx_api.get_nls_language);
         var_loginbuttton                := portal30.wwnls_api.get_string('CBS','banner_uilogin','login_button',wwctx_api.get_nls_language);
         --for filling up the list box
         var_listlangcaption          := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_caption',wwctx_api.get_nls_language);
         var_optioneng                    := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optioneng',wwctx_api.get_nls_language);
         var_optionspanish               := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optionspan',wwctx_api.get_nls_language);
         var_optionfrench           := portal30.wwnls_api.get_string('CBS','banner_listlang','listlang_optionfrench',wwctx_api.get_nls_language);
         end;
    --Up to here
    htp.p('<HTML>');
    --htp.p('<FORM>');
    htp.p('<HEAD><TITLE>'||var_bannertitle||'</TITLE>');
    htp.p('<META content="text/html; charset=utf-8" http-equiv=Content-Type>');
    htp.p('<STYLE>.bodytext {COLOR: black; FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 11pt; fontFamily: Verdana,Arial,Helvetica}');
    htp.p('.header1 {');
         htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 14pt; FONT-WEIGHT: bold; fontFamily: Verdana,Arial,Helvetica');
         htp.p('}');
         htp.p('.large {');
              htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 18pt; FONT-WEIGHT: bold; fontFamily: Verdana,Arial,Helvetica}');
         htp.p('.small {');
              htp.p('FONT-FAMILY: Verdana,Arial,Helvetica; FONT-SIZE: 8pt; FONT-WEIGHT: normal; fontFamily: Verdana,Arial,Helvetica');
         htp.p('}');
         htp.p('</STYLE>');
         htp.p('<BODY leftMargin=0 topMargin=0 MarginWidth="0" MarginHeight="0"> ');
         htp.p('<TABLE background="/images/h_wave.gif" border=0 cellPadding=0 cellSpacing=0 width="100%">');
         htp.p('<TBODY>');
         htp.p('<TR>');
    htp.p('<TD height=36>  </TD></TR></TBODY></TABLE>');
         htp.p('<TABLE border=0 cellPadding=7 cellSpacing=0 width="100%">');
         htp.p('<TR>');
    htp.p('<TD height=36><IMG alt="" border=0 height=45 width=140 src="/images/'||var_bannergif||'"></TD>');
         htp.p('<TD height=36 align=right valign=top>');
         htp.p('<form name="cbs_language_select" action="PORTAL30_SSO.wwctx_app_language.set_language" method="POST">');
         htp.p('<input type="hidden" name="p_http_language" value="">');
    htp.p('<input type="hidden" name="p_nls_territory" value="">');
    htp.p('<input type="hidden" name="p_requested_url" value="portal30_sso.draw_custom_login_page">');
         htp.p('<select name=p_nls_language value="null" onChange="javascript:fn_cbs_lang_submit(p_nls_language)">');
         htp.p('<option selected>'||var_listlangcaption||'</option>');
         htp.p('<option value="us">'||var_optioneng||'</option>');
         htp.p('<option value="e">'||var_optionspanish||'</option>');
         htp.p('<option value="f">'||var_optionfrench||'</option>');
         htp.p('</select>');
         htp.p('</form>');
         htp.p('</TD> ');
         htp.p('</TR></TBODY></TABLE>');
         --htp.p('<DIV align=center>');
         htp.p('<TABLE border=0 cellPadding=5 cellSpacing=6 width=100%>');
         htp.p('<TBODY>');
         htp.p('<TR>');
         htp.p('<TD border=0 width=30%> </TD>');
         htp.p('<TD width=50%><span class=large>'||var_bannertitle||'</span>');
              htp.p('<P class=bodytext>'||var_bannerinfo||'<P>');
         --htp.p('Oracle''s financial applications to leverage the power of a single');
         --htp.p('integrated database with common data standards and core processes. This');
         --htp.p('tool empowers employees at their desktops, enabling them to requisition');
         --htp.p('goods and services, as well as pay bills and personal expenses online via');
         --htp.p('a Web browser.');
         htp.p(''||var_linkname);
         htp.p('');
         htp.p('<P align=center><A');
              htp.p('href="https://p2pweb1d.nj.ssmb.com:3043/pls/p2pdb30_portal30_sso"');
              htp.p('</TD>');
         --htp.p('<TD class=bodytext height=25>  </TD>');
         htp.p('<TD width=20% valign=top align=right >');
                        htp.p('<TABLE cellpadding=5 BGCOLOR="#F2F2F2"');
                        htp.p('<TR><TD align=right>');
                        htp.p('<p class=small><b>'||var_loginuser||'</b> <input class=small type=text size=15 name=user value="">');
                        htp.p('<P class=small><b>'||var_loginpwd||'</b> <input class=small type=password size=15 name=password value="">');
                        htp.p('</TD></TR>');
                        htp.p('<TR><TD align=right>');
                        htp.p('<input class=small type=button size=15 name=cmd_login value='||var_loginbuttton||'>');
                        htp.p('</TD></TR>');
                        htp.p('</TABLE>');
              htp.p('</TD>');
         htp.p('</TR></TBODY></TABLE>');
              --htp.p('</DIV>');
              htp.p('</BODY>');
              --htp.p('</FORM>');
              htp.p('</HTML>');
              htp.p('<SCRIPT language=JavaScript>');
                             htp.p('var l_http_language = new Array()');
                             htp.p('var l_nls_territory = new Array()');
                        htp.p('l_http_language[1] = "en"');
                        htp.p('l_nls_territory[1] = "AMERICA"');
                        htp.p('l_http_language[2] = "fr"');
                        htp.p('l_nls_territory[2] = "FRANCE"');
                        htp.p('l_http_language[3] = "de"');
                        htp.p('l_nls_territory[3] = "GERMANY"');
                        htp.p('l_http_language[4] = "ja"');
                        htp.p('l_nls_territory[4] = "JAPAN"');
                        htp.p('l_http_language[5] = "es"');
                        htp.p('l_nls_territory[5] = "SPANISH"');
                                                 htp.p('function fn_cbs_lang_submit(field){');
                                                                --htp.p('alert (document.cbs_language_select.p_http_language.value)');
                                                      htp.p('if ( field.selectedIndex != 0 )');
                                                      htp.p('{');
                                                      htp.p('document.cbs_language_select.p_http_language.value = l_http_language[field.selectedIndex]');
                                                                htp.p('document.cbs_language_select.p_nls_territory.value = l_nls_territory[field.selectedIndex]');
                                                      htp.p('document.cbs_language_select.submit();');
                                                      htp.p('}');
                                                                                              htp.p('}');
              htp.p('</SCRIPT>');
              exception when others then
              htp.p(l_language);
              htp.p(SQLCODE);
              htp.p(SQLERRM);
    END;

  • Write a program to terminate the infinite loop when i enter any key

    Hi ,please tell me the program to terminate the infinite loop when i enter any key in the keyboard

    DarrylBurke wrote:
    mreddy, it's good to see the aliens returned you to Earth, even if it took them 2 years 4 monthslol ...
    to the OP ... you cannot do it ... unless ... you envoke swings or awt and add keylisteners . the only other way to accomplish this is using 3rd party libraries , like Jcurses ...
    [http://javacurses.sourceforge.net/]
    more specifically you can use jcurses.system.InputChar class to do what you want ...
    another way to do it is my making your console(terminal) communicate with your program for every character that you press.
    on linux you can use the stty command.
    stty -icanon

  • Infinite loop when trying to purchase a subscription in the sandbox environment

    We have set up a newsstand app with subscription functionality. We are testing the subscription functionality by using test users that have been set up in itunesconnect. When testing, we find that we get into an infinite loop when trying to subscribe to a magazine. After getting the pop-up to validate payment information, we are directed to the app store with a grey box, that looks like it should contain purchase information, but the page keeps reloading and we never get the option to enter this info. Finally a message appears that says the this is a test environment. I have included some screenshots below. Any thoughts?

    I was able to unzip the file "Adobe Creative Suite 6 Design & Web Premium MAC.zip" using stuffit expander, free from www.stuffit.com.  I am not sure why the expander native in Mac OSX v 10.9 ("Archive Utility.app") wasn't able to do this (I tried repeatedly for 2 days).  But stuffit expander worked fine and now the software is running...

  • I run into an infinite loop when I try and use this print method

    Hi,
    I have the following class. If i run it in stand alone, everything works out great. However, if I call it from a much larger application (which is why I have built this class), I run into an infinite loop. I have no idea why, but I have pinpointed it to the line: tableView.getTableHeader().paint(g2);
    Any help is greatly appreciated. I have been tryin to figure this out for a week now, and I havent gotten anywhere. It makes no sense to me, since this works as a standalone application, but if i put a method similar to the main() inside a much larger application, I end up with an inifinite loop.
    Thanks again!
    import javax.swing.table.AbstractTableModel;
    import javax.swing.*;
    import java.awt.print.*;
    import java.awt.*;
    import java.util.Iterator;
    import java.util.ArrayList;
    public class printTableTest implements Printable, Pageable {
         private PageFormat pf;
         private String[] headers = { "Heading 1", "Heading 2", "Heading 3"};
         private ArrayList<Object[][]> data = new ArrayList<Object[][]>();
         public printTableTest(PageFormat format) {
              this.pf = format;
                                               this.setObjects();
         public int getNumberOfPages() {
            return 1;
        public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
            return pf;
         public void setObjects() {
              for(int x=0; x < 3; x++) {
                   int ndx = 0;
                   Object[][] tempData = new Object[2][3               for (; ndx < 2 ; ) {
                        tempData[ndx] = new Object[] { "col 1: " + x, "col 2: " + x, "col 3: " + x };
                        ndx++;
                   data.add(tempData);
        public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
            return this;
         public int print(Graphics g, PageFormat format, int pageIndex) throws PrinterException {
              JFrame frame = null;
              JTable tableView = null;                                                       System.err.println("here");
              Graphics2D g2 = (Graphics2D) g;
              //Object[][] data = new Object[3][3];
              g2.setColor(Color.black);
              g2.translate(format.getImageableX() + 72, format.getImageableY() + 72);
              for(int x=0; x < data.size(); x++) {
                   tableView = new JTable(new PrintTableModel(headers, data.get(x)));
                   frame = new JFrame();
                   JScrollPane scrollpane = new JScrollPane(tableView);
                   scrollpane.setPreferredSize(new Dimension(300, 80));
                   frame.getContentPane().setLayout(new BorderLayout());
                   frame.getContentPane().add(BorderLayout.CENTER,scrollpane);
                   frame.pack();
                   tableView.paint(g2);
                   g2.translate(0, - tableView.getTableHeader().getHeight());
                   tableView.getTableHeader().paint(g2);
                   g2.translate(0, format.getImageableHeight()/3);
              return Printable.PAGE_EXISTS;
         public static void main(String args[]) {
             PrinterJob printerJob = PrinterJob.getPrinterJob();
              printTableTest pp = new printTableTest( printerJob.defaultPage());
              printerJob.setPageable(pp);
              boolean doPrint = printerJob.printDialog();
              if (doPrint) {
                   try {
                        printerJob.print();
                   } catch (PrinterException exception) {
                        System.err.println("Printing error: " + exception);
             System.exit(0);
         private class PrintTableModel extends AbstractTableModel {
              private Object[][] data = null;
              private String[] headers = null;
              public PrintTableModel(String[] headers, Object[][] data) {
                   this.headers = headers;
                   this.data = data;
              public int getColumnCount() { return headers.length; }
              public int getRowCount() { return data.length; }
              public Object getValueAt(int row, int col) { return data[row][col]; }
              public String getColumnName(int column) { return headers[column]; }
              public Class getColumnClass(int col) { return getValueAt(0,col).getClass(); }
              public boolean isCellEditable(int row, int col) { return false; }
              public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; }
    }

    Log the parameters passed to my print method?
    The only parameter that would be relevant would be the pageNumber, and I can tell you that it continues to loop. Here is an example of the output:
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    Page: 0
    and here is the Thread Trace:
    AWT-EventQueue-0@42f prio=6, in group "main", status: WAIT
           wait():-1, Object.java
           wait():474, Object.java
           getNextEvent():345, EventQueue.java
           pumpOneEventForHierarchy():189, EventDispatchThread.java
           pumpEventsForHierarchy():163, EventDispatchThread.java
           pumpEvents():157, EventDispatchThread.java
           pumpEvents():149, EventDispatchThread.java
           run():110, EventDispatchThread.java
    AWT-Shutdown@430 prio=5, in group "main", status: WAIT
           wait():-1, Object.java
           wait():474, Object.java
           run():259, AWTAutoShutdown.java
           run():595, Thread.java
    Java2D Disposer@2a0 daemon prio=10, in group "main", status: WAIT
           wait():-1, Object.java
           remove():116, ReferenceQueue.java
           remove():132, ReferenceQueue.java
           run():107, Disposer.java
           run():595, Thread.java
    AWT-Windows@fc daemon prio=6, in group "main", status: RUNNING
           eventLoop():-1, WToolkit.java
           run():269, WToolkit.java
           run():595, Thread.java
    Signal Dispatcher@2a2 daemon prio=10, in group "system", status: RUNNING
    Finalizer@2a3 daemon prio=8, in group "system", status: WAIT
           wait():-1, Object.java
           remove():116, ReferenceQueue.java
           remove():132, ReferenceQueue.java
           run():159, Finalizer.java
    Reference Handler@2a4 daemon prio=10, in group "system", status: WAIT
           wait():-1, Object.java
           wait():474, Object.java
           run():116, Reference.java
    main@1 prio=5, in group "main", status: RUNNING
           print():68, printTableTest.java
           redrawRegion():906, WPathGraphics.java
           printPage():1817, RasterPrinterJob.java
           print():1334, RasterPrinterJob.java
           print():1196, RasterPrinterJob.java
           main():1922, TOLMainFrame.java

  • How to exit infinite loop when using gotopage( )

    I have 10 Pages in one script. At page 9, I want to call page 2 , page 3 and page4
    The method is : RSWApp.GotoPage (2)
    At page 9 it will run infinite loop page2-page4, How can I stop this loop at Page4
    Thanks
    Julia

    Hi, I have a question follow up on this.
    For example:
    I have 5 pages:
    Page 1
    Page 2
    Page 3
    Page 4
    Page 5
    In Page 1, I have an VBA that look like this:
    if something then GoToPage 2
    if otherthing then GoToPage 4.
    But I only want when the page get to Page 3, then this iteration is finished and don't want to keep going to Page 4 and Page 5.
    How do I stop it or restart another iteration, start all over from Page 1?
    I have tried "RSWApp.StopIteration", look up some end, exit, etc, doesn't seems work.
    Thanks

  • InDesign infinite loop when exporting INDD as IDML - one specific document

    Hi,
    I have several thousand INDD files that are generated using CS4. We are migrating to CC server so need to be able to run scripts against these files. One of the scripts performs some (simple) manipulations and then saves as IDML...
    Except...
    With a percentage of our files (I've found two out of less than a hundred files that I've tested) the export to IDML task never completes. InDesign server simply hangs, permenantly. The only way to get our server back is to manually terminate the process using Task Manager and then restart. I have looked at the INDD files using InDesign client and can see nothing whatsoever the matter with them. However, even in client, even after deleting _ALL_ content, when I try to save as IDML, I get the export process hanging (see screenshot below).
    So, I guess I have two questions;
    1. How can I modify InDesign server to detect and recover from this form of infinite loop?
    2. Does anybody have any idea what could be causing the infinite loop? (And how to resolve it?)
    Thanks,
    Gaius

    You should try a divide and conquer for the InDesign file.
    That is split it in two and then try export to IDML
    Whichever sides hangs is where the problem lies. You can keep halving this document until you find the problematic page/pages.

  • Infinite loop when trying to unzip Adobe CS6 downloaded from "Arvato"

    The downloaded CS6 file "Download_Package.zip" does not open into a functional file (I tried this with Safari and with Chrome with the same results, all cookies enabled).
    Here's what I did:
    1.  Buy Adobe CS6 "design and web premium" academic version from my university bookstore, they gave me an Adobe card with a number on it.
    2. Go to the website indicated on the card, entered product code on the back of the card
    3.  Received email from [email protected] a few seconds later, with instructions, which includes the 36 digit "Redemption Code"
    4. As instructed in the email message, went to http://www.adobe.com/go/getserial.  This bounces me to the website https://redeem.licenses.adobe.com/getserial/#
    5. Inserted Adobe ID and Password where requested.
    6.  Entered the redemption code, Made a note of the displayed serial number
    7.  Pressed the "Download" button.
    8.  The downloaded CS6 file "Download_Package.zip" showed up in my download folder.  It automatically unziped itself to a file called "Download_Package.app" with an icon that reads "Arvato Bertelsmann"
    9.  Clicked on the "Arvato Bertelsmann" icon and it opened a window.  Pressed the button "start" and it downloads a 4.53 GB file into a folder called "Package" that contains the  archive file called "Adobe Creative Suite 6 Design & Web Premium MAC.zip".
    10.  When I double click on this file, it creates a new file called "Adobe Creative Suite 6 Design & Web Premium MAC.zip.cpgz"
    11.  Then when I double click on this file, it just archives itself into a new .zip file.  This then becomes an infinite loop.

    I was able to unzip the file "Adobe Creative Suite 6 Design & Web Premium MAC.zip" using stuffit expander, free from www.stuffit.com.  I am not sure why the expander native in Mac OSX v 10.9 ("Archive Utility.app") wasn't able to do this (I tried repeatedly for 2 days).  But stuffit expander worked fine and now the software is running...

  • Applescript quit infinite looping when restart/logout/shutdown

    recently I have a infinite looping applescript, and I save the is script as a "app", and running it on my macbook.
    my problem was when every time I want to restart the OS, it keep saying my app can't be quit, and I have to force quit.
    Anyway to write the script auto detect the shutdown/logout and restart, so there I can use the "quit" handle.
    on quit
      continue quit
    end quit
    repeat
    end repeat

    There exists, however, a very inelegant solution: using two stay-open apps at the same time, as follows:
    App_1
    global flag
    set flag to false
    on quit
          set flag to true
    end quit
    repeat
          if flag then exit repeat
    end repeat
    continue quit
    App_2
    on quit
          try
                tell application "System Events"
                      set frontmost of process "App_1" to true
                      delay 1
                      keystroke "q" using {command down}
                end tell
                delay 1
          end try
          continue quit
    end quit
    I'm sure though someone else will find a very simple and elegant solution. 

  • Is Replica aware stubs are in infinite loop when fail over????

              Hi
              Any help on this Appreciated
              See in this senario, where there is four weblogic instance runs in the cluster
              and a replica aware stub(stateless bean with idempodent methods) finds a particular
              method fails on a server and it redircets the request to another one server but the
              same method fails on all the server, then what is goin to happen?? is it going to
              throw some exception or gonna be in a loop to keep on redirecting the method request
              to all servers in Round???
              Regards
              Aruna
              

              Aruna,
              A stateless session bean whose methods have been declared idempotent will automatically
              retry on another service provider in a fail-over situation. When a fail-over situation
              occurs, the stub refreshes its list of service providers. Note: Just because your
              method call fails, doesn't mean it's a fail-over situation.
              Jane
              "Aruna" <[email protected]> wrote:
              >
              >Hi
              >
              > Any help on this Appreciated
              >
              > See in this senario, where there is four weblogic instance runs in
              >the cluster
              >and a replica aware stub(stateless bean with idempodent methods) finds a
              >particular
              >method fails on a server and it redircets the request to another one server
              >but the
              >same method fails on all the server, then what is goin to happen?? is it
              >going to
              >throw some exception or gonna be in a loop to keep on redirecting the method
              >request
              >to all servers in Round???
              >
              >
              >Regards
              >Aruna
              

  • My Mac Mini is in an infinite loop when I try to turn it on, it gets stuck on the Apple screen

    I was using my Mac Mini when my Mac wouldn't let me scrow down or up in Safari, when I tried to restart, the computer hasn't called, got stuck on the Apple screen, I tried to put it in the safe mode, didn't work, the same think happened, it got stuck on the Apple screen for hours

    Start:
    Mac OS X: Gray screen appears during startup

  • Itunes terms and condition infinite loop when trying to purchase

    i notice this is a common problem but nowhere can i see an answer?

    I was able to unzip the file "Adobe Creative Suite 6 Design & Web Premium MAC.zip" using stuffit expander, free from www.stuffit.com.  I am not sure why the expander native in Mac OSX v 10.9 ("Archive Utility.app") wasn't able to do this (I tried repeatedly for 2 days).  But stuffit expander worked fine and now the software is running...

  • ActionEvent/Setting gui text in an infinite loop

    Hi,
    I have set up a gui that contains ~ 100 JTextFields and one JTextButton
    Pressing the JTextButton on the gui triggers an action event that
    1.     establishes a socket connection w/ a server
    2.     reads input from the server in an infinite loop
    3.     should use the server data to dynamically setText in the various JTextFields found on the gui.
    for example, during one iteration of the infinite loop, the data may set the text of JTextField #1 to ?foo? and in a later iteration of the loop, the new data from the input stream may set the text of the same field to something else (e.g. ?bar?). Thus, the gui should show a dynamically changing collection of TextFields after the user presses the JTextButton.
    Problem: because of the infinite loop, NONE of the fields is ever updated (see pseudocode below). If I remove the infinite loop and simply have 1 iteration of the block of code within the actionPerformed method, the gui updates properly.
    How might I alter the code to a) maintain the server connection, b) continuously read from the input stream and c) have a dynamic update of the textfields w/in the gui?
    I've tried adding "this.paint(this.getGraphics());" within the infinite loop and it sort of works, but the updates to the gui are FAR SLOWER than the data that are streaming in from the server.
    Thanks for any help!
    The code looks something like this
    Public class abc extends JFrame
    Public abc()
         {initialize components}
    instantiate all textfields & button
    create various arrays
    public void initialize components
         (set up gui using gridbaglayout
         add actionListener to button)
    private actionperformed
    (establish socket connection w/ server
         read data from server in an infinite loop
         parse data and use information to setText on the gui)
    public static void main(blah blah)
         show abc();

    have the reading loop in a different class which will have its own Thread running aside from the main program's thread. This way your application will do both at once :)

  • Notebook caught in infinite loop, then gives a Hard Drive Short DST check error in Bios

    My laptop shut off unexpectedly last week. It got caught in an infinite loop when trying to restart. I was able to access bios and run a system check. I received Failure ID Q0821A-7017lt-xd7wwk-60xx03. I cannot get the computer to start. Please advise.

    1. This is a hardware issue and the Hard Drive is faulty
    2. You cannot recover this failure ID unless you replace the Hard drive
    Detailed Explanation:
    Whenever you get a message stating that the Short DST Check error with 24 Digit Failure ID "Q0821A-7017LT-XD7WWK-60XX03" that indicates that the Hard Disk Drive requires a replacement to resolve the issue
    Could be due to Application or driver conflicts, virus issues, file corruptions due to incompatible applications, improper shutdowns, update failures due to conflicts, sudden power surges, if notebook is dropped etc..
    HP will provide a replacement Hard Disk Drive if the Notebook warranty is Active, If not you need buy a SATA Hard Disk Drive from a retail shop nearby
    Please make sure you are getting at least equal capacity as the original one in order to use Recovery Disks. If you need you can buy a larger, but not smaller capacity Hard Disk Drive. For example if you have a 500GB Hard Disk Drive you can upgrade it to 750GB Hard Disk Drive but not 320GB Hard Disk Drive
    Please try the below shown troubleshooting steps once:
    Step 01. Remove the battery and unplug the AC/Power Adapter
    Step 02. Press and hold the Power button for more than 30 Seconds
    Step 03. Plug in the AC/Power Adapter (leave the Battery out for now)
    Step 04. Press the Power button and check if the Unit works normal
    If the above mentioned steps does not help, then you can try reseating the Hard Drive on your Notebook
    If the issue persists again please Contact HP if your HP Notebook is under warranty, HP would replace the Hard Disk Drive and provide you a Recovery media to restore factory operating system after replacement (if you've not yet created Recovery Discs/USB Media)
    Note: Back up all the personal data to an external drive if it's possible. Otherwise you could connect the failed HDD via SATA to USB adapter with another PC or same PC after replacement of HDD & re-installation of OS and try copying /recovering the files.
    Please click on the link In order to Identify, Prevent, Diagnose & Recover from Drive Failures on HP Notebook Hard Drives & Solid State Drives :
    http://h10032.www1.hp.com/ctg/Manual/c02876562.pdf
    Please check your notebook warranty to verify the status and order a new Hard Disk Drive
    Hope this helps, for any further queries reply to the post and feel free to join us again
    **Click the KUDOS star on left to say Thanks**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.
    Thank You,
    K N R K
    Although I am an HP employee, I am speaking for myself and not for HP

  • Multiple paint methods

    Hi
    I'm working on a draughts game and to make it a little nicer looking I've used graphics for the board squares.
    My paint method is double buffered so when a peice is dragged it lags a little because it has to buffer so many images. The only images I need to buffer are the ones that move i.e. the draughts.
    Is there a way to draw the squares in a separate paint method so they don't get buffered? Or is java limited to one paint method per class?

    It's going to lag no matter how many paint methods you use. (Thats even if there ARE other paint methods) If it's lagging because of how many images must be drawn, then perhaps you should write an algorithm that repaints only the areas that have changed. ie: Only repaint wherever the single peice is moved.
    -Adam

Maybe you are looking for