I have a number of components on panel and I want to apply different look and feel to different components. Is it possible?
I have a number of components on panel and I want to apply different look and feel to different components. Is it possible?
Yes is possible, don't do it, because most of Look and Feel have got different
Color, Font, Foreground, Background
Size or PreferredSize on the screen
use another methods from API for LayoutManager
implemented various methods in the JCOmponents APIs e.g. Color, Font, Foreground, Background
simple answer ---> is possible to create a awfull mess on the screeen
I'd suggest to use todays Java Look and Feels, most of them have various colors themes, part of them seperates themes and with option to change Colors themes, then there you can mixing built-in themes or/and with Color themes for each of JComponents
I think that with success you can to set Color, Font, Foreground, Background only, Look and Feels required basic knowledge about how JComponents and/with LayoutManagers together works
Yes,
you can do it. See Mixing look and feel
BUT
It's not recommended, and, frankly, it's ugly. Why would you want to do that? Is there something specific you wish to do? Perhaps there's a better way.
I have a number of components on panel and I want to apply different look and feel to different components. Is it possible?
Yes is possible, don't do it, because most of Look and Feel have got different
Color, Font, Foreground, Background
Size or PreferredSize on the screen
use another methods from API for LayoutManager
implemented various methods in the JCOmponents APIs e.g. Color, Font, Foreground, Background
simple answer ---> is possible to create a awfull mess on the screeen
I'd suggest to use todays Java Look and Feels, most of them have various colors themes, part of them seperates themes and with option to change Colors themes, then there you can mixing built-in themes or/and with Color themes for each of JComponents
I think that with success you can to set Color, Font, Foreground, Background only, Look and Feels required basic knowledge about how JComponents and/with LayoutManagers together works
I know I am late but I think someone might be use this it is kind of hack that I use to put multi look and feel to the app: put this the look and feel chooser before initiating the item (before writing = new ...)
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and then return the UIManager look and feel to the look and feel that it was on before you do this after it as in the example below:
JButton test;
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
test = new JButton();
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Mwtal".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Like this only the button test will have the look and feel of the windows and the rest will have look and feel of Metal.
Hope this hack help someone.
No ,you can not. Before you running your java application ,JVM will only load swingpropertitirs.propertities(a file located in you jre/lib) once , and it will only select only your default L&F ,but if you set your look and feel by adding code , it will use the L&F you selected.
© 2022 - 2024 — McMap. All rights reserved.