Repaint/Refreshing AWT components

Hi there,
I'm writing a chess game and for the GUI I've added 8x8 panels into a frame with a grid layout. Currently I'm just using labels for the pieces, in the middle of panels. I'm having a problem updating my GUI after a move has been made - a call to repaint() does nothing. I'm just using basic AWT.
I've also tried removeAllComponents() of the frame and adding them again with the updated data, but nothing happens - I just lose all my panels. Can anyone help please?
Many thanks!

scsi-boy :
I want to have a more general method of refreshing the
graphics so that later if/when I 'upgrade' to using
images (or whatever) instead of labels I can simplyi believe my suggestion is certainly compatible with that.
adapt it. I would think that calling setText for the
Labels would mean that I would have to give the
location of the panel as a parameter somewhere, and
would also have to remove the label where the piece
was previously (ie if a knight moves, I'd have to
target its destination to setText and remove it from
where it was).here is what i would do, please note that this will work with a variety
of implementations including using all Graphics later on or whatever.
// here we have a bunch of constants that represent the possible status
// of board postions
final int EMPTY_SPACE = 0;
final int B_KING = 1;
final int W_KING = 2;
final int B_QUEEN = 3;
final int W_QUEEN = 5;
final int B_BISHOP = 6;
final int W_BISHOP = 7;
final int B_KNIGHT = 8;
final int W_KNIGHT = 9;
final int B_ROOK = 10;
final int W_ROOK = 11;
final int B_PAWN = 12;
final int W_PAWN = 13;
// the game board is used to store the status of all the postitions in
// a game
int[][] gameBoard;
// the game display is the array of Labels that we use to present the
// board in our GUI
Label[][] gameDisplay;
// in the constructor;
gameBoard = new int[8][8];
for(int i=0;i<gameBoard.length;i++){
  for(int j=0;i<8;j++){
    gameBoard[i][j] = EMPTY_SPACE;
// here is where you would add the various pieces to gameBoard...
gameDisplay = new Label[8][8];
  Now wherever you interaction and logic are you can use a method. You
  can call this method repaint(); so that it will be compatible with
  what you do later.
public void repaint(){
  for(int i=0;i<gameBoard.length;i++){
    for(int j=0;j<8;j++){
      switch(gameBoard[i][j]){
        case B_KING:
          gameDisplayj].setText("Black King");
break;
case W_KING:
gameDisplay[i]j].setText("White King");
break;
case B_QUEEN:
gameDisplay[i]j].setText("Black Queen");
break;
// and so on and so forth... until
default:
gameDisplay[i]j].setText("");
anyway the above code is just a sample of how you can build this so you
can seperate out your logic from your GUI so you can change your GUI
later without hassle.
finally i would ask how are you changing the text on the screen. are you
creating new Labels and sticking them in the Panels? i suspect something
like this... don't do that. two reasons, one as you may have noticed it
doesn't work that way or you have to use some sort of hack to get it to
work and two it's more efficient in terms of memory and speed if you
re-use the awt ot Swing components by making use of methods such as
setText rather than creating new objects each time.
i hope you find this helpful.

Similar Messages

  • Unable to refresh EJB components

    I am using Java Studio Creator update 1.
    I have been using EJB components in one project, and that has been working fine for the past few months. Since last week, after dowloading the latest creator update from the update center, I am not able to refresh EJB components. This is the latest update posted at end of september 2006. This had four modules, i.e. com-sun-rave-insync.nbm, openide.nbm, org-netbeans-modules-beans.nbm and ravehelp.nbm.
    I dont know whether this issue is related to the update.
    The problem has been observed on two separate systems, each having this update.
    The EJB are created using Java Studio Enterprise 8.
    Please help.
    The Java Studio Creator log is:
    Log Session: Wednesday, October 4, 2006 9:27:16 AM GMT+03:00
    System Info: Product Version = Java Studio Creator 2 Update 1 (Build 060915)
    Operating System = Windows 2000 version 5.0 running on x86
    Java; VM; Vendor = 1.5.0_06; Java HotSpot(TM) Client VM 1.5.0_06-b05; Sun Microsystems Inc.
    Java Home = C:\Program Files\Sun\Creator2_1\java\jre
    System Locale; Encod. = en_US (rave); Cp1252
    Home Dir; Current Dir = C:\Documents and Settings\collins; C:\Program Files\Sun\Creator2_1\bin
    IDE Install; User Dir = C:\Program Files\Sun\Creator2_1\platform5; C:\Documents and Settings\collins\.Creator\2_1
    CLASSPATH = C:\Program Files\Sun\Creator2_1\platform5\lib\boot.jar;C:\Program Files\Sun\Creator2_1\platform5\lib\locale\boot_es.jar;C:\Program Files\Sun\Creator2_1\platform5\lib\locale\boot_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\lib\locale\boot_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\lib\locale\boot_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\lib\locale\boot_zh_CN.jar;C:\Program Files\Sun\Creator2_1\java\lib\dt.jar;C:\Program Files\Sun\Creator2_1\java\lib\tools.jar
    Boot & ext classpath = C:\Program Files\Sun\Creator2_1\patches\6311051.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\rt.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\i18n.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\sunrsasign.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\jsse.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\jce.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\charsets.jar;C:\Program Files\Sun\Creator2_1\java\jre\classes;C:\Program Files\Sun\Creator2_1\java\jre\lib\ext\dnsns.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\ext\localedata.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Sun\Creator2_1\java\jre\lib\ext\sunpkcs11.jar
    Dynamic classpath = C:\Program Files\Sun\Creator2_1\platform5\core\core.jar;C:\Program Files\Sun\Creator2_1\platform5\core\openide-loaders.jar;C:\Program Files\Sun\Creator2_1\platform5\core\openide.jar;C:\Program Files\Sun\Creator2_1\platform5\core\org-netbeans-swing-plaf.jar;C:\Program Files\Sun\Creator2_1\platform5\core\updater.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\core_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\core_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\core_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\core_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\core_zh_CN.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide-loaders_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide-loaders_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide-loaders_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide-loaders_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide-loaders_zh_CN.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\openide_zh_CN.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\org-netbeans-swing-plaf_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\org-netbeans-swing-plaf_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\org-netbeans-swing-plaf_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\org-netbeans-swing-plaf_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\org-netbeans-swing-plaf_zh_CN.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave_es.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave_fr.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave_ja.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave_ko.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_rave_zh_CN.jar;C:\Program Files\Sun\Creator2_1\platform5\core\locale\updater_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\com-sun-rave-extension-ide-launcher-upgrade.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\derbyclient.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\jgraph.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\naming.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\rowset.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smbase.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smdb2.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\sminformix.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smoracle.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smresource.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smspy.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smsqlserver.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smsybase.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\smutil.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\sql.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\sqlx.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\com-sun-rave-extension-ide-launcher-upgrade_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\com-sun-rave-extension-ide-launcher-upgrade_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\com-sun-rave-extension-ide-launcher-upgrade_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\com-sun-rave-extension-ide-launcher-upgrade_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\com-sun-rave-extension-ide-launcher-upgrade_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\core_rave_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\naming_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\naming_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\naming_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\naming_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\naming_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide-loaders_rave.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\openide_rave_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sqlx_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sqlx_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sqlx_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sqlx_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sqlx_zh_CN.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sql_es.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sql_fr.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sql_ja.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sql_ko.jar;C:\Program Files\Sun\Creator2_1\rave2.0\core\locale\sql_zh_CN.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\org-netbeans-upgrader.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\locale\org-netbeans-upgrader_es.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\locale\org-netbeans-upgrader_fr.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\locale\org-netbeans-upgrader_ja.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\locale\org-netbeans-upgrader_ko.jar;C:\Program Files\Sun\Creator2_1\nb4.1\core\locale\org-netbeans-upgrader_zh_CN.jar;C:\Program Files\Sun\Creator2_1\ide5\core\org-netbeans-modules-utilities-cli.jar
    [org.netbeans.core.modules #4] Warning: module com.sun.rave.libs.jsf does not declare OpenIDE-Module-Public-Packages in its manifest, so all packages are considered public by default: http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/doc-files/upgrade.html#3.4-public-packages
    You are trying to access file: jndi.properties from the default package.
    Please see http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/doc-files/classpath.html#default_package
    Turning on modules:
    org.openide/1 [5.9.1.4 060915]
    org.openide.loaders [5.2.1.1 060417]
    org.openide.io [1.6.1 060417]
    org.openide.execution [1.5.1 060417]
    org.netbeans.core.output2/1 [1.3.1 060417]
    org.netbeans.bootstrap/1 [1.0.1 060417]
    org.netbeans.swing.plaf [1.2.1 060417]
    org.netbeans.core/1 [1.27.1 060417]
    org.netbeans.core.execution/1 [1.6.1 060417]
    org.apache.tools.ant.module/3 [3.17.1 060417]
    org.netbeans.modules.settings/1 [1.7.1 060417]
    org.netbeans.swing.tabcontrol [1.3.1 060417]
    org.netbeans.core.windows/2 [2.4.1 060417]
    org.netbeans.core.ui/1 [1.6.1 060417]
    org.netbeans.core.ide/1 [1.6.1 060417]
    com.sun.rave.extension.core.ide/1 [1.0 060417]
    org.netbeans.modules.queries/1 [1.4.1 060417]
    org.netbeans.modules.projectapi/1 [1.3.1 060417]
    org.openidex.util/3 [3.6.1 060417]
    org.netbeans.api.xml/1 [1.8 3.999.4 060417]
    org.netbeans.modules.xml.core/2 [1.7 3.999.4 060417]
    org.netbeans.modules.xml.catalog/2 [1.6 3.999.4 060417]
    org.netbeans.modules.masterfs/1 [1.4.1.1 060417]
    org.netbeans.modules.projectuiapi/1 [1.5.4.0.0 4.0.0 060417]
    org.netbeans.modules.projectui [1.3.4.0.0.1 060417]
    com.sun.rave.branding.projects.projectui/1 [1.0 060417]
    javax.jmi.reflect/1 [1.4.1 060417]
    javax.jmi.model/1 [1.4.1 060417]
    org.netbeans.api.mdr/1 [1.1.1 060417]
    org.netbeans.jmi.javamodel/1 [1.13.1 060417]
    org.netbeans.api.java/1 [1.7.1 060417]
    org.netbeans.modules.java.platform/1 [1.3.1 060417]
    org.netbeans.modules.project.ant/1 [1.6.2 060823]
    org.openide.src [1.5.1 060417]
    org.netbeans.modules.jmiutils/1 [1.1.1 release41 060417]
    org.netbeans.modules.mdr/1 [1.1.1 release41 060417]
    org.netbeans.modules.classfile/1 [1.14.1 060417]
    org.netbeans.modules.javacore/1 [1.5.1 060417]
    org.netbeans.modules.java/1 [1.20.1.1 1.0.0 060417]
    org.netbeans.modules.project.libraries/1 [1.10.1 060417]
    org.netbeans.modules.java.project/1 [1.3.1 060417]
    org.netbeans.modules.beans/1 [1.14.2 060915]
    com.sun.rave.extension.beans/1 [1.0 060417]
    org.netbeans.modules.ant.browsetask [1.8.1 060417]
    org.netbeans.spi.viewmodel/2 [1.4.1 060417]
    org.netbeans.api.debugger/1 [1.3.1 060417]
    org.netbeans.api.debugger.jpda/1 [1.3.1 060417]
    org.netbeans.modules.j2eeapis/1 [1.3.1 060417]
    org.netbeans.modules.schema2beans/1 [1.11.1 060417]
    org.netbeans.libs.j2eeeditor/1 [1.4.1 060417]
    org.netbeans.modules.j2eeserver/3 [1.6.1 060417]
    com.sun.rave.api.portlet.dd/1 [1.0 1.0]
    com.sun.rave.api.jsf.project/1 [1.3 060612]
    org.netbeans.api.web.webmodule [1.2.1 060417]
    org.netbeans.libs.commons_logging/1 [1.0.1 1.0.4 060417]
    org.netbeans.modules.servletapi24/1 [2.3.1 2.3.1 060417]
    org.netbeans.libs.xerces/1 [1.5.1 2.6.2]
    org.netbeans.modules.web.jspparser/2 [2.2.3 060823]
    org.netbeans.core.multiview/1 [1.5.1 060417]
    org.netbeans.modules.xml.multiview/1 [1.0 1.0-release41 060417]
    org.netbeans.modules.editor.util/1 [1.4.1 060417]
    org.netbeans.modules.editor.fold/1 [1.2.1 060417]
    org.netbeans.modules.editor.lib/1 [1.3.1 0.1 060417]
    org.netbeans.modules.editor.plain.lib/1 [1.0.1 060417]
    org.netbeans.modules.editor/3 [1.19.1 060417]
    org.netbeans.modules.editor.plain/1 [1.0.1 060417]
    org.netbeans.modules.xml.text/2 [1.7 3.999.4 060417]
    org.netbeans.modules.html.editor.lib/1 [1.0.1 060417]
    org.netbeans.modules.html.editor/1 [1.0.1 060417]
    org.netbeans.modules.java.editor.lib/1 [1.0.1 060417]
    org.netbeans.modules.java.editor/1 [1.0.1 060417]
    org.netbeans.modules.html/1 [1.15.1 060417]
    org.netbeans.modules.web.core.syntax/1 [1.17.1.1 060417]
    org.netbeans.modules.j2ee.dd/1 [1.3.1 1.0 060417]
    org.netbeans.modules.web.core/1 [1.20.1 release41 060417]
    com.sun.rave.modules.jsf.examples.postrelease/1 [1.0 060424]
    org.netbeans.modules.javahelp/1 [2.5.1 060417]
    org.netbeans.tasklistapi/1 [1.16.6 6 060417]
    org.netbeans.modules.tasklist.core/2 [1.33.615 15 060417]
    org.netbeans.modules.suggestions_framework/2 [1.11.6158 8 060417]
    org.netbeans.modules.j2ee.ant [1.3.1 060417]
    org.netbeans.modules.debugger.jpda/2 [1.13.1.0.0.1 060417]
    org.netbeans.spi.debugger.ui/1 [2.5.1 060417]
    org.netbeans.modules.debugger.jpda.ui/1 [1.2.1.0.0.1 060417]
    com.sun.rave.extension.core.execution/1 [1.0 060417]
    com.sun.rave.extension.html/1 [1.0 060417]
    com.sun.rave.portlet.container/1 [1.0 1.0]
    com.sun.rave.portlet.container.ant/1 [1.0 1.0]
    com.sun.rave.designtime/1 [1.0.2 060823]
    com.sun.rave.api.designer/1 [1.0 060417]
    org.netbeans.modules.tasklist.docscan/2 [1.19.61584 4 060417]
    com.sun.rave.extension.openide/1 [1.0 060417]
    com.sun.rave.extension.java/1 [1.0 060417]
    org.netbeans.modules.j2ee.dd.webservice [1.0.1 060417]
    org.netbeans.modules.websvc.websvcapi [1.0.1 060417]
    org.netbeans.modules.j2ee.api.ejbmodule [1.0.1 060417]
    org.netbeans.modules.junit/2 [2.14.1 060417]
    org.netbeans.modules.j2ee.common/1 [1.0.1 1.0.1 060417]
    org.netbeans.modules.servletapi23/1 [1.7.1 060417]
    org.netbeans.modules.web.project [1.4.3 1.1.1.1 060417]
    com.sun.rave.extension.web.project/1 [1.0 060417]
    com.sun.rave.extension.java.platform/1 [1.0 060417]
    org.netbeans.modules.properties/1 [1.14.1.1 060417]
    org.netbeans.modules.diff/1 [1.10.1 promotionE 060417]
    org.netbeans.modules.vcscore/1 [1.14.1 promotionE 060417]
    org.netbeans.modules.vcs.advanced/1 [1.12.1 060417]
    com.sun.rave.extension.vcsgeneric/1 [1.0 060417]
    org.netbeans.modules.properties.syntax/1 [1.14.1 060417]
    com.sun.rave.branding.tasklist.docscan/1 [1.0 060417]
    com.sun.rave.designer.markup/1 [1.0 060417]
    com.sun.rave.jsfsupport/1 [1.0.5.2 060823]
    com.sun.rave.api.insync/1 [1.0 060417]
    org.apache.batik/1 [1.5.2 1.5]
    com.sun.rave.css/1 [1.0 060417]
    org.netbeans.modules.refactoring/1 [1.1.1 1.0 060417]
    com.sun.rave.insync/1 [1.0.7.3 060915]
    com.sun.rave.navigation/1 [1.0.5 060417]
    com.sun.rave.extension.api.xml/1 [1.0 060417]
    com.sun.rave.branding.web.jspsyntax/1 [1.0 060417]
    com.sun.rave.webui.samples.ajax/1 [0.3 060503_2]
    com.sun.rave.branding.xml.catalog/1 [1.0 060417]
    com.sun.rave.dataprovider.runtime/1 [1.0 060417]
    com.sun.rave.extension.core/1 [1.0 060417]
    com.sun.rave.extension.core.ui/1 [1.0 060417]
    com.sun.rave.ejbsupport/1 [1.0 060417]
    com.sun.rave.corepackage/1 [1.1 060417]
    com.sun.rave.branding.core.windows/1 [1.0.1 060417]
    com.sun.rave.extension.debuggercore/1 [1.0 060417]
    com.sun.rave.jsfcl/1 [1.1.3 060823]
    org.netbeans.modules.servletapi/1 [1.6.1 060417]
    org.netbeans.modules.httpserver/2 [2.1.1 release41 060417]
    org.netbeans.modules.web.monitor/1 [1.12.1 060417]
    com.sun.rave.extension.refactoring/1 [1.0 060417]
    com.sun.rave.jsfmetadata/1 [1.0.5 060417]
    com.sun.rave.welcome/1 [1.0.1 060417]
    com.sun.rave.libs.jsf/1 [1.0.5 060417]
    com.sun.rave.branding.openide.loaders/1 [1.0 060417]
    com.sun.rave.branding.editor/1 [1.0 060417]
    com.sun.rave.errorhandler.server/1 [0.2 060417]
    org.netbeans.modules.navigator/2 [4.1.1 promoe 060417]
    com.sun.rave.jwsdpsupport/1 [1.1 060417]
    com.sun.rave.toolbox/1 [1.0.5 060417]
    com.sun.rave.websvc/1 [1.0.6.2 060823]
    com.sun.rave.extension.tasklist.docscan/1 [1.0 060417]
    org.netbeans.modules.debugger.jpda.ant [1.4.1 060417]
    org.netbeans.modules.java.j2seproject [1.2.2 1.2.0 060417]
    com.sun.rave.extension.java.j2seproject/1 [1.0 060417]
    com.sun.rave.extension.java.editor/1 [1.0 060417]
    com.sun.rave.extension.core.output2/1 [1.0 060417]
    com.sun.rave.extension.xml.core/1 [1.0 060417]
    org.netbeans.modules.javadoc/1 [1.14.1 060417]
    org.netbeans.modules.utilities/1 [1.18.1 060417]
    org.netbeans.modules.utilities.project/1 [1.2.1 060417]
    com.sun.rave.extension.projects.projectui/1 [1.0 060417]
    com.sun.rave.propertyeditors/1 [1.0.2 060823]
    org.netbeans.modules.j2ee.sun.ws61/1 [1.0 060417]
    org.netbeans.modules.java.j2seplatform/1 [1.2.1 1.2.0 060417]
    com.sun.rave.extension.xml.catalog/1 [1.0 060417]
    com.sun.rave.extension.xml.text/1 [1.0 060417]
    com.sun.rave.extension.utilities/1 [1.0 060417]
    org.netbeans.modules.extbrowser/1 [1.6.1 060417]
    com.sun.rave.branding.extbrowser/1 [1.0 060417]
    com.sun.rave.extension.vcscore/1 [1.0 060417]
    org.netbeans.modules.image/1 [1.14.1.1 060417]
    com.sun.rave.branding.image/1 [1.0 060417]
    com.sun.rave.branding.java/1 [1.0 060417]
    com.sun.rave.project.jsfportlet/1 [1.0 1.0]
    com.sun.rave.project.jsfloader/1 [1.1.2 060823]
    com.sun.rave.servernav/1 [1.1 060417]
    com.sun.rave.dataconnectivity/1 [1.0.4.3 060823]
    org.netbeans.modules.web.jstl11/1 [2.3.1 2.3.1 060417]
    org.netbeans.modules.ant.freeform [1.5.1 060417]
    com.sun.rave.branding.xml.core/1 [1.0 060417]
    com.sun.rave.extension.properties/1 [1.0 060417]
    com.sun.rave.extension.core.multiview/1 [1.0 060417]
    com.sun.rave.branding.core/1 [1.0.1 060417]
    org.netbeans.modules.j2ee.sun.dd/1 [1.2 1.0]
    org.netbeans.modules.autoupdate/1 [2.12.1.2 060417]
    com.sun.rave.branding.autoupdate/1 [1.0 060417]
    org.netbeans.modules.java.freeform [1.0.1 060417]
    org.netbeans.modules.web.freeform [1.0.2 060417]
    org.netbeans.modules.j2ee.sun.ide/1 [2.1.1.1 060417]
    com.sun.rave.branding.web.project/1 [1.0 060417]
    com.sun.rave.extension.editor/1 [1.0 060417]
    com.sun.rave.branding.vcscore/1 [1.0 060417]
    com.sun.rave.branding.utilities/1 [1.0 060417]
    com.sun.rave.extension.javadoc/1 [1.0 060417]
    org.netbeans.upgrader [4.2.1 060417]
    org.netbeans.lib.cvsclient/1 [1.11.1 060417]
    com.sun.rave.portlet.container.pluto/1 [1.0 1.0]
    org.netbeans.modules.vcscore.javacorebridge/1 [1.0.1 060417]
    com.sun.rave.extension.ide.launcher.upgrade [4.1 060417]
    org.netbeans.modules.clazz/1 [1.16.1 060417]
    org.netbeans.modules.ant.grammar/1 [1.10 060417]
    com.sun.rave.designer/1 [1.0.6.2 060823]
    com.sun.rave.branding.html/1 [1.0 060417]
    com.sun.rave.modules.jsf.examples.bundled/1 [1.0.1 060417]
    com.sun.rave.extension.core.windows/1 [1.0 060417]
    com.sun.rave.branding.openidex/1 [1.0 060417]
    com.sun.rave.extension.debuggerjpda.ui/1 [1.0 060417]
    com.sun.rave.extension.utilities.project/1 [1.0 060417]
    org.netbeans.modules.vcs.profiles.vss/1 [1.6.1 060417]
    com.sun.rave.extension.core.javahelp/1 [1.0 060417]
    com.sun.rave.extension.autoupdate/1 [1.2.1.1.0 060417]
    com.sun.rave.ravehelp/1 [1.0.3.2 060915]
    com.sun.rave.project.navigationloader/1 [1.0 060417]
    org.netbeans.modules.javanavigation/1 [4.1.1 060417]
    com.sun.rave.ejb/1 [1.0.3 060823]
    com.sun.rave.branding.xml.text/1 [1.0 060417]
    com.sun.rave.branding.beans/1 [1.0 060417]
    com.sun.rave.branding.openide/1 [1.0 060417]
    com.sun.rave.extension.java.freeform/1 [1.0 060417]
    com.sun.rave.project.migration/1 [1.0 1.0]
    com.sun.rave.extension.web.core/1 [1.0 060417]
    com.sun.rave.extension.web.freeform/1 [1.0 060417]
    org.netbeans.modules.vcs.profiles.cvsprofiles/1 [1.6.1 060417]
    com.sun.rave.extension.monitor/1 [1.0 060417]
    com.sun.rave.extension.objectbrowser.navigator/1 [1.0 060417]
    [Fatal Error] :-1:-1: Premature end of file.
    INFORMATIONAL *********** Exception occurred ************ at 9:28 AM on Oct 4, 2006
    org.xml.sax.SAXParseException: Premature end of file.
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1269)
    [catch] at org.netbeans.core.xml.FileEntityResolver$DTDParser.parse(FileEntityResolver.java:388)
    at org.netbeans.core.xml.FileEntityResolver.getEnvForIDO(FileEntityResolver.java:136)
    at org.netbeans.core.xml.FileEntityResolver.getEnvironment(FileEntityResolver.java:129)
    at org.openide.loaders.Environment.findForOne(Environment.java:106)
    at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:584)
    at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:575)
    at org.openide.loaders.InstanceDataObject.getCookieFromEP(InstanceDataObject.java:540)
    at org.openide.loaders.InstanceDataObject.getCookie(InstanceDataObject.java:561)
    at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:426)
    at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:535)
    at org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:352)
    at org.netbeans.core.windows.WindowManagerImpl.getTopComponentForID(WindowManagerImpl.java:731)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponent(TopComponentSubModel.java:299)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponents(TopComponentSubModel.java:56)
    at org.netbeans.core.windows.model.DefaultModeModel.getTopComponents(DefaultModeModel.java:236)
    at org.netbeans.core.windows.model.DefaultModel.getModeTopComponents(DefaultModel.java:680)
    at org.netbeans.core.windows.Central.getModeTopComponents(Central.java:1167)
    at org.netbeans.core.windows.ModeImpl.getTopComponents(ModeImpl.java:163)
    at com.sun.rave.designer.DesignerTopComp.findCurrent(DesignerTopComp.java:624)
    at com.sun.rave.designer.DesignerServiceProvider.getCurrentDesigner(DesignerServiceProvider.java:452)
    at com.sun.rave.designer.DesignerServiceProvider.getCurrentFile(DesignerServiceProvider.java:477)
    at com.sun.rave.complib.IdeUtil.getActiveProject(IdeUtil.java:71)
    at com.sun.rave.complib.ComponentLibraryManager$1.propertyChange(ComponentLibraryManager.java:216)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
    at org.netbeans.core.windows.RegistryImpl.doFirePropertyChange(RegistryImpl.java:249)
    at org.netbeans.core.windows.RegistryImpl.access$100(RegistryImpl.java:36)
    at org.netbeans.core.windows.RegistryImpl$1.run(RegistryImpl.java:134)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    [WinSys.PersistenceManager.getTopComponentForID] Problem when deserializing TopComponent for tcID:'VCSCommandOutput'. Reason: Top component VCSCommandOutput could not be loaded, either owning module was disabled, has incompatible version or top components settings file format is broken.
    INFORMATIONAL *********** Exception occurred ************ at 9:28 AM on Oct 4, 2006
    java.io.IOException: Top component VCSCommandOutput could not be loaded, either owning module was disabled, has incompatible version or top components settings file format is broken.
    [catch] at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:442)
    at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:535)
    at org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:352)
    at org.netbeans.core.windows.WindowManagerImpl.getTopComponentForID(WindowManagerImpl.java:731)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponent(TopComponentSubModel.java:299)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponents(TopComponentSubModel.java:56)
    at org.netbeans.core.windows.model.DefaultModeModel.getTopComponents(DefaultModeModel.java:236)
    at org.netbeans.core.windows.model.DefaultModel.getModeTopComponents(DefaultModel.java:680)
    at org.netbeans.core.windows.Central.getModeTopComponents(Central.java:1167)
    at org.netbeans.core.windows.ModeImpl.getTopComponents(ModeImpl.java:163)
    at com.sun.rave.designer.DesignerTopComp.findCurrent(DesignerTopComp.java:624)
    at com.sun.rave.designer.DesignerServiceProvider.getCurrentDesigner(DesignerServiceProvider.java:452)
    at com.sun.rave.designer.DesignerServiceProvider.getCurrentFile(DesignerServiceProvider.java:477)
    at com.sun.rave.complib.IdeUtil.getActiveProject(IdeUtil.java:71)
    at com.sun.rave.complib.ComponentLibraryManager$1.propertyChange(ComponentLibraryManager.java:216)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
    at org.netbeans.core.windows.RegistryImpl.doFirePropertyChange(RegistryImpl.java:249)
    at org.netbeans.core.windows.RegistryImpl.access$100(RegistryImpl.java:36)
    at org.netbeans.core.windows.RegistryImpl$1.run(RegistryImpl.java:134)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    ==>
    java.io.IOException: Top component VCSCommandOutput could not be loaded, either owning module was disabled, has incompatible version or top components settings file format is broken.
    [catch] at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:442)
    at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:535)
    at org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:352)
    at org.netbeans.core.windows.WindowManagerImpl.getTopComponentForID(WindowManagerImpl.java:731)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponent(TopComponentSubModel.java:299)
    at org.netbeans.core.windows.model.TopComponentSubModel.getTopComponents(TopComponentSubModel.java:56)
    at org.netbeans.core.windows.model.DefaultModeModel.getTopComponents(DefaultModeModel.java:236)
    at org.netbeans.core.windows.model.DefaultModel.getModeTopComponents(DefaultModel.java:680)
    at org.netbeans.core.windows.Central.getModeTopComponents(Central.java:1167)
    at org.netbeans.core.windows.ModeImpl.getTopComponents(ModeImpl.java:163)
    at com.sun.rave.designer.Designe

    I have solved the problem. Many apologies for mentioning that this was due to creator update. It was due to thelength of command line for the javac
    See this post: http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=64191

  • Characters show up as boxes when using AWT components.

    Having installed on a Windows XP english OS the asian languages packs (with fonts included, from Microsoft) and knowing that with MS Gothic, Gulim and Simsun you can display japanese, korean and chinese characters it seems that on JRE 1.5 and up this is not possible (boxes appear instead) on any applet.
    How to reproduce:
    Label l2 = new Label("Japanese chars: \u8457\u4f5c\u6a29");
    Workaround:
    Step 1. Rename ..\jre\lib\fontconfig.properties.src to &hellip;&hellip;\fontconfig.properties
    Step 2. Modify the following line:
    sequence.allfonts=alphabetic/default,dingbats,symbol
    to
    sequence.allfonts=alphabetic/default,dingbats,symbol,japanese,chinese-ms936,chinese-ms950,korean
    How is this possible? On JRE 1.4 this was working. Also another fix is to use Swing components instead but this is not realistic for a big project.
    Any help will be greatly apprecied.

    The problem is related to the JRE v. 1.5.0_11 or greater. In JRE 1.4.2_13 for each language there was a configuration file that Java was using to determine which fonts to use for different categories of objects.
    The problem is encountered only for AWT components.
    Starting with JRE 1.5 (http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html) there is only one configuration file (fontconfig.properties.src) for all the languages. Since the character subsets supported by given fonts often overlap, in the file separate search sequence properties are used to define in which order to try the fonts when rendering a character. In the default version of the file this properties do not specify also the asian languages.
    We have to do the following things:
    *1.* You must first install into Windows the support for asian languages: Control Panel - > Regional and Language Options
    � On the Advanced tab add the conversion tables for all Asian languages (this action may not be required).
    � On the Languages tab check �Install files for East Asian Languages (this action is required)
    Restart the computer.
    *2.* Assure you have the needed asian fonts : batang(fopr korean), simsun, gulim, mingliu, msgothic(for japanese) installed.
    *3.* Rename ...\jre\lib\fontconfig.properties.src to ��\jre\lib\fontconfig.properties. By doing this the fontconfig.properties file will be used by the JRE as the default configuration file.
    *4.* Modify the following line:
    sequence.allfonts=alphabetic/default,dingbats,symbol
    to
    sequence.allfonts=alphabetic/default,dingbats,symbol,japanese,chinese-ms936,chinese-ms950,korean
    *5.* Assure that in the file the logical to physic font binding, binds to existing fonts.
    Obs: If step 1 is skipped the titles of the windows will still have boxes.
    Hope it helps.
    Donoiu Cristian

  • Best way to repaint/refresh JFrame classes.

    Hello everyone,
    I am developing a small application for my studies. I have several classes many representing a user form allowing interaction with my system.
    One of my first class instances is a Menu Screen from which the user can for example update their details. When the Update Details frame is closed by the user I invoke
    frameName.setVisible(false);
    frameName.dispose();This removes the Update Details frame and the Menu Screen is now fully visible.
    However this screen does not get refreshed and remains partially obscured by the background color of the JFrame, even if I bring say a browser to the foreground and then click the original Menu Screen to the foreground it does not refresh the Menu Screen and remains half painted.
    I was wondering about a few things.
    1. Is there a way of detecting when the current JFrame has just received the focus, at which point I could repaint the screen.
    2. Is there a way of Menu Screen discussed above being able to detect the closure of the Update Details JFrame (a separate class) and then take appropriate steps to repaint/refresh itself.
    3. Ideally what I would like to do is Hide the Menu Screen then allow the user to interact with their menu selection and then Un-hide the Meun Screen when the user is done interacting with their menu selection.
    4. Are there any tutorials on this type of thing, that anynone could direct me to.
    Thank you for your consideration.
    Cheers
    Mark

    Hello everyone,
    I am developing a small application for my studies. I
    have several classes many representing a user form
    allowing interaction with my system.
    One of my first class instances is a Menu Screen from
    which the user can for example update their details.
    When the Update Details frame is closed by the user I
    invoke
    frameName.setVisible(false);
    frameName.dispose();This removes the Update Details frame and the Menu
    Screen is now fully visible.
    However this screen does not get refreshed and remains
    partially obscured by the background color of the
    JFrame, even if I bring say a browser to the
    foreground and then click the original Menu Screen to
    the foreground it does not refresh the Menu Screen and
    remains half painted.
    I was wondering about a few things.
    1. Is there a way of detecting when the current JFrame
    has just received the focus, at which point I could
    repaint the screen.
    2. Is there a way of Menu Screen discussed above being
    able to detect the closure of the Update Details
    JFrame (a separate class) and then take appropriate
    steps to repaint/refresh itself.
    3. Ideally what I would like to do is Hide the Menu
    Screen then allow the user to interact with their menu
    selection and then Un-hide the Meun Screen when the
    user is done interacting with their menu selection.
    4. Are there any tutorials on this type of thing, that
    anynone could direct me to.
    Thank you for your consideration.
    Cheers
    Mark

  • Multilanguage support for awt components..

    hi all,
    when i tried to use .setFont() method for awt componets like labels and buttons it is displayed as rectangles insted of showing the appropriate characters. actually i tried to set the font to "simsun" (unicode font for chinese). but it works fine for swing components.
    how can we achieve that for awt without changing the font.properties file? or how can we insist to use the font.properties file supplied by us insted of default font.property file for that language?
    can we run the application by putting our font.properties file which is meant to be used for only our application, in the current working folder insted of putting in javahome\jre\lib path?
    thanks in advance..
    regards
    sojan

    Hi Sojan,
    first up, forget the notion of even tinkering with the font.properties file if you can. It's an old, outdated method of setting up the fonts that Sun doesn't even support any more. Use setFont() where you can, and die trying in the process! ;-)
    One thing I would check is which font each AWT component currently thinks it has. It's easy enough to set the font system wide with Swing components, but I'm not sure if that capability extends to AWT components (I've certainly had trouble with it in various places in the past). While you've set up the Chinese font correctly, your AWT components might still be stuck with the Java default (Helvetica, or whatever it is, which is incapable of displaying Chinese), and hence displaying the rectangles because they don't know how to handle the foreign characters. You might need to set SimSun as the font for each of your AWT components individually at a worst-case scenario.
    Hope that helps,
    Martin Hughes

  • Some country native characters in AWT components

    Hi All,
    I have problem with visualization some native characters on AWT components. For instance, when I put on the Frame some Labels components, then I can't see correct some special polish native characters, I can only see some boxes. It seems the same with some other AWT components with a text entry.
    This problem is only in GUI, because some other issues like Strings and Stream processing works good.
    (I tested it both on WinXP and Linux SuSE 9.1 with the same result)
    Thanks in advance for some help
    Krzysztof

    Have you tried doing this in Swing? Works for me:
    import java.awt.*;
    import javax.swing.*;
    public class FontExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    buildGUI();
        static void buildGUI() {
            Font font=new Font("Dialog",Font.PLAIN,12);
            String text="re\u0123istr\u0113tiem";
            JTextArea textarea=new JTextArea();
            textarea.setFont(font);
            textarea.setText(text);
            JComboBox combo=new JComboBox(new String[]{text});
            combo.setFont(font);
            JFrame f = new JFrame("FontExample");
            Container cp = f.getContentPane();
            cp.add(combo, BorderLayout.NORTH);
            cp.add(textarea, BorderLayout.CENTER);
            f.pack();
            f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Changing AWT components to Swing components

    I'm having a little trouble changing some AWT components to Swing components. I received an error message when I tried to run my program. I looked up the component in the java docs. But, I did not see the option the error was talking about. The error and the area of code is listed below. Thank you for any help you can provide.
    Error message:
    Exception in thread "main" java.lang.Error: Do not use P5AWT.setLayout() use P5A
    WT.getContentPane().setLayout() instead
    at javax.swing.JFrame.createRootPaneException(JFrame.java:446)
    at javax.swing.JFrame.setLayout(JFrame.java:512)
    at P5AWT.<init>(P5AWT.java:56)
    at P5AWT.main(P5AWT.java:133)
    Press any key to continue . . .
    Code:
    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout(FlowLayout.CENTER));
    ta = new JTextArea(20, 60);
    p3.add(ta);
    setLayout(new FlowLayout(FlowLayout.CENTER));
    add(p3);

    you need to change the line...
    setLayout(new FlowLayout(FlowLayout.CENTER)); to
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));

  • Overlapping AWT components

    Hi, is there anyway to control how awt components are added when they overlap over each other? (such as sending it to the front or back of all components) I have a container that has several canvases, where the last component added should be on top. Unfortunately, the canvas is always covered by the other canvas. Any advice?

    Look at his program : the last canvas is on top of the second that is no top of the first,
    mport java.awt.*;
    import java.awt.event.*;
    public class Overlap extends Frame
    public Overlap() 
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         setBounds(10,10,500,400);
         setLayout(null);     
         Canvas c1 = new Canvas();
         c1.setBounds(30,30,100,100);
         c1.setBackground(Color.pink);
         add(c1,0);
         Canvas c2 = new Canvas();
         c2.setBounds(100,100,130,130);
         c2.setBackground(Color.red);
         add(c2,0);
         Canvas c3 = new Canvas();
         c3.setBounds(200,200,100,100);
         c3.setBackground(Color.orange);
         add(c3,0);
         setVisible(true);
    public static void main (String[] args) 
         new Overlap();
    Noah

  • Lots of AWT components

    Im just wondering are there any good free tools to quickly layout lots of AWT components?
    Also how easy is it to produce tabs in AWT? is it as simple as assigning different panels to each tab?
    One more question, if there are lots of components on a screen, how fast is the AWT? for example, will it have a problem displaying 40 something components?
    Thanks for any help

    For the tab thing: Use JTabPane (which internally probably uses CardLayout), it�s very very easy: Check out the JtabePane example in SwingSet in Java Web Start, the source code is included.
    Layouting like 40 components isn�t really a performance question, because it�s nothing compared to drawing a 100*100 image.
    It takes advanced programming stuff before you will have perfomance problems, without using infinity loops or blocking the thread (by sleep or so)
    To layout many components, use several of the basic layout managers wich each other or use GridBagLayout or use my open source, free ProportionLayout (written to solve some probs I had with GridBag):
    http://users.pandora.be/lunatic/ProportionLayout/

  • Concurrently update awt components

    Hello all,
    What I understand is that it's impossible to update awt components concurrently in a thread save way. For example; If you want to implement a game in which when you push on a button a counter starts to run (in a JTextField for example). While that counter is running you want that button to be disabled for a fixed time, let's say 1 second, and want to count down on that button's text. At the same time other components should be updated by other code in the game logic ( things like mana regenration counters etc.).
    Is this possible in a thread save way with standard libraries?

    Thank you for replying.
    Yes that is what I understood. My problem is though, for example in the case of the mana regeneration, that I want it to regenerate at a fixed rate. So x amount in y seconds. I know this comes close to real time programming and is not really possible, but that's not the point here. What I'd like is that the current mana is available to the game logic and displayed at the same time in the gui, while it's being updated. While this mana regeneration is running, the user can press another button (a spell) and the mana takes another hit, while still being updated by the regeneration thread. Other game logic may affect the mana aswell (like abilities of monsters).
    The problem here is that I need none user events to update awt components and that it should be displayed in the gui real time (ish).

  • Why the AWT components are called heavy-weight and SWING as light-weight?

    Why the AWT components are called heavy-weight and SWING as light-weight?.
    Building our own components means overhead on JVM. hence in what sence the SWING components are called light weight.?
    I know that the Swing componets are the components which are not going to depend upon peer classes and render, OS independent LOOK n FEEL.
    Thanks,
    Sanath Kumar

    All extensions of Component are considered lightweight since, as you point out, they don't have their own dedicated native peer.
    Essentially a lightweight component only has a canvas on which to draw itself and some means of receiving events from the system. In fact, there is no need to have one of these "canvas" and "event" objects for each component - the parent component can manage these abilities on behalf of its children. Eventually you end up with only top-level components needing to be heavyweight in order to communicate with the windowing system.
    A lightweight component therefore has the minimal dependency on the underlying windowing system giving you maximum cross-platform flexibility.
    It is usually true that lightweight => slower and heavyweight => faster since it is reasonable to assume that native peers will be optimal for the windowing system. However, that's not the point of the lightweight/heavyweight distinction.
    Hope this helps.

  • AWT Components without Border

    I've made subclasses of all awt components and overwritten pain() metod so that the component don't have border. But this technik don't work with TextField and TextArea ( Button, Choice, List is working fine). Does any body kwno what should I do to have components with NO border or with 2D border?

    Its a pain() isn't it! Guess the only way is to do a workaround. Maybe this could be a way?
    class MyTextField extends Panel
       public TextField m_TextField;
       MyTextField()
          m_TextField = new TextField();
          add(m_TextField);
       public void doLayout()
          m_TextField.setBounds(-2, -2, getSize().width+4, getSize().height+4);
    Ragnvald Barth
    Software engineerhttp://blake.prohosting.com/ragnvald/

  • CardLayout & AWT Components

    Switching between panels when using AWT components with a CardLayout is not as smooth as when using Swing components.
    At best the 2 panels seem to merge into one another until only one is displayed, while at worst a part of the previous panel can remain on the screen for a half second or so before the switch is complete.
    Kind of hard to explain but there is no instantaneous switch like you get when using Swing components.
    As I hope to eventually run this GUI as an Applet - when the problem may, I imagine, become even more pronounced - I would be grateful for any assistance anyone could offer on this matter.
    When switching the panels ALL I do is:
    cardLayout.show(deck, "PanelName");

    Well it's too big to post the whole thing. Some snippets:
    // add the panels to the cardLayout
    deck = new Panel();
    deck.setLayout(cardDisplay);
    deck.add(menuPanel, "MenuPanel");
    deck.add(notePanel, "NotePanel");
    deck.add(logonPanel, "LogonPanel");
    deck.add(tabbedPane, "TabbedPane");
    this.add(deck);
    cardDisplay.show(deck, "LogonPanel");
    // switch on some button press
    if (e.getSource() == appendNote)
    cardDisplay.show(deck, "NotePanel");
    noteArea.requestFocus();

  • Avoid repaint in JLayeredPane components

    I have a program including a JLayeredPane that contains a JComponent and a JPanel. Both components are set on different layers of the JLayeredPane.
    I use the JPanel for painting, so I want to avoid unnecessary repaints if I can. The problem is that when I resize the JComponent using setBounds(), the JLayeredPane performs a repaint, and consequently, the JPanel too.
    How can I avoid the repaint propagation through all the JLayeredPane? I tried to use setIgnoreRepaint(true), but it didn't seem to work.
    If you need to see some code, just ask. Thanks in advanced. :)

    Sorry for not sending my SSCCE before; there was mealtime here. Thanks for your code anyway, I'll have a look now to see if I get any idea.
    This is my code. What I'd like to avoid it's to display the setence "inner painted" (it means that the paintComponent() method of the innerPanel has been triggered):
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import javax.swing.BoxLayout;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.event.MouseInputListener;
    public class SelectionFrame implements MouseInputListener {
        private final static int CURSOR_WIDTH = 2;
        private final static int ALPHA_SELECTION_INT = 20;
        private JFrame frame;
        private JScrollPane scrollPane;
        private JPanel innerPanel;
        private JPanel outerPanel;
        private JComponent transComponent;
        private JLayeredPane layeredPane;
        private boolean cursorEnabled;
        private boolean selectionEnabled;
        private Color bgColor;
        public SelectionFrame() {
            cursorEnabled = true;
            selectionEnabled = true;
            frame = new JFrame();
            frame.setTitle("Adilo Selection");
            frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),
                    BoxLayout.X_AXIS));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setMinimumSize(new Dimension(400, 300));
            bgColor = Color.CYAN;
            innerPanel = new JPanel()  {
                @Override
                protected void paintComponent(Graphics g)   {
                    System.out.println("inner painted");
            innerPanel.setBackground(bgColor);
            outerPanel = new JPanel();
            outerPanel.setBackground(Color.BLUE);
            outerPanel.setBounds(0, frame.getHeight() / 3, frame.getWidth(), frame.getHeight() / 3);
            transComponent = new JComponent()
                @Override
                public void paintComponent(Graphics g)
                    Color selectionColor = new Color(255 - bgColor.getRed(),
                            255 - bgColor.getGreen(),
                            255 - bgColor.getBlue(),
                            ALPHA_SELECTION_INT);
                    g.setColor(selectionColor);
                    g.fillRect(0, 0, getSize().width, getSize().height);
            layeredPane = new JLayeredPane();
            layeredPane.add(innerPanel, new Integer(1));
            layeredPane.add(outerPanel, new Integer(2));
            layeredPane.add(transComponent, new Integer(3));
            scrollPane = new JScrollPane();
            scrollPane.setViewportView(layeredPane);
            innerPanel.setBounds(0, 0, frame.getWidth(), frame.getHeight());
            innerPanel.addMouseListener(this);
            innerPanel.addMouseMotionListener(this);
            frame.add(scrollPane, BorderLayout.CENTER);
            frame.pack();
            frame.setVisible(true);
        private int initXPos;
        public void mousePressed(MouseEvent e) {
            initXPos = e.getX();
            if(cursorEnabled)    {
                transComponent.setBounds(e.getX(), 0, CURSOR_WIDTH, frame.getHeight());
        public void mouseReleased(MouseEvent e) {
        public void mouseEntered(MouseEvent e) {
        public void mouseExited(MouseEvent e) {
        public void mouseDragged(MouseEvent e) {
            int xPos = e.getX();
            if(selectionEnabled)    {
                if(xPos > initXPos) {
                    transComponent.setBounds(initXPos, 0, xPos - initXPos, frame.getHeight());
                else    {
                    transComponent.setBounds(xPos, 0, initXPos - xPos, frame.getHeight());
        public void mouseMoved(MouseEvent e) {
        public void mouseClicked(MouseEvent e) {
        public static void main(String[] args) {
            new SelectionFrame();
    }

  • Avoiding the repaint of all components in an JApplet

    Hello everyone,
    Thannks to all who gave me advices for the two JComboBoxes I had...finally I found two "if" conditions in the actionPerformed of the first JComboo which restricted the list of elements posted in the second one.
    I have a much bigger problem now....The Applet contains an object which is an extension of JPanel, and in this extension there is a "paintComponent()" that creates a certain number of JButtons in a "for" loop. The problem I have is :
    How could I avoid this panel to be repainted every time the page containing the Applet is resized? Is it even possible( because from what I've been reading a "paint()" of the applet always calls for all the components' "repaint()".....I haven't even definned a "paint()" for the applet, .....and then, each button has an action listener that simply won't work after a repaint() of the whole applet. And honestly i'm starting to lose my mind a bit over all this......Oh, I had almost forgotten....the problem after re-sizing is that within the borders of the Panel there are always buttons created by the "for" loop ....and they are smaller and appear high up "north" in the panel...it's horrible!!!!!
    This is my code for the paintComponent() of the extension of the JPanel:
    public void paintComponent(Graphics g){
           g.drawLine (130,50,130,450);
           g.drawLine (129,50,129,450);
           g.drawLine (270,50,270,450);
           g.drawLine (271,50,271,450);
           g.drawString("Plateau no.", 80,40);
           g.setColor(ballon);
           g.fillArc(100,434,200,100,45,-270);
           System.out.println("I've been through paint");
        for(int i=0;i<13;i++)
           System.out.println("buton ok"+i);
           plateaux=new JButton();
    plateaux[i].setEnabled(true);
    plateaux[i].addActionListener(this);
    Color cri=new Color(240-15*i,0,0);
    plateaux[i].setBounds(130,60+30*i,139,15);
    plateaux[i].setBackground(cri);
    add(plateaux[i], null);
    g.drawString(" "+ (13-i),105,70+30*i);
    There's nothing else in the extension....only the paint ...it implements ActionListener.....
    Thankx in advance....I'd really apreciate it if someone could help me.....
    Ruxi

    To clear the background for each repaint add a call to super or use clearRect or fillRect (with the background color set, of course). If you don't do this you will get artifacts in your graphics.
    class GraphicComponent extends JPanel {
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            // carry on...
    }Paint code is the place to render graphics and images, not for adding components. Add your components to the GUI in or via init. Generally is is useful to keep your drawing component separate from your other components.
    class GUIClass extends JApplet implements ActionListener {
        public void init() {
            JPanel buttonPanel = getButtonPanel();
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(buttonPanel, "South");
            getContentPane().add(new GraphicComponent());  // default center section
        private JPanel getButtonPanel() {
            JPanel panel = new JPanel(null);
            JButton[] plateaux = nw JButton[13];
            for(int i=0;i<plateaux.length;i++) {
                System.out.println("buton ok"+i);
                plateaux=new JButton("button " + i);
    plateaux[i].setEnabled(true);
    plateaux[i].addActionListener(this);
    Color cri=new Color(240-15*i,0,0);
    plateaux[i].setBounds(130,60+30*i,139,15);
    plateaux[i].setBackground(cri);
    panel.add(plateaux[i]);

Maybe you are looking for