Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Java, Java 7 Edition
This is the forum to discuss the Wrox book Ivor Horton's Beginning Java, Java 7 Edition by Ivor Horton ; ISBN: 978-0-470-40414-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Java, Java 7 Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2013, 09:27 PM
Registered User
 
Join Date: Dec 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Pg 668, Extension of pg 665 "Try It Out"

I was unable to get anything but metal "look and feel". My code is below. Tried moving segments around without success. Using Windows 8.1.
On Line 9, I set "look and feel" to nimbus but the look was still metal. I know this because I print out that variable on Line 43 and it is still metal. I have 5 possible "look and feel"s but always get metal. Any suggested changes to the code to make it work is most welcome.

Code:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class TryWindow {
  public static void createWindow() {
  JFrame aWindow = new JFrame("This is the Window Title");
      try {
	  UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
	  javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
	} catch(Exception e) {
	  System.err.println("Look and feel not set.");
	}


	try {
	  UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName());
	  javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
	} catch(Exception e) {
	  System.err.println("Look and feel not set.");
	}

	int windowWidth = 400;
	int windowHeight = 150;
	aWindow.setBounds(50,100, windowWidth, windowHeight);
	aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	aWindow.setVisible(true);
		
  }
  
  public static void main(String[] args) {
    UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels();
    for(UIManager.LookAndFeelInfo look : looks) {
	  System.out.println(look.getClassName());
	}

    SwingUtilities.invokeLater(new Runnable() {
	  public void run() {

	    createWindow();
	  }
	});
	System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());
  }
 }

Last edited by engindav; December 20th, 2013 at 11:48 AM.. Reason: clarification
 
Old December 20th, 2013, 04:19 PM
Registered User
 
Join Date: Dec 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem Solved

NVM - found the answer. I inserted the "JFrame.set...Decorated(true);" line as shown. The code below is from line 5, 6 and now a new line 7 which pushes everything down a line. I Googled "get look and feel to work in windows 8 with java" and found this link

http://stackoverflow.com/questions/5...e-this-in-java

Code:
public class TryWindow {
  public static void createWindow() {
  JFrame.setDefaultLookAndFeelDecorated(true);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2, pg 82. "R.layout.main" Error Nick Makin BOOK: Beginning Android 4 Application Development 1 July 17th, 2013 08:45 PM
Chapter 6 - pg.228 ThemeList "not declared" lsochia BOOK: Beginning ASP.NET 4 : in C# and VB 3 February 8th, 2011 03:50 AM
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.