Tuning GC parameters for a large Swing application

Our Swing application suffers from periodic out-of-memory errors. We have been trying to tune the application with limited sucess.
The problem is full GC is called only when it is close to the maximum memory. As a result when it reaches the max-heap-size values, it takes a long time to complete GC and the application hangs.
My current jnlp settings are as follows:
<j2se version="1.5+" href="http://mydomain/myapp/jre" initial-heap-size="64M"
  max-heap-size="384M"
  java-vm-args="-verbose:gc -Dsun.java2d.noddraw=true -XX:NewSize=16m -XX:SurvivorRatio=8 -XX:YoungGenerationSizeIncrement=5 -XX:TenuredGenerationSizeIncrement=5 -XX:AdaptiveSizeDecrementScaleFactor=5" />I am looking at ways by which the tenured generation too gets garbage collected peiodically. Is there a way by which I can achieve this?

for first one, try paintImmediately(rectangle) method. for second one, i guess Graphics g = panel.getGraphics();
g.drawRect(....);

Similar Messages

  • Help please!  Using classes in large swing applications.

    I am building a fairly large swing application. The class that builds the main frame for the application is getting extremely long with code because I have so many seperate JPanels. I'm using JDialogs wherever possible, but in many cases I need a JPanel within my main frame. I've been trying to build these panels within their own seperate classes, but it seems that the components are not being drawn. Any help or a small example would be great!

    So... The question is: You don't know how to use JPanels built in other classes?
    You should probably just try to find some sort of reference code and work from that. It's really not that hard

  • Set a default Font for a whole Swing application?

    Hi,
    Is it possible to set "Courier" as the default font for a whole swing application?
    I seem to have gotten lost here, could someone give me some pointers please?
    Thank You,
    -Uday

    So it needs to be done right at the beginningYes.
    Is there a code sample i can look at for reference and a standard way of doing this.I've seen examples posted in the forum the use the UIManager.getDefaults() method and then iterate through the defaults looking for all properties that end with ".font" and then replace the font as required.

  • Is there any Open source Reporting Toll for using in swing application ?

    Is there any reporting system like crystal report or any thing for report generation. Using JTable class it is so time taking job. I have downloaded Eclipse with crystal report embedded, and have created a report but can not integrate the report with JFrame with any menu item action. All the code i got releted to JSP. and few code get that are using
    //Crystal Java Reporting Component (JRC) imports.
    import com.crystaldecisions.reports.sdk.*;
    import com.crystaldecisions.sdk.occa.report.lib.*;
    //Java Imports.
    import javax.swing.*;
    public class JRCViewReport {
         private static final String REPORT_NAME = "JRCViewReport.rpt";
         public static void launchApplication() {
              try {
                   //Open report.
                   ReportClientDocument reportClientDoc = new ReportClientDocument();
                   reportClientDoc.open(REPORT_NAME, 0);
                   //Launch JFrame that contains the report viewer.
                   new ReportViewerFrame(reportClientDoc);          
              catch(ReportSDKException ex) {     
                   System.out.println(ex);
              catch(Exception ex) {
                   System.out.println(ex);               
         public static void main(String [] args) {
              //Event-dispatching thread to run Swing GUI.  This is good practice for Swing applications
              //to help ensure that events are dispatched in a predicatable order.
              //For more information on using this method, refer to the SUN site below for more details:
              //http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Hand-off to worker function to start application.
                        launchApplication();                    
    }Also there is one file ReportViewerFrame.java
    but the error is "*com.crystaldecisions.reports.sdk*" not found
    Please help ..........................................................

    I have already use Jasper Report. Thakns a lot for your suggestion. Now I think i have solved your problem...... View the code.. this code will not open the JasperViewer but from the background it will be printed and after calling the printing function you can save a data in the database ------------------------
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            Connection con = Database.getConnection(); // your database connection
            jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);
            for(int i=0;;i++) { //print all pages
                try{
                    JRPrinterAWT.printPages(jasperPrint,i,i,false);
                }catch(Exception e) {
                    break;
            }

  • Should I use a MVC framework for an large RIA application

    The book of "Adobe Flex 3 Training from the Source" does not
    talk about any MVC frameworks in its
    eCommerce example. I think Flex's events, functions, and mx
    components are MVC already. Do they have to be in separate file to
    call them MVC? I do not find that core Flex is harder to read and
    understand than using a MVC framework. I think using the MVC
    framework would hurt the performance because too many additional
    events are dispatched. Any comments?

    MVC is one design pattern that is pretty darn useful for a
    lot of applications, IMHO. There are frameworks that more or less
    force you to think in MVC pattern terms, like Cairngorm and
    PureMVC. But you certainly don't need to use a framework to create
    an overall design pattern of model, view, controller. However, it
    sure can make it easier if you're doing a large project. The book
    you're talking about is a good example. They don't use a framework
    but they have tried to use a form of MVC in the way that they
    implement all the components to ensure things are loosely coupled.
    As far as hurting performance, I'm no expert but there are so
    many thousands of events occurring all the time in Flex that you
    might actually enhance performance if you take more control by
    using custom events of your own creation within a well designed
    framework.
    I'm a fan of the Mate because I get it and it doesn't impose
    a strict structure like Cairngorm. I don't have a whole lot of
    experience with OOP (though I'm sure getting it thanks to this
    forum). Many others have their own opinions and will surely
    recommend other frameworks. However, the bottom line is that if
    you're doing a big project, I would think it would be a huge help
    to at least have a conceptual framework approach in your mind, if
    not part of the code.
    Here's a video intro to Mate
    http://tinyurl.com/mateintro

  • Using JavaFX to rewrite GUI layer for Java Desktop Swing application

    From the faq's on javafx.com I read the following:
    I currently build applications in Java. Can I reuse my Java libraries in JavaFX Script?
    Yes. You can leverage the power of Java by using any Java library within a JavaFX application.
    This way you can preserve your investment in Java and use JavaFX to build engaging visual experiences.
    Can I use JavaFX to develop a user interface for my Java program?
    While it's easy to write your application in JavaFX and call into Java where necessary,
    the inverse - writing a Java application that calls into JavaFX for the user interface - is not yet true.
    We expect this to be addressed in the near future.
    * Perhaps I'm missing something, but I do not see the difference between the two questions, but they give completely different answers?
    * We have a swing application that we might want to use JavaFX to replace the current Swing user interface, however, we also have alot of business logic / communications code written in
    * Java that we aren't going to rewrite.
    Could someone tell me why the two questions have different answers?
    Thanks. Cheers.

    Hi Josh,
    I'm facing serious issue trying to invoke a javafx class from my java code. Could you please suggest a way to do it. Even hacks would be ood enough for now.
    I have created file Clock.fx. When run individually from my IDE (i'm using NetBeans) it works fine. But when i try to invoke it from a java class in project in throws exception.
    public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    JavaFXScriptEngine fxEngine = (JavaFXScriptEngine) manager.getEngineByName("javafx");
    System.out.print("created fxEngine");
    try {
    Object o = fxEngine.eval ("Clock { property: \"Clock\" }");
    fxEngine.invokeMethod (o, "create");
    } catch (Exception ex) {
    ex.printStackTrace();
    I get following exception
    Exception thrown in JavaFX pretty printing: java.io.FileNotFoundException: \tmp\___FX_SCRIPT___.fxdump from StringInputBuffer (The system cannot find the path specified)
    Exception thrown in JavaFX pretty printing: java.io.FileNotFoundException: \tmp\___FX_SCRIPT___.fxdump from StringInputBuffer (The system cannot find the path specified)
    javax.script.ScriptException: compilation failed
    at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.parse(JavaFXScriptEngineImpl.java:255)
    at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:145)
    at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:136)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
    at newpackage.Main.main(Main.java:29)
    Could you please give a solution to it. I would be obliged.

  • I would appreciate advice on technical choices for a large web application.

    Application Server: Sun Java System Application Server Platform 8.2
    JDK: J2EE 1.4
    Database platform: Oracle 9i
    I am currently in the middle of designing a large, not enterprise, web application.
    At this point, I have the requirements, ERDs, UML diagrams, several initial JavaBeans and POJOs contributed from other developers. So, planning is going well...
    This is a customer service application to manage customer accounts.
    I have the following sections, each section are several applications, except for the main app, which is one application:
    Option Maintenance - manages data used within the main app.
    System Maintenance - manages data used within the main app.
    Client Maintenance - manages data used within the main app.
    Event Log Browser - a historical events viewer of events in the main app.
    Transaction Browser - similar to Event Log Browser with transaction data.
    Admin. Maintenace - manages users of the application.
    Customer Management - main app.
    A user will authenicate into the main app and based on authorization, a user main also see all or specific management sections and browsers.
    I need advice on the best way to approach this in terms of making technical choices?
    I understand the MVC pattern, so my original though would be to use the framework within JSF. FacesServlet, etc...
    Again, this isn't an enterprise application by any means, but it does need to be able to scale. In later phases, when asked to add another application - I don't want to look back and say "why did I do this?"
    I just want to make sure I am making good technology choices based on known requirements.
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    jschell: Thank you for the questions, these help a lot.
    Q: Have you scaled the usage? Do you know how many users will use it in the first month and three years from now?
    Yes, it is figured that we'll start with twelve users, with an increase of about one or two new users per year, not very much at all.
    Q: What does the average user do? What does the unaverage user do?
    The average user will only use the Customer Management - main app. They will be logged in throughout the day managing accounts based on any customers calling in.
    Another average user will use the Browser based applications to check daily transactions, however this is usually towards mid-morning and in the evening.
    An unaverage user will use the Maintenance based applications to set-up the data or make any changes. The Maintenance based applications will be rarely used after set-up.
    Q: Are there any priority customers (like 50% of the companies business comes from one customer)? If so then it would be a really good idea to find out what they want and what they want to do.
    Not really priority customers, but priority call times. Most calls happened between 6:30AM - 10:00AM CST. During that time, the Customer Management - main app will be used by all twelve users.
    Q: What is the liability and security context? In other words what happens if some kid gets access to an account?
    This is an internal application, hosted inside a DMZ. A user must authenticate (log in) to use the application.
    What I have yet to deal with is how do I force authentication if a user tries to obtain access to an application through their browser history or even by typing in a URL... That's another topic in itself.
    Any transactions with in the Customer Management - main app, will be logged - in which these logs can be view by the Transaction Browser.
    Q: What are the future directions that the software might grow? What resources will it need? How will it be tested? How 'perfect' must it be when it goes live?
    The only known growth for the software would be adding additional report viewers or monitor features to help track customer transactions.
    Hardware resources, the application be hosted on a SunOS 5.8 Generic_117350-02 sun4u sparc SUNW,Sun-Fire-880. There are 8 Sun Sparc 900Mhz chips.
    Testing will occur in phases at the development stage, then it will go through a full QA stage performed by the QA Department.
    At minimum, the Customer Management - main app and Transaction Browser must be "perfect".
    Q: How much time do you have to do it?
    I have three months.

  • Very Large Business Application (VLBA)

    CVLBA Research Center
    The Center for Very Large Business Applications (CVLBA) is a joint research initiative of the Otto-von-Guericke University Magdeburg and the Technische Universität München which was initiated by SAP in 2006. The decision by SAP AG to fund research with these two university partners stems from the cooperation experiences and the knowledge transfer that has taken place by jointly running the SAP University Alliances Project. Fifteen researchers in the CVLBA teams at Otto-von-Guericke University Magdeburg and Technische Universität München focus their research on bridging the gap between ERP research and ERP development.
    Defining Very Large Business Applications
    The first step in exploring issues of VLBA was to establish a common working definition to be used by all partners. According to the definition used a VLBA is essentially characterized u2013 in contrast to a single business application u2013 by its strategic importance for an organization, by its spatial, organizational, cultural or technical unrestrictedness and by its capability to be implemented by application systems or system landscapes.
    The goal of the foundation of VLBA is a profound definition that conceives a VLBA as both, an application (instantiation level; VLBA in the narrower sense) and a research framework (meta level; VLBA in the broader sense). You can find more details in the text attached in this thread. We are looking forward to your feedback about this highly relevant topic, in particular regarding sustainability, legacy systems and cultural diversity!

    Definition of Very Large Business Application
    The first step in exploring issues of a Very Large Business Application (VLBA) was to establish a common working definition to be used by all partners. A VLBA deals with a business application, which has a strategic importance within a constituted organization. Significant features of a VLBA are:
    (1) A VLBA supports one or more processes, from which one at least is a business process. Consequently, a VLBA is directly successfully effective and the strategic dependency of the organization is given by an application of a VLBA, because changing or turning the system away is associated with big financial, organizational and personnel-related costs.
    (2) A VLBA does not have any spatial, organizational, cultural or technical limits.
    (3) VLBAs could be implemented through application systems as well as through system landscapes. It is significant that they support a (universal organizational) business process.
    A possible far reaching ability of automation of internal processes should be achieved through the application of the most modern technologies. Supply Chain Management (SCM)- and Customer Relationship Management (CRM)-systems are instances for this kind of software, as far as they fulfill all defined requirements. VLBAs are similar to a Business Information System in the manner that they can support several Business Application Fields and in this case, they are based on several types of Business Application Systems.
    VLBA as a Field of Research
    Along with the first definition, the concept of u2018VLBAu2019 was classified and integrated into the already existing conceptual world of business informatics, using the UML. This allows distinguishing u2018VLBAu2019 from other related topics and clearly defines its scope in the business informaticsu2019 scientific world. In particular, a VLBA can be regarded as a special system landscape on the one hand and as a research area in the other hand. The present-day heterogeneous and grown system landscapes, just like they are usually discovered in the business practice, suffer from the symptom of spaghetti integration. Therefore, it seems to be practical to raise principles of the Software Engineering to the level of the system landscapes and to establish a design theory in the sense of System Landscape Engineering.
    Authors: Lars Krüger (CVLBA Magdeburg) & Bastian Grabski (CVLBA Magdeburg)

  • Error -maintain archiving parameters for outgoing documents in archive link

    Hi,
    I am trying to archive an outgoing document from SAP i.e. an invoice to a content repository using archive link and getting the below error:
    Maintain archiving parameter(s) for output type RD00 (appl. V3)
    Message no. VN096
    Diagnosis
    At the time of output determination, the archiving parameters for output type RD00 (application V3) were incorrectly maintained in Customizing.
    Additional information:
    SAP object:
    Archiving object:
    Procedure
    Maintain the archiving parameters and repeat output determination for the required document.
    Kindly help as to from which transaction I can maintain archiving parameters for this transaction ???
    With Regards
    Neha

    Hi,
    Which storage device are you using? I can only speculate the problem. Ok. So output type is configured properly. Can you check the object type for your document type in Transaction code OAC3. Check it should be VBRK. If it is not then change it to VBRK. Now go to transcation code OAD5 and check every thing is configured there or not. If it is all done then it should work. I presume that all basic customization is done in your system.
    Regards
    Sirfraz

  • How run a JEE swing application client ?

    I'm making Jee tests, using NetBeans 6.8 and GlassFish v3.
    I have an application that has an EJB module and two interface clients (jar app-client and war web-client).
    Each client uses same ejb module.
    For test the web module, I made this:
    1) I set the client module for the project:
    - Right click on the project (JeeTest) -> Properties -> Run
    - Select JeeTest-war as client module
    2) When Run the project from NetBeans, it works fine
    3) Test the project directly in the web browser and also works fine.
    For test the swing application, I made this:
    1) I set the client module:
    - Right click on the project (JeeTest) -> Properties -> Run
    - Select JeeTest-app-client as client module
    2) Run the project from NetBeans, it works fine
    3) But, When I try test the jar file, outside NetBeans, not working
    The question:
    How test the swing application outside netbeans?
    [Here I put the project code for NetBeans|http://www.blueboxmicrosystems.com/JeeTest.zip]

    Hi ! gimbal2
    I Launched from the command prompt: java -jar jeetest-app-client.jar
    Opened the form, but when I press the button to call the ejb, returns this error:
    01/02/2010 11:05:00 PM forms.MainForm btnSayMessageActionPerformed
    GRAVE: null
    javax.naming.NoInitialContextException: Need to specify class name in environment or
    system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at forms.MainForm.btnSayMessageActionPerformed(MainForm.java:90)
    at forms.MainForm.access$000(MainForm.java:25)
    at forms.MainForm$1.actionPerformed(MainForm.java:53)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    The JeeTest-ejb module, have 2 classes:
    Message.java
    package ejb;
    import javax.ejb.Stateless;
    @Stateless
    public class Message implements MessageRemote {
        public String sayHello() {
            return "Hello, from EJB !!!";
    MessageRemote.java
    package ejb;
    import javax.ejb.Remote;
    @Remote
    public interface MessageRemote {
        String sayHello();
    }In the JeeTest-app-client, I am trying call the ejb from a Jbutton in the form, and pass the value to a JTextField, like this:
            String message="";
            try {
                Context context = new InitialContext();
                MessageRemote messageRemote = (MessageRemote) context.lookup(MessageRemote.class.getName());
                message=messageRemote.sayHello();
            } catch (NamingException ex) {
                Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
            this.txtMessage.setText(message);I put the code for the project HERE
    Edited by: m_ilio on 01/03/2010 03:24 AM
    Edited by: m_ilio on 01/03/2010 03:25 AM

  • New FAQ Entry on JVM Parameters for Large Cache Sizes

    I've posted a new [FAQ entry|http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#60] on JVM parameters for large cache sizes. The text of it is as follows:
    What JVM parameters should I consider when tuning an application with a large cache size?
    If your application has a large cache size, tuning the Java GC may be necessary. You will almost certainly be using a 64b JVM (i.e. -d64), the -server option, and setting your heap and stack sizes with -Xmx and -Xms. Be sure that you don't set the cache size too close to the heap size so that your application has plenty of room for its data and to avoided excessive full GC's. We have found that the Concurrent Mark Sweep GC is generally the best in this environment since it yields more predictable GC results. This can be enabled with -XX:+UseConcMarkSweepGC.
    Best practices dictates that you disable System.gc() calls with -XX:-DisableExplicitGC.
    Other JVM options which may prove useful are -XX:NewSize (start with 512m or 1024m as a value), -XX:MaxNewSize (try 1024m as a value), and -XX:CMSInitiatingOccupancyFraction=55. NewSize is typically tuned in relationship to the overall heap size so if you specify this parameter you will also need to provide a -Xmx value. A convenient way of specifying this in relative terms is to use -XX:NewRatio. The values we've suggested are only starting points. The actual values will vary depending on the runtime characteristics of the application.
    You may also want to refer to the following articles:
    * Java SE 6 HotSpot Virtual Machine Garbage Collection Tuning
    * The most complete list of -XX options for Java 6 JVM
    * My Favorite Hotspot JVM Flags
    Edited by: Charles Lamb on Oct 22, 2009 9:13 AM

    First of all please be aware HSODBC V10 has been desupported and DG4ODBC should be used instead.
    The root cause the problem you describe could be related to a timeout of the ODBC driver (especially while taking care of the comment: it happens only for larger tables):
    (0) [MySQL][ODBC 3.51 Driver]MySQL server has gone away (SQL State: S1T00; SQL
    (0) Code: 2006)
    indicates the Driver or the DB abends the connection due to a timeout.
    Check out the wait_timeout mysql variable on the server and increase it.

  • Place to store custom parameters (properties) in swing application

    In a relatively simple swing application, I was wondering how should I handle choosing of custom parameters like database userid and password. I think for a simple application I can use xml file for setting the userid and password. But that leads to some doubts.
    1. The xml file cannot be included in the jar distribution beacuse otherwise the user will not be able to change the settings.( We don't expect the user to unjar the file, change the settings and repackage it). So where should the xml file be put ?
    2. In my program, I should be able to read the xml file based on the relative path (which ideally should begin from the location where the jar is stored). How would I achieve that.
    That said, if there is some other way, easier or more suited for this kind of functionality, please let me know.
    regards,
    nirvan.

    Jam_IT wrote:
    (new File("")).getAbsolutePath();If the file is not there, ..My understanding is that if the user drags a shortcut to the Jar onto the desktop, that absolute path will point to the desktop.
    On a related note. Sun has decided it is no business of code to know where it is stored. Changes to applets and JWS now ensure the code cannot discover the installation location (even for digitally signed and fully trusted code). Non-JWS/applet projects might be able to still get a File location using ..
    URL url = ourObject.getClass().getProtectionDomain().getCodeSource().getLocation();..but I would not bank on that still working in Java's 7 or 8..

  • Best setup for a swing application

    Hello,
    I have developed an Swing application for a EPOS machine.
    The machine has around 512 ram.
    What's the best setup for me in terms of performance, for example, which JVM to use etc.....
    Cheers
    Bobby

    bsbiran wrote:
    Hi,
    Well the app require alot of images and I parts of it do run 'slow'
    ...I'm currently going through a book about Swing and read that many times the "slowness" of a Swing-application can be credited to the programmer for not using the API efficiently/correctly (letting the app repaint too much, or repainting large parts that don't need repainting at all, to name just two things). So, I don't know how much of a Swing-guru you are, but it might be better to read a few decent Swing tutorials or pick up a good Swing book.

  • How to give Common Background color for all JPanels in My Swing application

    Hi All,
    I am developing a swing application using The Swing Application Framework(SAF)(JSR 296). I this application i have multiple JPanel's embedded in a JTabbedPane. In this way i have three JTabbedPane embedded in a JFrame.
    Now is there any way to set a common background color for the all the JPanel's available in the application??
    I have tried using UIManager.put("Panel.background",new Color.PINK);. But it did not work.
    Also let me know if SAF has some inbuilt method or way to do this.
    Your inputs are valuable.
    Thanks in Advance,
    Nishanth.C

    It is not the fault of NetBeans' GUI builder, JPanels are opaque by default, I mean whether you use Netbeans or not.Thank you!
    I stand corrected (which is short for +"I jumped red-eyed on my feet and rushed to create an SSCCE to demonstrate that JPanels are... mmm... oh well, they are opaque by default... ;-[]"+)
    NetBeans's definitely innocent then, and indeed using it would be an advantage (ctrl-click all JPanels in a form and edit the common opaque property to false) over manually coding
    To handle this it would be better idea to make a subclass of JPanel and override isOpaque() to return false. Then use this 'Trasparent Panel' for all the panels where ever transparency is required.I beg to differ. From a design standpoint, I'd find it terrible (in the pejorative sense of the word) to design a subclass to inconsistently override a getter whereas the standard API already exposes the property (both get and set) for what it's meant: specify whether the panel is opaque.
    Leveraging this subclass would mean changing all lines where a would-be-transparent JPanel is currently instantiated, and instantiate the subclass instead.
    If you're editing all such lines anyway, you might as well change the explicit new JPanel() for a call to a factory method createTransparentJPanel(); this latter could, at the programmer's discretion, implement transparency whichever way makes the programmer's life easier (subclass if he pleases, although that makes me shudder, or simply call thePanel.setOpaque(false) before returning the panel). That way the "transparency" code is centralized in a single easy to maintain location.
    I had to read the code for that latter's UI classes to find out the keys to use (+Panel.background+, Label.foreground, etc.), as I happened to not find this info in an authoritative document - I see that you seem to know thoses keys, may I ask you where you got them from?
    One of best utilities I got from this forum, written by camickr makes getting these keys and their values very easy. You can get it from his blog [(->link)|http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/]
    Definitely. I bit a pair of knucles off when discovered it monthes after cumbersomely traversing the BasicL&F code...
    Still, it is a matter-of-fact approach (and this time I don't mean that to sound pejorative), that works if you can test the result for a given JDK version and L&F, but doesn't guarantee that these keys are there to stand - an observation, but not a specification.
    Thanks TBM for highlighting this blog entry, that's the best keys list device I have found so far, but the questions still holds as to what specifies the keys.
    Edited by: jduprez on Feb 15, 2010 10:07 AM

  • How can I select a smaller font for all components of a Swing application?

    The default size of font in Java Look and Feel is 12, how can I change it to 10 globally for my Swing application ?
    Thanks for your help.
    Helen

    It is not very simple because all components don't use the same fonts and if you don't want to subclass the l&f you can do this :
    after setting the l&f (in the main for example)
    Font f = new Font("dialog", Font.PLAIN, 11);
    UIManager.put("MenuItem.font", f);
    UIManager.put("Menu.font", f);
    UIManager.put("MenuItem.acceleratorFont", new Font("dialog", Font.PLAIN, 10));
    UIManager.put("Label.font", f);
    UIManager.put("Button.font", f);
    UIManager.put("ToggleButton.font", f);
    UIManager.put("ToolTip.font", f);
    UIManager.put("List.font", f);
    UIManager.put("Table.font", f);
    UIManager.put("TextField.font", f);
    UIManager.put("ComboBox.font", f);
    UIManager.put("RadioButton.font", f);
    UIManager.put("CheckBox.font", f);
    UIManager.put("RadioButtonMenuItem.font", f);
    UIManager.put("CheckBoxMenuItem.font", f);
    UIManager.put("TableHeader.font", f);
    UIManager.put("Spinner.font", f);
    UIManager.put("Panel.font", f);etc...
    Denis

Maybe you are looking for