java


How to make window to be able to be thin in SWT?


Why doesn't the following application allow me to make window very thin? The minimal width allows to layout 3 columns of images while I wish to make one-column-wide possible.
How to allow narrowing more?
package tests;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class TryRowLayout {
public static void main(String[] args) {
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.wrap = true;
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setMinimumSize(1, 1);
//shell.setLayout(rowLayout);
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(rowLayout);
Image image = new Image(display, "images/alt_window_32.gif");
Label label;
for(int i=0; i<100; ++i) {
//label = new Label(shell, SWT.NONE);
label = new Label(composite, SWT.NONE);
label.setImage(image);
}
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
The reason for this is that Windows requires a minimal window width to be able to add the min/max/close buttons and the window title.
The default style of the Shell is
SWT.SHELL_TRIM = SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE
Unfortunately, you can't even get around this by forcing the Shell to just show the close button:
Shell shell = new Shell(display, SWT.CLOSE | SWT.RESIZE);
Windows will still enforce the minimal width.
Concluding, I'm afraid there is nothing you can do about it if you still require the window controls. If you don't need the window controls, then you can use
Shell shell = new Shell(display, SWT.RESIZE);
Here is example code:
public static void main(String[] args)
{
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.wrap = true;
Display display = new Display();
Shell shell = new Shell(display, SWT.RESIZE);
shell.setLayout(new FillLayout());
shell.setMinimumSize(1, 1);
// shell.setLayout(rowLayout);
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(rowLayout);
Label label;
for (int i = 0; i < 100; ++i)
{
// label = new Label(shell, SWT.NONE);
label = new Label(composite, SWT.NONE);
label.setText("A");
}
shell.pack();
shell.open();
shell.setSize(50, 200);
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
}
And this is what it looks like:

Related Links

How can I get a friend to stop thinking global and start thinking relative? [closed]
iOS - Java - Issue with Post that having unicode
Evaluating an arithmetic expression without delimiters [duplicate]
Issues with parsing JSON String to Java
Java Spring: Error creating bean
Getting a Color from a String input, getField
Call a Parent Method In Java
how to pass list of list values from jsp to servelet
encoding utf 8 java jdbc oracle
making post request throws nullpointerexception
Return statement within an if statement and printing it out to a file
Best way to serve image+html content to html page using servlet?
Query Dynamo table with only the secondary global index
How to bind map of custom objects using #RequestBody from JSON
Java calling Python (class, interface, or enum expected)
Semantic Versioning between Bamboo and Artifactory?

Categories

HOME
winforms
gerrit
reflection
drivers
pycharm
json.net
kalman-filter
v8
esper
add
vifm
tomcat6
export-to-csv
qt-creator
remote-access
event-handling
worldwind
serilog
flux
jprofiler
emulator
physics-engine
jndi
rundeck
buildbot
phpfox
spring-mybatis
publish
facebook-apps
tasklet
srcset
madlib
yadcf
pim
lxd
normal-distribution
fusionpbx
revolution-slider
objectlistview
temporary-files
preconditions
pdf-reactor
glew
sas-jmp
google-datalayer
youcompleteme
filepicker
logparser
clean-architecture
ionicons
rdfs
git-diff
tropo
pdfclown
dwscript
firmata
static-ip-address
color-picker
android-fonts
database-optimization
django-debug-toolbar
gstreamer-0.10
persist
lua-5.1
essence
fadeout
php-parse-error
netmq
energy
historian
ios8-today-widget
intel-fortran
ora-00900
pundit
coveralls
rgeo
deis
geonetwork
mdt
asp.net-web-api-odata
php-5.4
dml
htmlcleaner
datagridviewcolumn
gnu-smalltalk
farseer
coverflow
file-locking
jplaton
shellexecute
android-screen-support
interface-orientation
sharp-repository
simba
browser-detection
path-separator
bluepill
appconkit
enter
stage
joyent
f#-powerpack
gdlib
site.master
cxxtest
coda-slider
vc90
data-driven
temporal-database

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile