问题
I written a Java SWT (GUI) program to just display the shell window and I running it in Eclipse and I am using Fedora 17 operating system.
I am getting the output with maximize and minimize option missing in that window. But I tried it in Windows 7 and it gives me the correct output without missing anything.
Please anyone tell me that why is it missing in Fedora 17 and what is the solution to correct it?
This is the code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class Example {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display,SWT.MAX|SWT.MIN);
Label label1 = new Label(shell,SWT.NONE);
label1.setText("CLEAR IT OUT PLEASE");
label1.setBounds(50,30,200,30);
shell.pack ();
shell.setSize(315,200);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
回答1:
Fedora 17 uses GNOME 3.4, and if you are using GNOME 3 the default window manager (gnome shell) doesn't have minimize or maximize icons (I know, it is seriously stupid.) If that is indeed the problem you are having, try installing gnome-tweak-tool
on your distro:
https://askubuntu.com/questions/125765/how-do-i-add-minimize-maximize-buttons-to-gnome-shell-windows
If you read more about SWT, you'll see that it uses the native GUI libraries of host OSes to display graphical elements, hence you'll be subject to the whims of the window manager, which perhaps you wouldn't with something like Swing.
来源:https://stackoverflow.com/questions/15151538/why-maximize-and-minimize-option-is-missing-in-linux-but-working-in-windows