Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP  Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP,Python
Java JSP Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP, Python Java JSP Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, Python,JSP
Java JSP Application Hosting Web Hosting Sign-Up Java JSP Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting  Java JSP Application Hosting Resellers web hosting, website hosting, web site hosting Java JSP Application Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python,JSP,  Fundraising
Java JSP Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting
WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Java JSP Application Hosting Welcome Java JSP Application Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Java JSP Application Hosting Fund Raising, Fundraising, web hosting Java JSP Application Hosting Resellers, web Hosting Java JSP Application Hosting Web Design, web Hosting Java JSP Application Hosting Extra Services,  web Hosting Java JSP Application Hosting Traffic Booster, web hosting Java JSP Application Hosting Traffic Booster, web hosting Java JSP Application Hosting Technical Support,  web Hosting Java JSP Application Hosting webmaster tips,  web Hosting Java JSP Application Hosting 30 Day Money Back, web hosting Java JSP Application Hosting Legal Notices for Web Hosting Java JSP Application Hosting Glossary Computer Terms for web Hosting Java JSP Application Hosting Contact Information - web hosting

Site Map
Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python, JSP Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting Solving Common Component Problems (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
Trail: Creating a GUI with JFC/Swing
Lesson: Using Swing Components
Home Page > Creating a GUI with JFC/Swing > Using Swing Components
Solving Common Component Problems
This section discusses problems that you might encounter while using components. If you don't find your problem in this section, consult the following sections:

Problem: I'm having trouble implementing a model (or some other code that's similar to something already in Java SE Platform, Standard Edition).

  • Look at the Java SE source code. It's distributed with the JDK, and it's a great resource for finding code examples of implementing models, firing events, and the like.
Problem: Whenever the text in my text field updates, the text field's size changes.
  • You should specify the preferred width of the text field by specifying the number of columns it should have room to display. To do this, you can use either an int argument to the JTextField constructor or the setColumns method.
Problem: Certain areas of the content pane look weird when they're repainted.
  • If you set the content pane, make sure it's opaque. You can do this by invoking setOpaque(true) on your content pane. Note that although JPanels are opaque in most look and feels, that's not true in the GTK+ look and feel. See Adding Components to the Content Pane for details.
  • If one or more of your components performs custom painting, make sure you implemented it correctly. See Solving Common Painting Problems for help.
  • You might have a thread safety problem. See the next entry.

Problem: My program is exhibiting weird symptoms that sometimes seem to be related to timing.

Problem: My modal dialog gets lost behind other windows.

  • If the dialog has a null parent component, try setting it to a valid frame or component when you create it.
  • This bug was fixed in the 6.0 release. For more information, see 4255200.

Problem: The scroll bar policies don't seem to be working as advertised.

  • Some Swing releases contain bugs in the implementations for the VERTICAL_SCROLLBAR_AS_NEEDED and the HORIZONTAL_SCROLLBAR_AS_NEEDED policies. If feasible for your project, use the most recent release of Swing.
  • If the scroll pane's client can change size dynamically, the program should set the client's preferred size and then call revalidate on the client.
  • Make sure you specified the policy you intended for the orientation you intended.
Problem: My scroll pane has no scroll bars.
  • If you want a scroll bar to appear all the time, specify either VERTICAL_SCROLLBAR_ALWAYS or HORIZONTAL_SCROLLBAR_ALWAYS for the scroll bar policy as appropriate.
  • If you want the scroll bars to appear as needed, and you want to force the scroll bars to be needed when the scroll pane is created, you have two choices: either set the preferred size of scroll pane or its container, or implement a scroll-savvy class and return a value smaller than the component's standard preferred size from the getPreferredScrollableViewportSize method. Refer to Sizing a Scroll Pane for information.
Problem: The divider in my split pane don't move! Problem: The setDividerLocation method of JSplitPane doesn't work.
  • The setDividerLocation(double) method has no effect if the split pane has no size (typically true if it isn't onscreen yet). You can either use setDividerLocation(int) or specify the preferred sizes of the split pane's contained components and the split pane's resize weight instead. Refer to Positioning the Divider and Restricting Its Range for information.
Problem: The borders on nested split panes look too wide. Problem: The buttons in my tool bar are too big.
  • Try reducing the margin for the buttons. For example:
    button.setMargin(new Insets(0,0,0,0));
    
Problem: The components in my layered pane aren't layered correctly. In fact, the layers seem to be inversed — the lower the depth the higher the component.
  • This can happen if you use an int instead of an Integer when adding components to a layered pane. To see what happens, make the following change to LayeredPaneDemo:

    Change this...to this...
    layeredPane.add(label, new Integer(i)); layeredPane.add(label, i);

Problem: The method call colorChooser.setPreviewPanel(null) does not remove the color chooser's preview panel as expected.

  • A null argument specifies the default preview panel. To remove the preview panel, specify a standard panel with no size, like this: colorChooser.setPreviewPanel(new JPanel());

Previous page: How to Use Borders
Next page: Questions and Exercises: Using Swing Components
 
 
 

Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . . .
.
.
. .
.
. .
. . . . . . . . . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting