Sunday 15 January 2012

java - making JFrame with custom texture -


How to set a custom window's frame header?

Instead of the blue header I make the texture from the image.

code:

  last JFrame frame = new JFrame (); Buffer image image = images Reed (new file ("D: Tactics.bmp"));   

Default window:

Enter image details here

I do not think you have anything about color or images in someone's title bar JFrame, without using native code to implement at least one platform-specific solution. The reason for this is that Jeffrey actually uses his original windowing system to make the window.

For the internal frame, it will be able to customize it for you, because it is a component provided inside a window that is controlled by Java. Indeed, there are plenty of UI managers in your life.

You can not place an image over there. Although you can try.

Here's something I saw and tried to feel:

  import javax.swing. *; Import javax.swing.plaf *; Import javax.swing.plaf.metal. *; Public category title {public static zero major_helper (string algos []) {JFrame f = new JFrame (); F.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE); F.setSize (300, 300); F.setLocationRelativeTo (null); F.setUndecorated (true); F.getRootPane () .setWindowDecorationStyle (JRootPane.FRAME); Zpean panel = new zpn (); Panel.setBackground (java.awt.Color.white); F.setContentPane (panel); DefaultMetalTheme z = New DefaultMetalTheme () {// Inactive Title Color Public Color UIResource getWindowTitleInactiveBackground () {New ColorUIResource (Java.Att.Color.orange); } // Active Title Color Get Public Colors UIRSverWondoTholeBackground () {New Color Source (Java.A.TT) // Start ActiveBumps Public ColorUIResource getPrimaryControlHighlight () {Return the new ColorUIResource (java.awt.Color.orange)) ; } Public ColorUIResource getPrimaryControlDarkShadow () {Return to New ColorUIResource (Java.tt.colour.orange); } Public ColorUIResource getPrimaryControl () {Return to New ColorUIResource (Java.atti.ange.orange); } // End Activebops // Current InputBoops Public ColorUIRSOrS getControlHighlight () {Return new color UISROS (Java.atti.ange.ange); } Public ColorUIResource getControlDarkShadow () {New ColorUIResource (Java.ETT) Public ColorUIResource getControl () {Return new ColorUIResource (java.awt.Color.orange)); } // android on Android; Metal Look Endile. Stuttgart (Zed); {UIManager.setLookAndFeel (Try New MetalLookAndFeel ()); } Hold (exception e) {e.printStackTrace (); } Swing UTGE.Update ComponentTriOi (F); F.setVisible (true); } Public Stable Zero Main (Last String AZ []) {SwingUtilities.invokeLater (New Runnabal) (Public Zero Run) {main_helper (args);}}); }}    

No comments:

Post a Comment