tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/4632-problems-with-look-and-feelInfinite Kind: Discussion 2021-05-08T17:00:24Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-01-31T21:43:36Z2021-01-31T21:43:36ZProblems with Look and Feel<div><p>Hi Mike,<br>
The look and feel is responsible for setting colours in components, so that'd be the place to look. Which theme is in use?</p>
<p>Thanks,<br>
Sean</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-01-31T21:56:24Z2021-02-06T16:51:43ZProblems with Look and Feel<div><p>.</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T06:31:41Z2021-02-01T06:31:41ZProblems with Look and Feel<div><p>I have saved the L&F, set it to the cross platform one and then reinstated it around the pop-up window. This does the trick.</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T06:34:36Z2021-02-01T06:34:36ZProblems with Look and Feel<div><p>Would you mind sharing the snippet of code that you used..?</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T07:23:08Z2021-02-01T07:23:08ZProblems with Look and Feel<div><p>I've been doing a lot of work around L&F lately, so it'd be best if you didn't change the L&F. Instead could you override <code>public void updateUI()</code> in the button and use it to set the color in your popup, making sure to call <code>super.updateUI()</code> at the beginning of your override?</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T08:20:07Z2021-02-01T08:20:07ZProblems with Look and Feel<div><p>OK, I will give it a go. Just as an aside the enclosed image below the problem we are trying to overcome:<br>
By changing the L&F I achieved the second image.</p>
<p>Stuart, in this is my code: The window containing the buttons is MYJRViewer</p>
<pre>
<code> LookAndFeel previousLF = UIManager.getLookAndFeel();
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (ClassNotFoundException |InstantiationException |IllegalAccessException |UnsupportedLookAndFeelException e) {}
this.viewer = new MyJRViewer(jasperReportsContext, sourceFile, isXMLFile, locale, resBundle);
this.pnlMain.add(this.viewer, BorderLayout.CENTER);
try {
UIManager.setLookAndFeel(previousLF);
} catch (UnsupportedLookAndFeelException e) {}
}</code>
</pre></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T08:39:13Z2021-02-01T08:39:13ZProblems with Look and Feel<div><p>Ok, on most platforms by default we use getSystemLookAndFeelClassName which I think might call through to GTK on linux, if available. I'll change it to use getCrossPlatformLookAndFeelClassName, except in Dark Mode which uses the open source Darcula L&F.</p>
<p>On the mac you'll want it to use the system look and feel and using the cross platform L&F will make it look really bad.</p>
<p>So please don't change the L&F at all, and let me know if the updateUI() override isn't working for you.</p>
<p>Thanks,<br>
Sean</p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T08:45:57Z2021-02-01T08:45:57ZProblems with Look and Feel<div><p>OK, I will let you know what happens</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T16:26:54Z2021-02-01T16:26:54ZProblems with Look and Feel<div><p>Hi Sean, subclassing the JButton and JToggleButton classes and setting the background in the updateUI method seems to have worked, we are getting the same results on Windows 10, Debian, Feren and Mint Linux and Big Sur macOs. I have removed the changes to Look and Feel.</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-01T16:44:03Z2021-02-01T16:44:03ZProblems with Look and Feel<div><p>Hi Mike, could you share the code you used to do this please? Thx</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-03T09:25:50Z2021-02-03T09:25:50ZProblems with Look and Feel<div><p>Hi Stuart there isn't much to see, all I do is subclass the buttons and use them in my code. For JasperReports I have had to create own versions of JasperViewer, JRViewer and JRViewerToolbar so I can change the tool bar to use my subclassed buttons.</p>
<pre>
<code>public class MyButton extends JButton {
public MyButton() {
super();
}
@Override
public void updateUI() {
super.updateUI();
setBackground(Color.white);
}
}
public class MyToggleButton extends JToggleButton {
public MyToggleButton() {
super();
}
@Override
public void updateUI() {
super.updateUI();
setBackground(Color.white);
}
}</code>
</pre>
<p>in JRViewerToolbar</p>
<pre>
<code> protected MyToggleButton btnActualSize;
protected MyButton btnFirst;
protected MyToggleButton btnFitPage;
protected MyToggleButton btnFitWidth;
protected MyButton btnLast;
protected MyButton btnNext;
protected MyButton btnPrevious;
protected MyButton btnPrint;
protected MyButton btnReload;
protected MyButton btnSave;
protected MyButton btnZoomIn;
protected MyButton btnZoomOut;</code>
</pre></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490049712021-02-06T16:51:35Z2021-02-06T16:51:35ZProblems with Look and Feel<div><p>FYI - I've just realised that I had a different problem, and also that I've seen and fixed your problem (setting the background) before (in Python) without overriding the button... I had to call theButton.setOpaque(True) before setBackground(color) would work....</p></div>Stuart Beesley (Mr Toolbox)