Hi,
sorry, but I haven't been able to find a simpler solution for your LoadFile() question:
Probably a good point to improve the Jabaco framework implementation of RichTextBox.
Greetings
A1880
sorry, but I haven't been able to find a simpler solution for your LoadFile() question:
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Option Explicit
Import javax#swing#text#rtf
Public Sub Command1_Click()
Dim kit As RTFEditorKit
Dim doc As DefaultStyledDocument
Dim fis As FileInputStream
kit = Cast(RichTextBox1.Parent.getEditorKitForContentType("text/rtf"), RTFEditorKit)
doc = Cast(kit.createDefaultDocument, DefaultStyledDocument)
fis = New FileInputStream(New File("test.rtf"))
Call RichTextBox1.Parent.setEditorKit(kit)
Call kit.read(fis, doc, 0)
Call RichTextBox1.Parent.setDocument(doc)
fis.close
End Sub
|
Probably a good point to improve the Jabaco framework implementation of RichTextBox.
Greetings
A1880
This post has been edited 1 times, last edit by "A1880" (Jul 22nd 2009, 12:27pm)
@A1880: superspitzenmäßig!
@klctal:
The dialog "Imports" appears, in the box "Classname" type: DefaultStyledDocument and click "Find Class"
You see that it will be found in the namespace javax#swing#text, now just activate the checkbox left from the class and close the dialog
Alternatively you could also write into your Code:
Import javax#swing#text
above the line:
Import javax#swing#text#rtf
but then the whole namespace text will be imported, which is big.
regards OlimilO
@klctal:
in Jabaco klick the menuitem "Project"->"References (Classpath)"
Quoted
the DefaultStyledDocument class was not found
The dialog "Imports" appears, in the box "Classname" type: DefaultStyledDocument and click "Find Class"
You see that it will be found in the namespace javax#swing#text, now just activate the checkbox left from the class and close the dialog
Alternatively you could also write into your Code:
Import javax#swing#text
above the line:
Import javax#swing#text#rtf
but then the whole namespace text will be imported, which is big.
regards OlimilO
@A1880: habs mir nochmal angeschaut ...
@klctal: you could use this instead
regards
OlimilO
@klctal: you could use this instead
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Import javax#swing#text Import javax#swing#text#rtf Public Sub Command3_Click() CommonDialog1.ShowOpen If CommonDialog1.IsCanceled Then Exit Sub RichTextBox_LoadFile(RichTextBox1, CommonDialog1.FileName) End Sub Public Sub RichTextBox_LoadFile(RTB As RichTextBox, aFileName As String) Dim fis As New FileInputStream(aFileName) Dim doc As New DefaultStyledDocument(New StyleContext) Dim kit As New RTFEditorKit RTB.Parent.setEditorKit(kit) RTB.Parent.setDocument(doc) kit.read(fis, doc, 0) fis.close End Sub |
regards
OlimilO
Another thing:
I found out a way to read textfiles with more than one line:
I found out a way to read textfiles with more than one line:
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 |
Public Sub SingleLoad(FilePath As String) Dim FF As VBFileHandler Dim LineText As String FF = Open(FilePath) Do Until FF.EOF LineText = ReadLine(FF) TextMain.Text = TextMain.Text + LineText Loop FF.close() End Sub |
This post has been edited 1 times, last edit by "klctal" (Aug 13th 2009, 10:07am)
Similar threads
-
General topics, questions and discussions »-
Multi-line jbgrid header
(Jun 25th 2009, 1:10pm)
-
Tips, Tricks, Samples & Tutorials »-
How to create PDF-Documents with Jabaco and iText
(Apr 12th 2009, 10:51am)
-
Tips, Tricks, Samples & Tutorials »-
db2000 lightchat
(Feb 10th 2009, 5:47pm)
-
General topics, questions and discussions »-
Reading an INI File?
(Mar 10th 2009, 1:32am)
-
Tips, Tricks, Samples & Tutorials »-
db2000 TXT2PDF
(Jan 22nd 2009, 5:49pm)
