Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / Создание вручную HTMLDocument. / 1 сообщений из 1, страница 1 из 1
12.10.2006, 05:40:47
    #34048988
sysmanx
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Создание вручную HTMLDocument.
Вот попытался заполнить вручную HTMLDocument:
Код: plaintext
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.
			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TABLE);
			atrset.addAttribute(HTML.Attribute.BORDER,"1");
			atrset.addAttribute(HTML.Attribute.WIDTH,"100%");
//			atrset.addAttribute(StyleConstants.Bold, Boolean.TRUE);
//			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.B);
//			atrset.addAttribute(StyleConstants.Bold,"bold");

			ar[ 0 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.StartTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TR);
			ar[ 1 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.StartTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TD);
			ar[ 2 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.StartTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.CONTENT);
			ar[ 3 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.ContentType,ss1, 0 , 1 );


			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TD);
			ar[ 4 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.EndTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TD);
			ar[ 5 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.StartTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.CONTENT);
			ar[ 6 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.ContentType,ss2, 0 , 1 );


			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TD);
			ar[ 7 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.EndTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TR);
			ar[ 8 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.EndTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.TABLE);
			ar[ 9 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.EndTagType);

			atrset=  new  SimpleAttributeSet();
			atrset.addAttribute(StyleConstants.NameAttribute,HTML.Tag.CONTENT);
			ar[ 10 ]=  new  DefaultStyledDocument.ElementSpec(atrset,DefaultStyledDocument.ElementSpec.ContentType,ss3, 0 , 1 );


			 class  SD  extends  HTMLDocument{
				 public  SD(){
					 super ();
				}
				 public   void  create(DefaultStyledDocument.ElementSpec[] ar){
					 super .create(ar);
				}
				 public   void  insert( int  offset,DefaultStyledDocument.ElementSpec[] ar) throws  BadLocationException{
					 super .insert(offset,ar);
				}
			}

			SD sd =  new  SD();
			 try {
				sd.insert( 0 ,ar);
			} catch (BadLocationException ex){
				ex.printStackTrace(System.out);
			}
При выводе на экран (JEditorPane) некакого форматирования не происходит(верней таблица может и есть, но я её невижу так как нет бордера и она нерастянута), а при взятия текста gatText() получаю:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
<html>
  <head>

  </head>
  <body>
    <p style="margin-top: 0">
      <table border="1" width="100%">
        <tr>
          <td>
             1 
          </td>
          <td>
            a
          </td>
        </tr>
      </table>
       3 
    </p>
  </body>
</html>


Ктонибудб может подсказать, наверное я неправельно атрибуты <table> кладу.
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / Создание вручную HTMLDocument. / 1 сообщений из 1, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]