Strange JButton appearance for all LAFs except Windows
It took me a while to figure out how to repeat this problem, but I finally did. I have a simple BoxLayout container in a JFrame, and with Windows Look and Feel it looks as expected. With any other LAF on my system (Metal, Windows Classic, CDE/Motif) all buttons except one are displayed as if their insets are null. The button border is confined very close to the button text. Calling setSize() on the button doesn't make any difference.
What makes it strange is that I can't see why one button is displayed properly. And even stranger is the fact that it's not the button position that determines which one looks correct. Take a look at the test code below, which is a stripped down executable extract of my program. The JButton object "settings" is always displayed correctly, even If you re-arrange the arguments to the cbButtonPanel.add() methods so that "settings" is in a different position. I can't see anything different about how settings is defined or configured compared to the other buttons. I even gave them the same button text to eliminate that as the source of the difference.
If you run the test code with no program argument, it will default to Windows Look and Feel, and the buttons will look as I intended them to. But enter a LAF name for the argument (See the names provided on the console when you run the program) other than Windows and you'll see that all but one button are not displayed properly. (Note that for any multi-word LAF name, e.g. Windows Classic, you need to enclose the argument in quotes.)
The code seems to be a straightforward implementation of a BoxLayout managed container, as documented in the javadocs and the tutorial. Am I doing something wrong that Windows LAF lets me get away with?
import java.awt.Container;
import java.awt.Dimension;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.Border;
public class RcbGuiTest{
JFrame frame = null;
int width;
int height;
JTextField fileSelect = null;
JPanel cbButtonPanel;
JButton sendFile = null;
JButton copyCBToCB = null;
JButton copyCBToFile = null;
JButton settings = null;
JButton restart = null;
JMenuBar menuBar;
JMenu helpMenu;
JMenuItem about;
JMenuItem help;
JMenuItem readme;
JMenuItem rcbWeb;
HashMap lafMap = new HashMap();
String lafName = "";
public static void main(String[] args){
if (args.length == 0){
args = new String[]{"Windows"};
final RcbGuiTest test = new RcbGuiTest(args[0]);
SwingUtilities.invokeLater(new Runnable(){
public void run(){
test.createAndShowGUI();
public RcbGuiTest(String lafName){
this.lafName = lafName;
public void createAndShowGUI(){
Border raisedBevel = BorderFactory.createRaisedBevelBorder();
frame = new JFrame("RCB Control Panel");
//set up menu items
menuBar = new JMenuBar();
helpMenu = new JMenu("Help");
about = new JMenuItem("About RCB");
help = new JMenuItem("RCB Help");
readme = new JMenuItem("Readme File");
rcbWeb = new JMenuItem("RCB on the Web");
helpMenu.add(about);
helpMenu.add(help);
helpMenu.add(readme);
helpMenu.add(rcbWeb);
menuBar.add(helpMenu);
frame.setJMenuBar(menuBar);
Container contentPane = frame.getContentPane();
JLabel fileSelectLabel = new JLabel(
"Enter file name, select files, or drag and drop files");
fileSelect = new JTextField(30);
fileSelect.setMinimumSize(new Dimension(250,20));
fileSelect.setSize(new Dimension(250,20));
sendFile = new JButton("Button");
sendFile.setMinimumSize(new Dimension(120,25));
sendFile.setSize(new Dimension(120,25));
JButton selectFile = new JButton("Button");
copyCBToCB = new JButton("Button");
copyCBToFile = new JButton("Button");
settings = new JButton("Button");
restart = new JButton("Button");
sendFile.setBorder(raisedBevel);
selectFile.setBorder(raisedBevel);
copyCBToCB.setBorder(raisedBevel);
copyCBToFile.setBorder(raisedBevel);
restart.setBorder(raisedBevel);
JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel,BoxLayout.X_AXIS));
labelPanel.add(Box.createRigidArea(new Dimension(5,20)));
labelPanel.add(fileSelectLabel);
labelPanel.add(Box.createHorizontalGlue());
JPanel fieldPanel = new JPanel();
fieldPanel.setLayout(new BoxLayout(fieldPanel, BoxLayout.X_AXIS));
fieldPanel.add(Box.createRigidArea(new Dimension(5,20)));
fieldPanel.add(fileSelect);
fieldPanel.add(Box.createRigidArea(new Dimension(5,20)));
JPanel fileButtonPanel = new JPanel();
fileButtonPanel.setLayout(new BoxLayout(fileButtonPanel, BoxLayout.X_AXIS));
fileButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
fileButtonPanel.add(sendFile);
fileButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
fileButtonPanel.add(selectFile);
fileButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
fileButtonPanel.add(restart);
fileButtonPanel.add(Box.createHorizontalGlue());
cbButtonPanel = new JPanel();
cbButtonPanel.setLayout(new BoxLayout(cbButtonPanel, BoxLayout.X_AXIS));
cbButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
cbButtonPanel.add(copyCBToCB);
cbButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
cbButtonPanel.add(settings);
cbButtonPanel.add(Box.createRigidArea(new Dimension(5,0)));
cbButtonPanel.add(copyCBToFile);
cbButtonPanel.add(Box.createHorizontalGlue());
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
contentPane.add(labelPanel);
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
contentPane.add(fieldPanel);
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
contentPane.add(fileButtonPanel);
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
contentPane.add(cbButtonPanel);
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
width = 320;
height = 180;
fileSelect.setMaximumSize(new Dimension(width,20));
frame.setMinimumSize(new Dimension(width, height));
frame.setResizable(false);
LookAndFeelInfo[] laf = UIManager.getInstalledLookAndFeels();
for (int i= 0; i<laf.length; i++){
System.out.println("LAF Name: " + laf.getName());
lafMap.put(laf[i].getName(), laf[i].getClassName());
String lafClassName = "";
try {
UIManager.setLookAndFeel( lafClassName = (String)lafMap.get(lafName));
System.out.println("Using Look and Feel " + lafName + "\tclass name: " + lafClassName);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
SwingUtilities.updateComponentTreeUI(frame);
frame.setVisible(true);
The problem turned out to be the setBorder() invocations I was making on the JButtons. This was left over from when I originally used a null layout manager, and the setBounds() calls were making the buttons appear at their desired size. The clue came when I discovered that I was setting the border on all buttons except settings, the one that was behaving properly. Why it behaved as expected with Windows LAF I have no idea.
Similar Messages
-
Sound works fine for all programs on Windows 7 (64-bit) except recently 64-bit iTunes just stopped working. I believe the sound stopped right after downloading the 10.5.1.42 version of iTunes.
Sir,
I had the same problem with itunes 10.5 with creative labs sound card. The only way I could solve it was to use the built in sound on my video card. But needless to say I have a very high end video card, I have the NVIDIA GTX 580. And after I used the sound on my video card everything worked great. -
How to diable delete button in PO for all users excepting one
Dear All
Please guide how to disable delete button in PO for all users excepting only one.
ThanksHi,
check following link
[Disable fields at item level in ME22N;
[Disable Delete Button;
Regards
Kailas Ugale -
How to set mozilla firefox homepage for all users in windows 7?
I want to set same homepage for all users in windows 7.
You can use a mozilla.cfg file in the Firefox program folder to lock prefs or specify new (default) values.
Place a local-settings.js file in the defaults\pref folder where also the channel-prefs.js file is located to specify using mozilla.cfg.
pref("general.config.filename", "mozilla.cfg");
These functions can be used in the mozilla.cfg file:
defaultPref(); // set new default value
pref(); // set pref, but allow changes in current session
lockPref(); // lock pref, disallow changes
See:
*http://kb.mozillazine.org/Locking_preferences
*http://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/ -
Exclusion - For all customers, except one
Is there a simple way to create exclusion for ALL customers, except XXXXX?
There are approx 20,000 customers, across multiple Sales Orgs.
Would like to exclude 100+ products from 19,999 customers
Is there are way to set up products for only one customer to purchase?
Listing will not work.
Considering multiple levels of exclusion to get to the 1 customer, but searching for an easier method.
Thanks.Hi Tom,
I think Listing will work.
What if you make a single material group for all 100+ products and create condition record in Listing for this material group and that particular customer ??
I think it should work.
Share your feedback
Sagar -
Pin shortcuts to Taskbar and Start Menu for all users in Windows 7
How can i Pin shortcuts to Taskbar and Start Menu for All Users in Windows 7? Office 2007 Word, Excel and Outlook.
There are a few ways...
You can configure a default profile which will give you the ability to setup the Start Menu as you want it with the items pinned how you like. However, in my experience customizations done to the Taskbar are not maintained in a default profile.
So, one way to get around that would be to create a script and use the "Active Setup" hooks that are built into Windows 7 to achieve the desired results.
If you combine this script...
http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
With Active Setup...
http://www.visualbasicscript.com/Active-Setup-Examples-m67461.aspx
You can get the results you want to get...
Pinned items on the Taskbar have two components, one is in the file system and the other is in the registry. You could also use GPO Preferences to add both components to a new profile and therby get similar results. I played around with this method a little and did get it to work also.
Mike N. -
Hi,
for example, in student table i am having 1000 columns, column names like(id ,name,class, dept,etc,.).
i want to insert 998 fields to department table from student tables except(id,class).
i don't want to mention all column names in the insert command,
is there any possibilities to filter the column names in insert command like (EXCEPT, NOT IN).
Thanks in advance..duplicate of
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b31fa034-5b8f-42e4-b4e1-592a632ca6a5/inserting-values-for-all-records-except-1-or-2-column-without-specify-column-names?forum=sqlce
please dont cross post
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Setting a default folder view for all folders in Windows 7
How do you set up a default folder view of "List" for ALL the folders in Windows 7 including the optical drive?
ArtooI just installed windows 7. Are you seriously telling me that i now have all folders with mp3s in them AUTOMAGICALLY (THANKS FOR THE HANDY HELPING HAND THERE MICROSOFT!!!) set to some designers whim of what an mp3 folder "SHOULD" look like?
Well i was going to write a big rant, and indeed did, but then i was doing some more research and it seems like i just made everyones day and solved the problem (partially). Or well THIS guy did:
http://www.howtogeek.com/howto/16694/customize-the-five-windows-folder-templates/
After you’ve clicked OK, visit some of the other folders in your file system. You should see that most have taken on these new settings.
What we’ve just done, in effect, is we have customized the General Items template. This is one of five templates that Windows Explorer uses to display folder contents. The five templates are called (in Windows 7):
General Items
Documents
Pictures
Music
Videos
When a folder is opened, Windows Explorer examines the contents to see if it can automatically determine which folder template to use to display the folder contents. If it is not obvious that the folder contents falls into any of the last four templates,
then Windows Explorer chooses the General Items template. That’s why most of the folders in your file system are shown using the General Items
template.
Changing the Other Four Templates
If you want to adjust the other four templates, the process is very similar to what we’ve just done. If you wanted to change the “Music” template, for example, the steps would be as follows:
Select a folder that contains music items
Apply the existing Music template to the folder (even if it doesn’t look like you want it to)
Customize the folder to your personal preferences
Apply the new template to all “Music” folders
A fifth step would be: When you open a folder that contains music items but is not automatically displayed using the Music template, you manually select the Music template for that folder.
Anyways, sorry that explanation doesnt do it justice. I have spent waaay too much time trying to figure this out already. Also that link doesnt say how to 1) copy templates (are they file or registry based?, didnt do research) 2) if you can distable templates
or the automatic re-templating of folders.
THAT is what i want to know! as it is much more maintance then its actually worth...
but once i had set 5 default types to, the exact same thing... it now doesnt matter if it automagically switches it. SUCK IT MS AUTOTUNE!!!
Its bloody hard to frame this question too. What can you say about this? "folder changes to mp3" "customize folder types windows 7" "windows 7 folder changes to mp3" "dont automatically change folders to mp3" "how
to change mp3 details column for good" "automatically change column order win 7 mp3"
The search that actually solved it:
"do not apply default template to mp3 windows 7"
good luck, this worked for me!
EDIT: also i just noticed that neonr already answered this above. i just didnt read it carefully enough. anyways i guess i will leave this and mark his as answer. -
Setting Finder Sidebar Folders for all users on Windows Network.
Morning All,
Have 15 iMacs and have joined them to Active Directory using Centrify.
Looking to customize the Finder Sidebar for all users that log on. We don't want to do this manually for all users. Specifically want to make sure the Home Folder is mapped and documents folder and all the other ones are not showing.
Is this possible to do at all? We have Centrify Group Policies we can apply on our Windows Network and a Mac Server we can use with Profile Manager if necessary as well.
Hope you can help,
Regards,Hi All,
Thought I'd bring this thread to the top again in the hopes someone will be able to help. -
Registering Plugins/Extensions for All Users on Windows 7
I am deploying firefox in a shared desktop environment and they all require the same firefox extensions.
I have downloaded the .xpi files and when I install them it only appears for me and not for the other users on the PC.
I need to be able to install these extensions once and have them available to all users on that PC.
I tried the -install-global-extensions command, but looks like that was removed from Firefox 10. Does anyone have any suggestions to my problem?
thanks!Hi!
I'm not an expert with Add-ons so I can't help much but at least someone else in this forum knows the answer you may be luckier in the Add-ons forum: https://forums.mozilla.org/addons/ -
Unable to change keyboard layout for all users on Windows Server 2012 R2
Hi,
I have a requirement where I need to support national keyboard layout for Danish for all users on that machine. When I ran the powershell with script Set-WinUserLanguageList
-LanguageList da-DK it only sets the Danish keyboard layout to the specific logged in user.However the for other users its same English(US) keyboard which is not expected.
Please help me how to set the Danish keyboard for all users on the machine. Its Urgent!ThanksHi Mike,
Thanks for reply.
But I need to configure everything using powershell script. Is it possible to use powershell script to setting group policy/ adding logon script ?
These are pretty basic administration tasks and almost always quicker to accomplish with the GUI. Why do you want to use a PowerShell script?
EDIT: Here's some information on the topic however:
https://technet.microsoft.com/en-us/library/cc781361%28v=ws.10%29.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/06/use-powershell-and-group-policy-for-your-logon-script.aspx
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing) -
Remove Collapse/expand icons from the tray for all user except administrato
Hi,
My requirement is to remove the expand/collapse icons from the overview page for all the user but administrator can have those available.
I have set the show tray property to NO , this has made the complete tray invisible for all including the administartor as well.
I want the only icons to be inviisble and not for administrator.
Please provide your valuable inputs.
Thanks
PoojaHi
The best practice in Portal is to create 2 different design, one for users, one for administrators. I mean design : Desktop, Framework Page, Theme ...and so on.
This allows you to manage two ways of displaying or not informations, for sure user view should be different of administrator view.
And you also in your case you should have tow different "overview" iViews, one for users one for administrators.
The "show tray" property should be yes (otherwise you won't see anyting ), but the property "Show Expand/Collapse icon in tray" to NO.
I hope it will help
Best regards
johann -
Unix command to stop Software updates for all users except admins?
I want to stop App Store and other software updates for all user accounts. Administrator accounts should still be able to do Software Updates.
Is there a terminal command that can do that i can push out through ARD?
ThanksManaged preferences are the best bet. You could use Profile Manager or use the mcx command from the command line. I'd strongly suggest browsing over this before delving into MCX though...
http://macadmins.psu.edu/2011presentations/PSUMAC301-MCX-John_DeTroye.pdf
(the Workgroup Manager application shown is deprecated, but it's essentially the same with Profiles and running MCX from the command line) -
Hi Team,
We have notification subscription configured currently, which will send email notification for Central team for all alerts generated in SCOM. Recently we got complaint from messaging(exchange server) team, that the exchange related email notifications are
going to other teams.
How shall we exclude "All exchange 2010 entities" group from current subscription.
Thanks,
Dinesh
Thanks & Regards, DineshHi
There is no functinality to exclude objects in notifications. You would have to select everything that you want to be alerted on. Either you select all Groups, classes or split up the subscription per "Technology" like SQL, IIS etc. and select
the corresponding MPs to be alerted on like all rules and Monitors.
Probably selecting the classes would be the best option
https://social.technet.microsoft.com/Forums/systemcenter/en-US/7e8a5d4a-1727-4448-a2d8-85950645e01a/notification-subscription-by-management-pack
This might help also
http://blogs.technet.com/b/kevinholman/archive/2008/06/26/using-opsmgr-notifications-in-the-real-world-part-1.aspx and
http://myitforum.com/myitforumwp/2014/03/04/system-center-operations-manager-2012-r2-generating-notifications-by-management-pack/
Cheers,
Stefan
Blog: http://stefanroth.net If my post helped you, please take a moment to vote as helpful and\or mark as an answer -
Firefox won't install for all users in Windows 8.1; only installs for administrator
Since moving to Windows 8.1, I have been unable to install Firefox for multiple users on this laptop. Firefox installs only for the Administrator (me), and does not appear on any other user account. When I try installing from one of the other user accounts (after entering my administrator password), it simply won't install.
Check that Firefox isn't set to run as Administrator.
Right-click the Firefox desktop shortcut and choose "Properties".
Make sure that all items are deselected in the "Compatibility" tab of the Properties window.
* Privilege Level: "Run this program as Administrator" should not be selected
* "Run this program in compatibility mode for:" should not be selected
Also check the Properties of the firefox.exe program in the Firefox program folder (C:\Program Files\Mozilla Firefox\).
Maybe you are looking for
-
How to rescrict the user to enter a manual condition type once in pricing
Hi All, We are using a condition type ZSP1 in our pricing procedure. I want that the user should be able to enter the condition type only once during pricing. eg Suppose the user has entered ZSP1 as 100 in the sales order , then he should not be able
-
B.Y.O.x , authentication, best practice, mixed OSes
Morning me again......... I have 2 x 5508 WLCs in place with around 50 APs split between the 2. As there is currently a low uptake of using wireless devices all of which we own I have up until now been using WPA2 and MAC filtering
-
Always pop up call back when try to call out from my iphone 5s Gold
While I try to make phone call it always pop up with call back. So what is the problem?
-
Lion installation says my hard drive is damaged, now my Mac won't turn on!
Help! I just purchased the new Lion software app and was downloading it to my iMac when out of the blue a message popped up saying that the software could not be installed because my hard drive is damaged and cannot be fixed! I now cannot even turn m
-
My macbook (aluminum 13inch) shuts down unexpectedly when battery 45%
hello there, my macbook 13inch-aluminum, 2 years old, shuts down unexpectedly when battery state is at about 45% and when an external hard drive (western digital passport 160gb) is connected, or an iphone on a usb port. This occurs only when my mac i