Witam.Pisze prosta przegladarke .Mam problem z pobraniem rozmiaru i polozenia okna glownego aby pozniej ustawic ten sam rozmiar
browser'a.
W starszych wersjach Eclipse dzialalo to bez problemu .Robilem to tak
Rectangle r=shell.getBounds();
browser.setBounds(r);
i dzialalo bez zadnych problemow.
Oczywiscie to bylo w zdarzeniu shell ControlResized.
Ponizej kod
import org.eclipse.swt.SWT;
public class Zadanie extends Shell {
private Text text;
int i=0;
/**
* Launch the application.
* @param args
*/
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Zadanie shell = new Zadanie(display);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the shell.
* @param display
*/
public Zadanie(final Display display) {
super(display, SWT.SHELL_TRIM);
Button btnNewButton = new Button(this, SWT.NONE);
btnNewButton.setBounds(10, 10, 68, 23);
btnNewButton.setText("Otworz");
text = new Text(this, SWT.BORDER);
text.setBounds(84, 14, 348, 19);
final Browser browser = new Browser(this, SWT.NONE);
browser.setBounds(0, 38, 442, 228);
final ProgressBar progressBar = new ProgressBar(this, SWT.NONE);
progressBar.setBounds(84, 14, 348, 19);
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
browser.setUrl(text.getText());
}
});
browser.addProgressListener(new ProgressAdapter() {
@Override
public void changed(ProgressEvent event) {
text.setVisible(false);
progressBar.setMaximum(event.total);
progressBar.setSelection(event.current);
if(event.total==event.current)
{
text.setVisible(true);
}
}
});
// tutaj jest problem
addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = null;
//r=shell.//getbounds powinno byc
browser.setBounds(r);
}
});
// tutaj sie konczy ;)
createContents();
}
/**
* Create contents of the shell.
*/
protected void createContents() {
setText("SWT Application");
setSize(450, 300);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}