ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
1666
1666
EMPFEHLEN
-
Hi,
ich bins mal wieder. ICh hab eine Verstaendnisfrage bezueglich des Text Widgets von SWT.
Ich lasse mir in folgender Klasse einen Text aus einem File in einen String einlesen und gebe diesen in ein Multi Text Widget.
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
public final class AboutDialog { private final static String resourcePic = "pixmaps/aboutPic.png"; private final static String resourceCredits = "org/gui/text/credits.txt"; private Image topImage; public AboutDialog(Shell shell){ int style = SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.TITLE; final Shell aboutShell = new Shell(shell,style); Display display = shell.getDisplay(); RowLayout layout = new RowLayout(); layout.type=SWT.VERTICAL; layout.fill=true; topImage = new Image(display,getClass().getResourceAsStream(resourcePic)); Label picLabel = new Label(aboutShell,SWT.NONE); picLabel.setImage(topImage); picLabel.pack(); TabFolder folder = new TabFolder(aboutShell,SWT.TOP); TabItem credits = new TabItem(folder,SWT.NONE); credits.setText("Credits"); Text creditText = new Text(folder,SWT.MULTI | SWT.V_SCROLL | SWT.None); creditText.insert(readTextFromFile(ClassLoader.getSystemResource(resourceCredits))); creditText.setEditable(true); //creditText.setSize(creditText.computeSize (width, height)); creditText.setSelection(creditText.getCharCount()); creditText.pack(); credits.setControl(creditText); TabItem license =new TabItem(folder,SWT.NONE); license.setText("Lizenz"); Label licenseLabel = new Label(folder,SWT.NONE); licenseLabel.setText("nochmal testweise"); //folder.setSize(400,300); folder.pack(); Button closeButton = new Button(aboutShell,SWT.PUSH); closeButton.setText("okay"); closeButton.addSelectionListener(new SelectionListener(){ public void widgetSelected(SelectionEvent e){ aboutShell.setVisible(false); aboutShell.dispose(); } public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } }); aboutShell.setLayout(layout); aboutShell.setText("Uber Hydra"); aboutShell.pack(); //aboutShell.setSize(400,600); aboutShell.open(); } private static String readTextFromFile(URL uri){ String s = ""; try{ BufferedReader input = new BufferedReader( new InputStreamReader(uri.openStream())); String line; while ((line = input.readLine()) != null){ s = s + line + "\n"; } input.close(); }catch(IOException e){ e.printStackTrace(System.out); } return s; } }
Das auch soweit, das Text Widget wird aber so gross, wie der String ist. Eine Goressenangabe des Text Widgets wird ignoriert. Wie mache ich das, das das text Widget sagen wir mal 300 Pixel hoch ist, sich in der Groesse nicht veraendert und der text dann gescrollt werden kann ?
Ich komm von gtk#, da ist das alles bisschen einfacher
.
CIh hab bestimmt nur was uebersehen - mehrere Augen sehen bekanntlich mehr als zwei
Gruss,
Demo
-
04.05.10 15:35 #2Landrus Tutorials.de Gastzugang
sdsdsdsdsdsdsdsds
Ähnliche Themen
-
Text-File Scanner
Von FingerSkill im Forum C/C++Antworten: 12Letzter Beitrag: 13.07.09, 12:55 -
*.csv Datei als Text-File öffnen
Von the_new_Engineer im Forum Visual Basic 6.0Antworten: 2Letzter Beitrag: 09.06.08, 15:44 -
Text über flash file
Von umbroboy im Forum Javascript & AjaxAntworten: 0Letzter Beitrag: 09.11.06, 21:27 -
Text-File od. XML
Von ParadiseCity im Forum .NET ArchivAntworten: 3Letzter Beitrag: 09.05.05, 12:19 -
file und text problem
Von seelenflug im Forum PHPAntworten: 2Letzter Beitrag: 26.07.04, 14:30





Zitieren
Login





