logo
down
shadow

Different look and feel of java application from the look and feel of Operating System


Different look and feel of java application from the look and feel of Operating System

By : Mahdi Jlassi
Date : October 17 2020, 06:10 PM
should help you out Initialize the look & feel to the System one. (Though I like "Nimbus" more.)
This should best be done in the beginning.
code :
public static void main(String[] args) {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    ...
}


Share : facebook icon twitter icon
System look and feel layout on JFileChooser but with nimbus look and feel theme

System look and feel layout on JFileChooser but with nimbus look and feel theme


By : my_names_dave
Date : March 29 2020, 07:55 AM
wish help you to fix your issue It's possible, though I don't know whether it's recommended. I managed to get it to work by asking the view to update itself on all but the topmost JFileChooser component (since that would replace all the chooser components with the Nimbus ones which you don't want).
I'd regard this as a hack that may or may not work depending on the internals of the Windows look and feel. It relies on pretty much the whole JFileChooser being built up by Swing components. If it ever was changed to use more direct native rendering (i.e. Java asks Windows to paint a significant portion of the chooser), it wont work. Don't know how well that trick will work with other components.
code :
package test;

import java.awt.Component;

import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.UIManager;
import javax.swing.plaf.nimbus.NimbusLookAndFeel; //Or use com.sun.... if you are using JDK < 7

public class LAFTester
{
    public static void main(String... args)
    throws Exception
    {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JFileChooser chooser = new JFileChooser();
        chooser.updateUI(); //Create UI objects
        UIManager.setLookAndFeel(NimbusLookAndFeel.class.getName()); //Now set look and feel
        //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); //works with metal as well
        refreshUI(chooser, false);

        chooser.showOpenDialog(null);
    }

    private static void refreshUI(JComponent c, boolean includeParent)
    {
        if (includeParent)
            c.updateUI();

        for (int i = 0; i < c.getComponentCount(); i++)
        {
            Component child = c.getComponent(i);
            if (child instanceof JComponent)
            {
                refreshUI((JComponent)child, true);
            }
        }
    }
}
NetBeans: How to change the look and feel with respect to Operating System

NetBeans: How to change the look and feel with respect to Operating System


By : user3593722
Date : March 29 2020, 07:55 AM
I hope this helps . I developed a small desktop application in Netbeans using Java. The application is working as expected. I developed it under WIN7.
code :
try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch(Exception e){}
How to get the Operating System's Look & Feel in Java 7?

How to get the Operating System's Look & Feel in Java 7?


By : mjm499
Date : March 29 2020, 07:55 AM
should help you out I feel that this is more a question for SO, but in short you should try something like :
code :
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Extend the system look and feel in a Swing application

Extend the system look and feel in a Swing application


By : SigSegv
Date : March 29 2020, 07:55 AM
should help you out I want to use the system look and feel for a Swing application. So I used the getSystemLookAndFeelClassName() method which works pretty fine. , Finally I extended the system look and feel like this:
code :
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.put("ButtonUI", "com.my.package.MyButtonUI");
UIManager.put("Panel.background", Color.green);
public class MyButtonUI extends BasicButtonUI {

    public static final int BUTTON_HEIGHT = 24;

    private static final MyButtonUI INSTANCE = new MyButtonUI ();

    public static ComponentUI createUI(JComponent b) {
        return INSTANCE;
    }

    @Override
    public void paint(Graphics g, JComponent c) {
        AbstractButton button = (AbstractButton) c;
        Graphics2D g2d = (Graphics2D) g;
        final int buttonWidth = button.getWidth();
        if (button.getModel().isRollover()) {
            // Rollover
            GradientPaint gp = new GradientPaint(0, 0, Color.green, 0, BUTTON_HEIGHT * 0.6f, Color.red, true);
            g2d.setPaint(gp);
        } else if (button.isEnabled()) {
            // Enabled
            GradientPaint gp = new GradientPaint(0, 0, Color.red, 0, BUTTON_HEIGHT * 0.6f, Color.gray, true);
            g2d.setPaint(gp);
        } else {
            // Disabled
            GradientPaint gp = new GradientPaint(0, 0, Color.black, 0, BUTTON_HEIGHT * 0.6f, Color.blue, true);
            g2d.setPaint(gp);
        }
        g2d.fillRect(0, 0, buttonWidth, BUTTON_HEIGHT);
        super.paint(g, button);
    }

