Editor de textos!!

Cyndi
06 de Octubre del 2005
Por favor si alguien me puede ayudar, me pidieron hacer un editor de textos en java, utilizando listas ligadas y ingresando por palabras...

juanortiz
06 de Octubre del 2005
fuente de un editor de textos, editor grafico y fuente para resolver ecuaciones lineales, cuadraticas.

Profesor
06 de Octubre del 2005
Hola Cyndi.
Te aconsejaria que comenzaras ha hacerlo y donde te quedes atrancada preguntes. Las personas que responden en el foro estan para responderte a cosas puntuales, no pretenderas que hagan todo tu trabajo. Chao

martin_sauces
06 de Octubre del 2005
Hay un ejemplo muy básico en la siguiente dirección:
http://www.dcc.uchile.cl/~lmateu/CC60H/Trabajos/edavis/ejemplo2.html
Creo que como punto de partida está bien, aunque deberás incluir otras opciones si quieres que sea potente de verdad. ¡que lo disfrutes!

jhonnybmx
06 de Octubre del 2005
esto te puede servir bastante :)

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Menu extends JFrame implements ActionListener{

public Container contenedor;
public FlowLayout miFlow;
public JTextArea miArea = new JTextArea(30,70);
public JScrollPane miScroll = new JScrollPane(miArea);


private String tipoletra;
private Color color=Color.lightGray;
private int tamaño=17;
JButton yoko=new JButton("yoko");

public JMenuBar bar;
public JToolBar barh;
public JLabel jtamaño,jcolor,jfondo,jfuente;
public JMenu menuFuente;
public JMenuItem item1, item2, item3, item4;
Font f,fuent;

public Menu(){

Container contenedor =getContentPane();
bar=new JMenuBar();
menuFuente = new JMenu("estilo de fuente");
menuFuente.setMnemonic('E');

item1 = new JMenuItem("Cursiva");
item2 = new JMenuItem("Negrita");
item3 = new JMenuItem("Normal");
item4 = new JMenuItem("Salir");
item4.setMnemonic('S');


barh=new JToolBar();
barh.add(yoko);
contenedor.add(barh);


Choice c =new Choice();
jtamaño=new JLabel("tamaño");
c.add("8");
c.add("9");
c.add("10");
c.add("11");
c.add("12");
c.add("14");
c.add("16");
c.add("18");
c.add("20");
c.add("22");
c.add("24");
c.add("26");
c.add("28");
c.add("36");
c.add("48");
c.add("72");
c.add("...");



Choice b=new Choice();
jcolor=new JLabel("Color Texto");

b.add("Negro");
b.add("Amarillo");
b.add("Azul");
b.add("Rojo");
b.add("Verde");
b.add("Rosa");
b.add("Azul elec");
b.add("Gris");
b.add("Naranja");
b.add("Fluorecente");
b.add("Mas colores");



Choice d=new Choice();
jfondo=new JLabel("Color Fondo");

d.add("blanco");
d.add("amarillo");
d.add("azul");
d.add("rojo");
d.add("verde");
d.add("rosa");
d.add("azul elec");
d.add("gris");
d.add("naranja");
d.add("fluorecente");
d.add("mas colores");

Choice f=new Choice();
jfuente=new JLabel("Estilo de fuente");

f.add("Arial");
f.add("Comic Sans MS");
f.add("Courier New");
f.add("Georgia");
f.add("Impact");
f.add("Lucida Console");
f.add("Modern");
f.add("Rockwell");
f.add("Tahoma");
f.add("Times Roman");
f.add("Symbol");
f.add("Verdana");
f.select("Tahoma");


b.addItemListener( new deItemListener(b));
c.addItemListener( new deItemListener(c));
d.addItemListener( new deItemListener(d));
f.addItemListener( new deItemListener(f));

setJMenuBar(bar);

barh.add(jtamaño);
barh.add(c);

barh.add(jcolor);
barh.add(b);

barh.add(jfondo);
barh.add(d);


barh.add(jfuente);
barh.add(f);


menuFuente.add(item1);
menuFuente.addSeparator();
menuFuente.add(item2);
menuFuente.addSeparator();
menuFuente.add(item3);
menuFuente.addSeparator();
menuFuente.add(item4);


item1.addActionListener(this);
item2.addActionListener(this);
item3.addActionListener(this);
item4.addActionListener(this);




bar.add(menuFuente);
setJMenuBar(bar);
contenedor = getContentPane();
miFlow = new FlowLayout();

contenedor.setLayout(miFlow);
contenedor.add(barh,BorderLayout.NORTH);
contenedor.add(miScroll);



}//fin constructor

public void paleta(){

color=JColorChooser.showDialog(this,"Elija color",color);
if(color==null){
color=Color.lightGray;
}
miArea.setForeground(color);
miArea.repaint();

}


public void paleta2(){

color=JColorChooser.showDialog(this,"Elija color",color);
if(color==null){
color=Color.lightGray;
}
miArea.setBackground(color);
miArea.repaint();

}




class deItemListener implements ItemListener{
Choice oChoice;

deItemListener( Choice choice ) {
oChoice=choice;
}


public void itemStateChanged( ItemEvent evt ) {

String op;
op=oChoice.getSelectedItem();


if(op.equals("Negro")){
miArea.setForeground(Color.black);
}


if(op.equals("Amarillo")){
miArea.setForeground(Color.yellow);
}



if(op.equals("Azul")){
miArea.setForeground(Color.blue);

}


if(op.equals("Rojo")){
miArea.setForeground(Color.red);
}




if(op.equals("Verde")){
miArea.setForeground(Color.green);
}



if(op.equals("Rosa")){
miArea.setForeground(Color.pink);
}


if(op.equals("Azul elec")){
miArea.setForeground(Color.cyan);
}


if(op.equals("Gris")){
miArea.setForeground(Color.gray);
}


if(op.equals("Naranja")){
miArea.setForeground(Color.orange);
}


if(op.equals("Fluorecente")){
miArea.setForeground(Color.magenta);
}

if(op.equals("Mas colores")){
paleta ();
}




if(op.equals("8")){
f=new Font(tipoletra,Font.PLAIN,8);
miArea.setFont(f);
tamaño=8;
}



if(op.equals("9")){
f=new Font(tipoletra,Font.PLAIN,9);
miArea.setFont(f);
tamaño=9;
}



if(op.equals("10")){
f=new Font(tipoletra,Font.PLAIN,10);
miArea.setFont(f);
tamaño=10;
}
if(op.equals("11")){
f=new Font(tipoletra,Font.PLAIN,11);
miArea.setFont(f);
tamaño=11;
}
if(op.equals("12")){
f=new Font(tipoletra,Font.PLAIN,12);
miArea.setFont(f);
tamaño=12;
}
if(op.equals("14")){
f=new Font(tipoletra,Font.PLAIN,14);
miArea.setFont(f);
tamaño=14;
}
if(op.equals("16")){
f=new Font(tipoletra,Font.PLAIN,16);
miArea.setFont(f);
tamaño=16;
}
if(op.equals("18")){
f=new Font(tipoletra,Font.PLAIN,18);
miArea.setFont(f);
tamaño=18;
}
if(op.equals("20")){
f=new Font(tipoletra,Font.PLAIN,20);
miArea.setFont(f);
tamaño=20;
}
if(op.equals("22")){
f=new Font(tipoletra,Font.PLAIN,22);
miArea.setFont(f);
tamaño=22;
}
if(op.equals("24")){
f=new Font(tipoletra,Font.PLAIN,24);
miArea.setFont(f);
tamaño=24;
}
if(op.equals("26")){
f=new Font(tipoletra,Font.PLAIN,26);
miArea.setFont(f);
tamaño=26;
}
if(op.equals("28")){
f=new Font(tipoletra,Font.PLAIN,28);
miArea.setFont(f);
tamaño=28;
}
if(op.equals("36")){
f=new Font(tipoletra,Font.PLAIN,36);
miArea.setFont(f);
tamaño=36;
}
if(op.equals("48")){
f=new Font(tipoletra,Font.PLAIN,48);
miArea.setFont(f);
tamaño=48;
}
if(op.equals("72")){
f=new Font(tipoletra,Font.PLAIN,72);
miArea.setFont(f);
tamaño=72;
}







if(op.equals("blanco")){
miArea.setBackground(Color.white);
}


if(op.equals("amarillo")){
miArea.setBackground(Color.yellow);
}



if(op.equals("azul")){
miArea.setBackground(Color.blue);

}


if(op.equals("rojo")){
miArea.setBackground(Color.red);
}




if(op.equals("verde")){
miArea.setBackground(Color.green);
}



if(op.equals("rosa")){
miArea.setBackground(Color.pink);
}


if(op.equals("azul elec")){
miArea.setBackground(Color.cyan);
}


if(op.equals("gris")){
miArea.setBackground(Color.gray);
}


if(op.equals("naranja")){
miArea.setBackground(Color.orange);
}


if(op.equals("fluorecente")){
miArea.setBackground(Color.magenta);
}

if(op.equals("mas colores")){
paleta2 ();
}



if(op.equals("Arial")){
f=new Font("Arial",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Arial";
}
if(op.equals("Comic Sans MS")){
f=new Font("Comic Sans MS",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Comic Sans MS";
}
if(op.equals("Courier New")){
f=new Font("Courier New",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Courier New";
}
if(op.equals("Impact")){
f=new Font("Impact",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Impact";
}
if(op.equals("Georgia")){
f=new Font("Georgia",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Georgia";
}
if(op.equals("Lucida Console")){
f=new Font("Lucida Console",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Lucida Console";
}
if(op.equals("Modern")){
f=new Font("Modern",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Modern";
}
if(op.equals("Rockwell")){
f=new Font("Rockwell",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Rockwell";
}
if(op.equals("Tahoma")){
f=new Font("Tahoma",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Tahoma";
}
if(op.equals("Times Roman")){
f=new Font("TimesRoman",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="TimesRoman";
}
if(op.equals("Symbol")){
f=new Font("Symbol",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Symbol";
}
if(op.equals("Verdana")){
f=new Font("Verdana",Font.PLAIN,tamaño);
miArea.setFont(f);
tipoletra="Verdana";
}






if(op.equals("...")){
tamaño=Integer.parseInt(JOptionPane.showInputDialog("Digite el tamaño de la fuente"));
f=new Font(tipoletra, Font.PLAIN, tamaño);
miArea.setFont(f);



}





}


}









public void actionPerformed(ActionEvent e){


if( e.getSource() == item1 ){
f=new Font(tipoletra, Font.ITALIC, tamaño);
miArea.setFont(f);
}

if( e.getSource() == item2 ){
f=new Font(tipoletra, Font.BOLD, tamaño);
miArea.setFont(f);
}


if( e.getSource() == item3 ){
f=new Font(tipoletra, Font.PLAIN, tamaño);
miArea.setFont(f);
}

if( e.getSource() == item4 ){
System.exit(0);


}


}//actionPerformed



public static void main(String arg[]){

Menu ventana = new Menu();
ventana.setSize( 800, 600 );
ventana.setResizable(false);
ventana.setTitle("mini word");
ventana.setLocation(50,50);
ventana.requestFocus();
ventana.setVisible(true);
ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}