SlideShare a Scribd company logo
* @author GABYLUPI

*/

importjavax.swing.JEditorPane;

importjavax.swing.JFrame;

importjavax.swing.JScrollPane;

importjavax.swing.WindowConstants;

public class ejemplo1 {

public ejemplo1(){

try

      {

JFrame v = new JFrame("JEditorPane con HTML");

JEditorPane editor = new JEditorPane();

JScrollPane scroll = new JScrollPane(editor);

v.getContentPane().add(scroll);

v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);



editor.setContentType("text/html");



editor.setText(

            "<head><base href="file:d:/"></head>"+

             "<b>negrita</b>n<br>" + "<i>cursiva</i><cbr>" +

             "<font face="arial">fuentearial</font><br>" +

             "<font face="courier">fuente courier</font><br>" +

             "<font size="24">fuentegrande</font><br>" +

             "<font color="red">color rojo</font><br>" +

             "<imgsrc="imagesCAG2DOHB.jpg"></img>");




v.pack();

v.setVisible(true);

      }
catch (Exception e)

           {

e.printStackTrace();

}

     }



     /**

      * main de prueba

      *

      * @paramargs Se ignoran.

*/

public static void main(String[] args)

{

new ejemplo1();

     }

}
importjavax.swing.ImageIcon;

importjavax.swing.JButton;

importjavax.swing.JFrame;

importjavax.swing.JScrollPane;

importjavax.swing.JTextPane;

importjavax.swing.WindowConstants;

importjavax.swing.text.BadLocationException;

importjavax.swing.text.SimpleAttributeSet;

importjavax.swing.text.StyleConstants;

public class Ejemplo {

publicEjemplo (){

try

{

JFrame v = new JFrame("JTextPane");

JTextPane editor = new JTextPane();

JScrollPane scroll = new JScrollPane(editor);

v.getContentPane().add(scroll);

v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);



SimpleAttributeSetattrs = new SimpleAttributeSet();



StyleConstants.setBold(attrs, true);

editor.getStyledDocument()

            .insertString(

editor.getStyledDocument().getLength(), "Negrita", attrs);

insertaNuevaLinea(editor);



StyleConstants.setItalic(attrs, true);

StyleConstants.setBold(attrs, false);

editor.getStyledDocument()

            .insertString(
editor.getStyledDocument().getLength(), "cursiva", attrs);

insertaNuevaLinea(editor);

editor.setCaretPosition(editor.getStyledDocument().getLength());

JButtonboton = new JButton("Pulsame");

editor.insertComponent(boton);

v.pack();

v.setVisible(true); }

catch (Exception e) {

e.printStackTrace();         }   }

public static void main(String[] args)   {

newEjemplo();       }

private void insertaNuevaLinea(JTextPane editor)

throwsBadLocationException           {

editor.getStyledDocument()

            .insertString(

editor.getStyledDocument().getLength(),

System.getProperty("line.separator"), null);   }}

More Related Content

What's hot

Tipo music-ui-規劃原則
Tipo music-ui-規劃原則Tipo music-ui-規劃原則
Tipo music-ui-規劃原則LearningTech
 
JSF 2 and Ajax
JSF 2 and  AjaxJSF 2 and  Ajax
JSF 2 and Ajax
Jim Driscoll
 
Testování prakticky
Testování praktickyTestování prakticky
Testování prakticky
Filip Procházka
 
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
Future Processing
 
Testes unitários de JS com Jasmine e Karma
Testes unitários de JS com Jasmine e KarmaTestes unitários de JS com Jasmine e Karma
Testes unitários de JS com Jasmine e Karma
Douglas Matoso
 
Códigos anti-plágio para Blogger
Códigos anti-plágio para BloggerCódigos anti-plágio para Blogger
Códigos anti-plágio para BloggerKarol Rabêlo
 

What's hot (8)

Work flowtask
Work flowtaskWork flowtask
Work flowtask
 
Tipo music-ui-規劃原則
Tipo music-ui-規劃原則Tipo music-ui-規劃原則
Tipo music-ui-規劃原則
 
JSF 2 and Ajax
JSF 2 and  AjaxJSF 2 and  Ajax
JSF 2 and Ajax
 
Testování prakticky
Testování praktickyTestování prakticky
Testování prakticky
 
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
 
Cidigo
CidigoCidigo
Cidigo
 
Testes unitários de JS com Jasmine e Karma
Testes unitários de JS com Jasmine e KarmaTestes unitários de JS com Jasmine e Karma
Testes unitários de JS com Jasmine e Karma
 
Códigos anti-plágio para Blogger
Códigos anti-plágio para BloggerCódigos anti-plágio para Blogger
Códigos anti-plágio para Blogger
 

Viewers also liked

Create interactive calendar
Create interactive calendarCreate interactive calendar
Create interactive calendar
lchuch402
 
statics presetation on import and export of the country
statics presetation on import and export of the country statics presetation on import and export of the country
statics presetation on import and export of the country
Tanya Sharma
 
Carbonates equation animation
Carbonates equation animationCarbonates equation animation
Carbonates equation animation
ktschem76
 
Placement & links to all tests
Placement & links to all testsPlacement & links to all tests
Placement & links to all tests
lchuch402
 
Placementlinks updated06202013
Placementlinks updated06202013Placementlinks updated06202013
Placementlinks updated06202013
lchuch402
 
OnMyCalendar For Schools 111114
OnMyCalendar For Schools 111114OnMyCalendar For Schools 111114
OnMyCalendar For Schools 111114
OnMyCalendar
 
Emory Open Education Initiative overview presentation 03.19.14
Emory Open Education Initiative overview presentation 03.19.14Emory Open Education Initiative overview presentation 03.19.14
Emory Open Education Initiative overview presentation 03.19.14
lchuch402
 
Educació emocional (autoconeixement)
Educació emocional (autoconeixement)Educació emocional (autoconeixement)
Educació emocional (autoconeixement)
Anna Muma
 
Kfc project of intrntnl business
Kfc project of intrntnl businessKfc project of intrntnl business
Kfc project of intrntnl business
Tanya Sharma
 

Viewers also liked (9)

Create interactive calendar
Create interactive calendarCreate interactive calendar
Create interactive calendar
 
statics presetation on import and export of the country
statics presetation on import and export of the country statics presetation on import and export of the country
statics presetation on import and export of the country
 
Carbonates equation animation
Carbonates equation animationCarbonates equation animation
Carbonates equation animation
 
Placement & links to all tests
Placement & links to all testsPlacement & links to all tests
Placement & links to all tests
 
Placementlinks updated06202013
Placementlinks updated06202013Placementlinks updated06202013
Placementlinks updated06202013
 
OnMyCalendar For Schools 111114
OnMyCalendar For Schools 111114OnMyCalendar For Schools 111114
OnMyCalendar For Schools 111114
 
Emory Open Education Initiative overview presentation 03.19.14
Emory Open Education Initiative overview presentation 03.19.14Emory Open Education Initiative overview presentation 03.19.14
Emory Open Education Initiative overview presentation 03.19.14
 
Educació emocional (autoconeixement)
Educació emocional (autoconeixement)Educació emocional (autoconeixement)
Educació emocional (autoconeixement)
 
Kfc project of intrntnl business
Kfc project of intrntnl businessKfc project of intrntnl business
Kfc project of intrntnl business
 

Ejercicio progra