    @Override
    public void update(Graphics g, JComponent c) {
        AbstractButton button = (AbstractButton) c;
        if (isInToolBar(button)) {
            // Toolbar button
            button.setOpaque(false);
            super.paint(g, button);
        } else if (button.isOpaque()) {
            // Other opaque button
            button.setRolloverEnabled(true);
            button.setForeground(Color.white);
            paint(g, button);
        } else {
            // Other non-opaque button
            super.paint(g, button);
        }
    }

    private boolean isInToolBar(AbstractButton button) {
        return SwingUtilities.getAncestorOfClass(JToolBar.class, button) != null;
    }
}
Changing the look and feel of java gui components into the windows look and feel

Changing the look and feel of java gui components into the windows look and feel


By : Yash
Date : March 29 2020, 07:55 AM
I hope this helps . Yes, see How to Set the Look and Feel in Oracle's Java Tutorials.
To set the look and feel to the current system look and feel:
Related Posts Related Posts :
  • Static value in for loop
  • Difference between Class c; and Class c=new Class();
  • My question is about Regular Expression in java
  • Why can't I write ch=ch+1; instead of ch++; though they have same meaning
  • Why is this loop changed?
  • Java (Read and write to file)
  • What's ideal debugging setup? window placement etc
  • Java app behind proxy to use http_proxy variable in linux
  • Straight Java/Groovy versus ETL tool (Talend/etc) - what libraries would you use?
  • Performance testing Flex applications
  • How to insert into two different tables in one statement with Java and MySQL?
  • Object Serialization for Undo/Redo Functionality Java
  • How to retrieve the last image from an SDcard in Android?
  • What's the fastest way to draw a Hello World in Java
  • Java error on bilinear interpolation of 16 bit data
  • Java equivalent for database schema changes like South for Django?
  • Java Robot key activity seems to stop working while certain software is running
  • Will using multiple version of a jar in an application cause problems?
  • JSF RuntimeException: Cannot find FacesContext
  • How do i get a particular day from Jan to Dec
  • Hibernate configuration for Mysql 8.0
  • What JVM can run on CPU and GPU?
  • How to cast an image received from a webservice in Binary64 format to actual image?
  • Is there anyway to get the generated keys when using Spring JDBC batchUpdate?
  • How good is Oracle Universal Connection Pool (UCP)
  • How to populate Java (web) application with initial data using Spring/JPA/Hibernate
  • How do I make my frames change in java?
  • Java Swing - Background of a JPanel
  • Printing pdf from extjs - best solution
  • Clean a RandomAccessFile
  • JFileChooser and browsing networked machines
  • How to write Java string literals that contain double-quotes (")?
  • What do I use Artifacts in IntelliJ IDEA for?
  • Bug with Spring Security 3.0.2 x Spring 3.0.1 - Proxies not being created
  • DBunit generates java.lang.ClassCastException: java.lang.String cannot be cast to oracle.sql.CLOB when trying to load a
  • Hibernate configuration - session factory scanning?
  • Enter Key Press behave like Submit in JSF
  • Using protocol buffers for binary logging
  • EasyMock Class Extension mock isn't mocking methods
  • How do I convert a byte array to Base64 in Java?
  • How to modify camel Exchange and send it
  • How do I avoid constructors?
  • Passing string in where clause using PreparedStatement
  • Tomcat 7 - Ignoring db conections pool parameters (DBCP)
  • How does reduce() method work with parallel streams in Java 8?
  • How can I use a generic class with wildcard declaration?
  • Unable to add ArrayList with multiple arguments
  • Move application into second window monitor in javafx
  • does intern() method have implication on performance?
  • How to run NPM Command in Java code using ProcessBuilder
  • Sending HTTP/2 request via Socket in Java
  • eclipse IDE wrong warning that unused field
  • Decode Java enum from single char
  • How to hide embedded dependencies when using an OSGI bundle with maven?
  • How to correctly implement a generic interface in Java
  • send alert to html page from servlet
  • <EOF>Exception while creating Derby table
  • What does stack.pop() return?
  • Problem with Java Language Levels in IntelliJ IDEA
  • How do i get the status code for a response i subscribe to using the JDK's HttpClient?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk