Accueil > > > BLOCNOTE TEXTAREA
BLOCNOTE TEXTAREA
Information sur la source
Description
Source
- /** Chiaramonti Julien
- Deust Gies
- Projet Informatique5
- Editeur de texte Java
- 30/08/02
- */
-
-
-
- /* ----------------INACTIF-----------------------------
-
- ->MenuItiem Annuler
- ->MenuItiem Imprmier runtime.getRuntime(execute("Print"))
-
-
- */
-
-
- import java.awt.*;
- import java.awt.event.*;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.util.*;
-
-
- public class WordbaD extends Frame implements WindowListener,ActionListener,ItemListener{
- TextArea TA;
- Font f;
- Button g;
- String message;
- String TAorig,TAactu;
- Choice cp;
- String NomFile="Sans Nom";
- String NomDirect="";
-
- public WordbaD() {
- message="Fichier Non Enregistrer";
- addWindowListener(this);
-
- setTitle(message+" - WordBaD - "+NomFile);
- setBackground(Color.white);
-
-
- /**---------------------------------------------------------------------------------------------------
- Construction d'une barre de menu
- ----------------------------------------------------------------------------------------------------*/
-
- MenuBar mb=new MenuBar();
-
-
- /**---------------------------------------------------------------------------------------------------
- Menu Fichier mf
- ---------------------------------------------------------------------------------------------------*/
- Menu mf=new Menu("Fichier");
- mb.add(mf);
- mf.addActionListener(this);
-
- /**--------------------------------------------------------------------------------------------------
- Commandes Menu Fichier
- --------------------------------------------------------------------------------------------------*/
-
- MenuItem mi;
-
- //MenuItem Nouveau
- mi=new MenuItem("Nouveau");
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_N));
- mf.add(mi);
-
- //MenuItem Ouvrir
- mi=new MenuItem("Ouvrir...");
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_O));
- mf.add(mi);
-
- //MenuItem Enregistrer
- mi=new MenuItem("Enregistrer");
- mf.add(mi);
-
- //MenuItem Enregistrer sous
- mi=new MenuItem("Enregistrer sous...");
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_S));
- mf.add(mi);
-
- //Séparateur
- mf.addSeparator();
-
- //MenuItem Imprimer
- mi=new MenuItem("Imprimer...");
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_P));
- mf.add(mi);
-
- //séparateur
- mf.addSeparator();
-
- //MenuItem Quitter
- mi=new MenuItem("Quitter");
- mf.add(mi);
- //raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
-
- /**--------------------------------------------------------------------------------------------------
- Menu Edition me
- --------------------------------------------------------------------------------------------------*/
-
- Menu me=new Menu("Edition");
- mb.add(me);
- me.addActionListener(this);
-
-
- /**--------------------------------------------------------------------------------------------------
- Commandes Menu Edition
- --------------------------------------------------------------------------------------------------*/
-
- //MenuItem Annuler
- mi=new MenuItem("Annuler");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_Z));
- me.add(mi);
-
- //Séparateur
- me.addSeparator();
-
- //MenuItem Couper
- mi=new MenuItem("Couper");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_X));
- me.add(mi);
-
- //MenuItem Copier
- mi=new MenuItem("Copier");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_C));
- me.add(mi);
-
- //MenuItem Coller
- mi=new MenuItem("Coller");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_V));
- me.add(mi);
-
- //Séparateur
- me.addSeparator();
-
- //MenuItem Selectionner tout
- mi=new MenuItem("Selectionner tout");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_A));
- me.add(mi);
-
- /**--------------------------------------------------------------------------------------------------
- Menu Affichage aff
- --------------------------------------------------------------------------------------------------*/
-
- Menu aff= new Menu("Affichage");
- mb.add(aff);
- aff.addActionListener(this);
-
- //MenuItem Couleur
- mi=new MenuItem("Police...");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_F));
- aff.add(mi);
-
- //Séparateur
- aff.addSeparator();
-
- //MenuItem Heure/Date
- mi=new MenuItem("Heure/Date");
-
- //Raccourci clavier pour cet item
- mi.setShortcut(new MenuShortcut(KeyEvent.VK_D));
- aff.add(mi);
-
- /**--------------------------------------------------------------------------------------------------
- Menu ? m
- --------------------------------------------------------------------------------------------------*/
-
- Menu m=new Menu("?");
- mb.add(m);
- m.addActionListener(this);
-
- /**--------------------------------------------------------------------------------------------------
- Commandes Menu ?
- --------------------------------------------------------------------------------------------------*/
- //MenuItem A propos...
- mi=new MenuItem("A propos...");
- m.add(mi);
-
- /**---------------------------------------------------------------------------------------------------
- Construction d'une barre d'outils
- ----------------------------------------------------------------------------------------------------*/
-
- Panel bo= new Panel();
- bo.setBackground(Color.gray);
-
-
- /**---------------------------------------------------------------------------------------------------
- Menu déroulant cp Couleur de la Police
- ----------------------------------------------------------------------------------------------------*/
-
- bo.add(new Label("Couleur police"));
- Choice cp= new Choice();
- cp.addItem("Noir"); cp.addItem("Gris");cp.addItem("Blanc"); cp.addItem("Vert");
- cp.addItem("Cyan"); cp.addItem("Jaune");cp.addItem("Bleu");cp.addItem("Rose");
- cp.addItem("Magenta"); cp.addItem("Rouge");cp.addItem("Orange");
- cp.addItemListener(this);
- bo.add(cp);
-
- /**---------------------------------------------------------------------------------------------------
- Menu déroulant sp Taille de la Police
- ----------------------------------------------------------------------------------------------------*/
-
- bo.add(new Label("Taille police"));
- Choice tp= new Choice();
- tp.addItem("10"); tp.addItem("12"); tp.addItem("14"); tp.addItem("16");
- tp.addItem("18"); tp.addItem("20"); tp.addItem("22"); tp.addItem("24");
- tp.addItem("26"); tp.addItem("28"); tp.addItem("36"); tp.addItem("48");
- tp.addItem("72");
- tp.addItemListener(this);
- bo.add(tp);
-
-
- bo.add(new Label("Style police"));
- Button g= new Button("Gras");g.addActionListener(this);bo.add(g);
- Button i = new Button("Italique");i.addActionListener(this); bo.add(i);
- Button s = new Button("Standard") ;s.addActionListener(this);bo.add(s);
- //Button gi = new Button("Gras Italique") ;gi.addActionListener(this); bo.add(gi);
-
-
- setIconImage(Toolkit.getDefaultToolkit().getImage("Collines.jpg"));
-
- setSize(500,350);
- setMenuBar(mb);
- add(bo,"North");
- /**---------------------------------------------------------------------------------------------------
- TextArea TA Zone de texte
- -----------------------------------------------------------------------------------------------------*/
-
- TA = new TextArea("", 10, 50, TextArea.SCROLLBARS_BOTH);
- TA.setEditable(true);
- f= new Font( "Dialog",Font.PLAIN,10);
- TA.setFont(f);
- TAorig=TA.getText();
- add(TA);
-
-
- }
-
- String selection = "";
-
- public void windowClosing(WindowEvent e) {System.exit(0);}
- public void windowClosed(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
-
- public TextArea myText(){ return TA;}
- public void actionPerformed(ActionEvent e) {
-
-
- TAactu=TA.getText();
- System.out.println("Debut actionoPerformed " + message + " "+TAorig.equals(TAactu) );
- //System.out.println("->"+TAactu+"<- ->"+TAorig+"<-");
- System.out.println("Nomfichier: "+">"+NomFile+"<"+" / Chemin fichier: "+">"+NomDirect+"<");
-
- if ( e.getActionCommand().equals("Nouveau") && !(TAorig.equals(TAactu)) ){
- try {
- System.out.println("Attention, je vais enregistrer un fichier");
- EnregistrerSous s= new EnregistrerSous(TA,this);
- message="Fichier Enregistrer";
- setTitle(message+" - WordbaD"+ " "+s.myFile());
- } catch (Exception exc) {
- System.out.println("Erreur dans Enregistrer Sous...");
- exc.printStackTrace();
- }
-
-
- }
-
- if ( e.getActionCommand().equals("Nouveau") && (TAorig.equals(TAactu)) ){
- TA.setText("");
- message="Fichier Non Enregistrer";
- setTitle("Fichier Non Enregistrer - WordbaD - Sans Nom");
-
-
- }
-
-
-
- if ( e.getActionCommand().equals("Ouvrir...") && !(TAorig.equals(TAactu) ) ){
- try {
- System.out.println("Ouvrir"+" Fichier Non Enregistrer "+" !(TAorig.equals(TAactu)) ");
- EnregistrerSous s= new EnregistrerSous(TA,this);
- message="Fichier Enregistrer";
- setTitle(message+" - WordbaD"+ " "+s.myFile());
- NomFile=s.myFile();
- NomDirect=s.myDirect();
- } catch (Exception exc) {
- System.out.println("Erreur dans Enregistrerif");
- exc.printStackTrace();
- }
- }
-
-
-
-
-
-
- if ( e.getActionCommand().equals("Ouvrir...") && (TAorig.equals(TAactu)) ){
- try {
- System.out.println("Attention je vais ouvrir un fichier et mon fichier actuel est inchangé ");
- Ouvrir o= new Ouvrir(TA,this);
- TAactu=TA.getText();
- message="Fichier Enregistrer";
- NomFile=o.myFile();
- NomDirect=o.myDirect();
- setTitle(message+" - WordbaD"+ " - "+o.myFile());
- } catch (Exception exc) {
- System.out.println("Erreur dans Enregistrer Sous...");
- exc.printStackTrace();
- }
-
- }
-
-
-
- if (e.getActionCommand().equals("Enregistrer") && message=="Fichier Non Enregistrer" ){
- try {
- System.out.println("Attention, je vais enregistrer un Fichier Non Enregistrer.");
- EnregistrerSous s= new EnregistrerSous(TA,this);
- message="Fichier Enregistrer";
- setTitle(message+" - WordbaD"+ " "+s.myFile());
- NomFile=s.myFile();
- NomDirect=s.myDirect();
- } catch (Exception exc) {
- System.out.println("Erreur dans Enregistrerif");
- exc.printStackTrace();
- }
- }
-
- if (e.getActionCommand().equals("Enregistrer") && message=="Fichier Enregistrer"){
- try{
- System.out.println("Attention, je vais ecraser un Fichier Enregistrer.");
- File fichier=new File(NomDirect,NomFile);
- FileWriter out= new FileWriter(fichier);
- out.write(TA.getText());
- out.close();
- }catch(Exception exc){
- System.out.println("Erreur dans Enregistrerelse");
- exc.printStackTrace();
- }
- }
-
- if (e.getActionCommand().equals("Enregistrer sous...")){
- try {
- System.out.println("Attention, je vais enregistrer un fichier");
- EnregistrerSous s= new EnregistrerSous(TA,this);
- message="Fichier Enregistrer";
- setTitle(message+" - WordbaD"+ " "+s.myFile());
- } catch (Exception exc) {
- System.out.println("Erreur dans Enregistrer Sous...");
- exc.printStackTrace();
- }
- }
-
-
- if (e.getActionCommand().equals("Imprimer...")) {System.out.println("Imprimer");}
-
- if (e.getActionCommand().equals("Quitter")) {System.exit(0);}
-
- if (e.getActionCommand().equals("Annuler")) {System.out.println("Annuler");}
-
- if (e.getActionCommand().equals("Coller")){TA.insert(selection, TA.getCaretPosition());}
- else if (e.getActionCommand().equals("Copier")) {selection = TA.getSelectedText();}
- else { selection = TA.getSelectedText();
- TA.replaceRange("", TA.getCaretPosition(), TA.getCaretPosition() + selection.length());
- }
-
- if(e.getActionCommand().equals("Selectionner tout"))TA.selectAll();
-
-
- if (e.getActionCommand().equals("Police...")){FModale2 f2= new FModale2(this, "Police... ", true);TA.setForeground(f2.getsonForeground());TA.setBackground(f2.getsonBackground());/*cp.select(f2.getsonForeground());*/}
-
- if (e.getActionCommand().equals("Heure/Date")){
- GregorianCalendar d = new GregorianCalendar();
- int heure = d.get(Calendar.HOUR);
- int min = d.get(Calendar.MINUTE);
- int sec = d.get(Calendar.SECOND);
- int mois = d.get(Calendar.MONTH) + 1;
- int annee = d.get(Calendar.YEAR) ;
- int aujourdhui = d.get(Calendar.DAY_OF_MONTH);
- TA.append(heure + ":" + min + " " + aujourdhui + "." + mois + "." + annee) ;
- }
-
- if (e.getActionCommand().equals("A propos...")) new FModale(this, "A propos... ", true);
-
- if(e.getActionCommand().equals("Italique")){f= new Font(f.getName(),Font.ITALIC,f.getSize());TA.setFont(f);}
- if(e.getActionCommand().equals("Gras")){f= new Font(f.getName(),Font.BOLD,f.getSize());TA.setFont(f);}
- if(e.getActionCommand().equals("Standard")){f= new Font(f.getName(),Font.PLAIN,f.getSize());TA.setFont(f);}
-
- TAorig=TAactu;
- System.out.println("Fin actionoPerformed " + message + " "+TAorig.equals(TAactu) );
- //System.out.println("->"+TAactu+"<- ->"+TAorig+"<-");
- System.out.println("Nomfichier: "+">"+NomFile+"<"+" / Chemin fichier: "+">"+NomDirect+"<");
-
-
-
-
-
-
-
- }
-
- public void itemStateChanged(ItemEvent e) {
-
- if( (String)e.getItem() == "Vert") TA.setForeground(Color.green);
- if( (String)e.getItem() == "Rouge")TA.setForeground(Color.red);
- if( (String)e.getItem() == "Jaune") TA.setForeground(Color.yellow);
- if( (String)e.getItem() == "Noir") TA.setForeground(Color.black);
- if( (String)e.getItem() == "Bleu") TA.setForeground(Color.blue);
- if( (String)e.getItem() == "Cyan") TA.setForeground(Color.cyan);
- if( (String)e.getItem() == "Magenta") TA.setForeground(Color.magenta);
- if( (String)e.getItem() == "Orange") TA.setForeground(Color.orange);
- if( (String)e.getItem() == "Rose") TA.setForeground(Color.pink);
- if( (String)e.getItem() == "Blanc") TA.setForeground(Color.white);
- if( (String)e.getItem() == "Gris") TA.setForeground(Color.gray);
-
- if( (String)e.getItem() == "10") { f= new Font(f.getName(),f.getStyle(),10); TA.setFont(f);}
- if( (String)e.getItem() == "12") { f= new Font( f.getName(),f.getStyle(),12); TA.setFont(f);}
- if( (String)e.getItem() == "14") {f= new Font( f.getName(),f.getStyle(),14); TA.setFont(f);}
- if( (String)e.getItem() == "16") {f= new Font( f.getName(),f.getStyle(),16);TA.setFont(f);}
- if( (String)e.getItem() == "18") {f= new Font( f.getName(),f.getStyle(),18);TA.setFont(f);}
- if( (String)e.getItem() == "20") {f= new Font( f.getName(),f.getStyle(),20);TA.setFont(f);}
- if( (String)e.getItem() == "22") {f= new Font( f.getName(),f.getStyle(),22); TA.setFont(f);}
- if( (String)e.getItem() == "24") {f= new Font( f.getName(),f.getStyle(),24);TA.setFont(f);}
- if( (String)e.getItem() == "26") {f= new Font( f.getName(),f.getStyle(),26);TA.setFont(f);}
- if( (String)e.getItem() == "28") {f= new Font( f.getName(),f.getStyle(),28);TA.setFont(f);}
- if( (String)e.getItem() == "36") {f= new Font(f.getName(),f.getStyle(),36);TA.setFont(f);}
- if( (String)e.getItem() == "48") {f= new Font( f.getName(),f.getStyle(),48);TA.setFont(f);}
- if( (String)e.getItem() == "72") {f= new Font( f.getName(),f.getStyle(),72);TA.setFont(f);}
- }
-
- public static void main(String args[]) {
- System.out.println("Chargement...");
- WordbaD W=new WordbaD();
- W.show();
- }
- }
- //fenetre A PROPOS DE WordbaD
-
- class FModale extends Dialog implements ActionListener,WindowListener {
-
- public FModale(Frame owner, String title, boolean modal) {
- super(owner, title, modal);
- setLayout(new FlowLayout());
- Button b;
- setBackground(Color.white);
- setSize(270,170);
- add(new Label("Chiaramonti - WordbaD"));
- add(new Label("Version 1.0"));
- add(new Label("Freeware - 2002 - CoolStuff Corporation"));
- add(b = new Button("OK"));
- b.addActionListener(this);
- addWindowListener(this);
- setBackground(Color.gray);
- setVisible(true);
- }
-
- public void actionPerformed(ActionEvent e) { setVisible(false); }
- public void windowClosing(WindowEvent e) {dispose();}
- public void windowClosed(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
-
- }
-
-
- /** Fenetre Ouvrir
- Ouvre un fichier
- */
-
- class Ouvrir extends FileDialog implements ActionListener,WindowListener {
- String NomFile,NomDirect;
- WordbaD frame;
-
- public Ouvrir(TextArea t, WordbaD frame) throws Exception {
- super(frame,"Ouvrir",FileDialog.LOAD);
- addWindowListener(this);
- setVisible(true);
- NomFile=getFile();
- NomDirect=getDirectory();
- File fichier=new File(NomDirect,NomFile);
- FileReader in=new FileReader(fichier);
- char[] data = new char[(int)fichier.length()];
- in.read(data);
- t.setText(new String(data));
- in.close();
- }
- public String myDirect(){ return NomDirect;}
- public String myFile() { return NomFile;}
- public void actionPerformed(ActionEvent e) { setVisible(false);}
- public void windowClosing(WindowEvent e) {dispose();}
- public void windowClosed(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
- //public void itemStateChanged(ItemEvent e){}
- }
-
- /** Fenetre Enregistrer Sous
-
- Enregistre un nouveau fichier
- */
-
- class EnregistrerSous extends FileDialog implements ActionListener,WindowListener{
- String NomFile,NomDirect;
- WordbaD frame;
-
- public EnregistrerSous(TextArea t,WordbaD frame) throws Exception {
- super(frame,"Enregistrer Sous...",FileDialog.SAVE);
- addWindowListener(this);
- setVisible(true);
- NomFile=getFile();
- NomDirect=getDirectory();
- File fichier=new File(NomDirect,NomFile);
- FileWriter out= new FileWriter(fichier);
- out.write(t.getText());
- out.close();
- }
- public String myDirect(){return NomDirect;}
- public String myFile() { return NomFile;}
- public void actionPerformed(ActionEvent e) { setVisible(false); }
- public void windowClosing(WindowEvent e) {dispose();}
- public void windowClosed(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
-
- }
-
-
-
- /** Fenetre Police...
- Selection de la couleur de la police et de la coukeur du fond d'ecran
- */
-
- class FModale2 extends Dialog implements ActionListener,WindowListener,ItemListener {
- Color sonBackground,sonForeground;
- TextArea TB;
-
- public FModale2(Frame owner, String title, boolean modal) {
- super(owner, title, modal);
- setLayout(new FlowLayout());
-
- /**---------------------------------------------------------------------------------------------------
- Menu déroulant czt Couleur de la Zone de texte
- ----------------------------------------------------------------------------------------------------*/
-
- add(new Label("Couleur de la Zone de Texte"));
- Choice czt= new Choice();
- czt.addItem("Blanc"); czt.addItem("Noir"); czt.addItem("Gris"); czt.addItem("Vert");
- czt.addItem("Cyan"); czt.addItem("Jaune");czt.addItem("Bleu");czt.addItem("Rose");
- czt.addItem("Magenta"); czt.addItem("Rouge");czt.addItem("Orange");
- czt.addItemListener(this);
- add(czt);
-
- /**---------------------------------------------------------------------------------------------------
- Menu déroulant cp Couleur de la Police
- ----------------------------------------------------------------------------------------------------*/
- add(new Label("Couleur du Texte"));
- //Choice cp
- Choice cp= new Choice();
- cp.addItem("Noir "); cp.addItem("Gris "); cp.addItem("Blanc "); cp.addItem("Vert ");
- cp.addItem("Cyan "); cp.addItem("Jaune ");cp.addItem("Bleu ");cp.addItem("Rose ");
- cp.addItem("Magenta "); cp.addItem("Rouge ");cp.addItem("Orange ");
- cp.addItemListener(this);
- add(cp);
-
- Button o,c;
- setBackground(Color.gray);
- setSize(350,300);
- TB = new TextArea(" Aperçu", 10, 50,TextArea.SCROLLBARS_NONE );
- TB.setEditable(false);
- Font f= new Font( "Dialog",Font.PLAIN,10);
- TB.setFont(f);
- add(TB);
-
-
- add(o = new Button("OK"));
- o.addActionListener(this);
- add(c = new Button("Annuler"));
- c.addActionListener(this);
- addWindowListener(this);
- setVisible(true);
- }
- public void actionPerformed(ActionEvent e) {
-
- if(e.getActionCommand().equals("OK")){
- sonForeground=TB.getForeground();
- sonBackground=TB.getBackground();
- dispose();
- }
-
- if(e.getActionCommand().equals("Annuler")){dispose();}
-
-
- }
-
- public Color getsonForeground(){return sonForeground;}
- public Color getsonBackground(){return sonBackground;}
- public void windowClosing(WindowEvent e) {dispose();}
- public void windowClosed(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
- public void itemStateChanged(ItemEvent e){
-
-
- if( e.getItem() == "Blanc") {TB.setBackground(Color.white); }
- if( (String)e.getItem() == "Vert") TB.setBackground(Color.green);
- if( (String)e.getItem() == "Rouge")TB.setBackground(Color.red);
- if( (String)e.getItem() == "Jaune") TB.setBackground(Color.yellow);
- if( (String)e.getItem() == "Noir") TB.setBackground(Color.black);
- if( (String)e.getItem() == "Bleu") TB.setBackground(Color.blue);
- if( (String)e.getItem() == "Cyan") TB.setBackground(Color.cyan);
- if( (String)e.getItem() == "Magenta") TB.setBackground(Color.magenta);
- if( (String)e.getItem() == "Orange") TB.setBackground(Color.orange);
- if( (String)e.getItem() == "Rose") TB.setBackground(Color.pink);
- if( (String)e.getItem() == "Gris") TB.setBackground(Color.gray);
-
- if( e.getItem() == "Blanc ") {TB.setForeground(Color.white); }
- if( (String)e.getItem() == "Vert ") TB.setForeground(Color.green);
- if( (String)e.getItem() == "Rouge ")TB.setForeground(Color.red);
- if( (String)e.getItem() == "Jaune ") TB.setForeground(Color.yellow);
- if( (String)e.getItem() == "Noir ") TB.setForeground(Color.black);
- if( (String)e.getItem() == "Bleu ") TB.setForeground(Color.blue);
- if( (String)e.getItem() == "Cyan ") TB.setForeground(Color.cyan);
- if( (String)e.getItem() == "Magenta ") TB.setForeground(Color.magenta);
- if( (String)e.getItem() == "Orange ") TB.setForeground(Color.orange);
- if( (String)e.getItem() == "Rose ") TB.setForeground(Color.pink);
- if( (String)e.getItem() == "Gris ") TB.setForeground(Color.gray);
- }
- }
-
-
/** Chiaramonti Julien
Deust Gies
Projet Informatique5
Editeur de texte Java
30/08/02
*/
/* ----------------INACTIF-----------------------------
->MenuItiem Annuler
->MenuItiem Imprmier runtime.getRuntime(execute("Print"))
*/
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.*;
public class WordbaD extends Frame implements WindowListener,ActionListener,ItemListener{
TextArea TA;
Font f;
Button g;
String message;
String TAorig,TAactu;
Choice cp;
String NomFile="Sans Nom";
String NomDirect="";
public WordbaD() {
message="Fichier Non Enregistrer";
addWindowListener(this);
setTitle(message+" - WordBaD - "+NomFile);
setBackground(Color.white);
/**---------------------------------------------------------------------------------------------------
Construction d'une barre de menu
----------------------------------------------------------------------------------------------------*/
MenuBar mb=new MenuBar();
/**---------------------------------------------------------------------------------------------------
Menu Fichier mf
---------------------------------------------------------------------------------------------------*/
Menu mf=new Menu("Fichier");
mb.add(mf);
mf.addActionListener(this);
/**--------------------------------------------------------------------------------------------------
Commandes Menu Fichier
--------------------------------------------------------------------------------------------------*/
MenuItem mi;
//MenuItem Nouveau
mi=new MenuItem("Nouveau");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_N));
mf.add(mi);
//MenuItem Ouvrir
mi=new MenuItem("Ouvrir...");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_O));
mf.add(mi);
//MenuItem Enregistrer
mi=new MenuItem("Enregistrer");
mf.add(mi);
//MenuItem Enregistrer sous
mi=new MenuItem("Enregistrer sous...");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_S));
mf.add(mi);
//Séparateur
mf.addSeparator();
//MenuItem Imprimer
mi=new MenuItem("Imprimer...");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_P));
mf.add(mi);
//séparateur
mf.addSeparator();
//MenuItem Quitter
mi=new MenuItem("Quitter");
mf.add(mi);
//raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
/**--------------------------------------------------------------------------------------------------
Menu Edition me
--------------------------------------------------------------------------------------------------*/
Menu me=new Menu("Edition");
mb.add(me);
me.addActionListener(this);
/**--------------------------------------------------------------------------------------------------
Commandes Menu Edition
--------------------------------------------------------------------------------------------------*/
//MenuItem Annuler
mi=new MenuItem("Annuler");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_Z));
me.add(mi);
//Séparateur
me.addSeparator();
//MenuItem Couper
mi=new MenuItem("Couper");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_X));
me.add(mi);
//MenuItem Copier
mi=new MenuItem("Copier");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_C));
me.add(mi);
//MenuItem Coller
mi=new MenuItem("Coller");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_V));
me.add(mi);
//Séparateur
me.addSeparator();
//MenuItem Selectionner tout
mi=new MenuItem("Selectionner tout");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_A));
me.add(mi);
/**--------------------------------------------------------------------------------------------------
Menu Affichage aff
--------------------------------------------------------------------------------------------------*/
Menu aff= new Menu("Affichage");
mb.add(aff);
aff.addActionListener(this);
//MenuItem Couleur
mi=new MenuItem("Police...");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_F));
aff.add(mi);
//Séparateur
aff.addSeparator();
//MenuItem Heure/Date
mi=new MenuItem("Heure/Date");
//Raccourci clavier pour cet item
mi.setShortcut(new MenuShortcut(KeyEvent.VK_D));
aff.add(mi);
/**--------------------------------------------------------------------------------------------------
Menu ? m
--------------------------------------------------------------------------------------------------*/
Menu m=new Menu("?");
mb.add(m);
m.addActionListener(this);
/**--------------------------------------------------------------------------------------------------
Commandes Menu ?
--------------------------------------------------------------------------------------------------*/
//MenuItem A propos...
mi=new MenuItem("A propos...");
m.add(mi);
/**---------------------------------------------------------------------------------------------------
Construction d'une barre d'outils
----------------------------------------------------------------------------------------------------*/
Panel bo= new Panel();
bo.setBackground(Color.gray);
/**---------------------------------------------------------------------------------------------------
Menu déroulant cp Couleur de la Police
----------------------------------------------------------------------------------------------------*/
bo.add(new Label("Couleur police"));
Choice cp= new Choice();
cp.addItem("Noir"); cp.addItem("Gris");cp.addItem("Blanc"); cp.addItem("Vert");
cp.addItem("Cyan"); cp.addItem("Jaune");cp.addItem("Bleu");cp.addItem("Rose");
cp.addItem("Magenta"); cp.addItem("Rouge");cp.addItem("Orange");
cp.addItemListener(this);
bo.add(cp);
/**---------------------------------------------------------------------------------------------------
Menu déroulant sp Taille de la Police
----------------------------------------------------------------------------------------------------*/
bo.add(new Label("Taille police"));
Choice tp= new Choice();
tp.addItem("10"); tp.addItem("12"); tp.addItem("14"); tp.addItem("16");
tp.addItem("18"); tp.addItem("20"); tp.addItem("22"); tp.addItem("24");
tp.addItem("26"); tp.addItem("28"); tp.addItem("36"); tp.addItem("48");
tp.addItem("72");
tp.addItemListener(this);
bo.add(tp);
bo.add(new Label("Style police"));
Button g= new Button("Gras");g.addActionListener(this);bo.add(g);
Button i = new Button("Italique");i.addActionListener(this); bo.add(i);
Button s = new Button("Standard") ;s.addActionListener(this);bo.add(s);
//Button gi = new Button("Gras Italique") ;gi.addActionListener(this); bo.add(gi);
setIconImage(Toolkit.getDefaultToolkit().getImage("Collines.jpg"));
setSize(500,350);
setMenuBar(mb);
add(bo,"North");
/**---------------------------------------------------------------------------------------------------
TextArea TA Zone de texte
-----------------------------------------------------------------------------------------------------*/
TA = new TextArea("", 10, 50, TextArea.SCROLLBARS_BOTH);
TA.setEditable(true);
f= new Font( "Dialog",Font.PLAIN,10);
TA.setFont(f);
TAorig=TA.getText();
add(TA);
}
String selection = "";
public void windowClosing(WindowEvent e) {System.exit(0);}
public void windowClosed(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public TextArea myText(){ return TA;}
public void actionPerformed(ActionEvent e) {
TAactu=TA.getText();
System.out.println("Debut actionoPerformed " + message + " "+TAorig.equals(TAactu) );
//System.out.println("->"+TAactu+"<- ->"+TAorig+"<-");
System.out.println("Nomfichier: "+">"+NomFile+"<"+" / Chemin fichier: "+">"+NomDirect+"<");
if ( e.getActionCommand().equals("Nouveau") && !(TAorig.equals(TAactu)) ){
try {
System.out.println("Attention, je vais enregistrer un fichier");
EnregistrerSous s= new EnregistrerSous(TA,this);
message="Fichier Enregistrer";
setTitle(message+" - WordbaD"+ " "+s.myFile());
} catch (Exception exc) {
System.out.println("Erreur dans Enregistrer Sous...");
exc.printStackTrace();
}
}
if ( e.getActionCommand().equals("Nouveau") && (TAorig.equals(TAactu)) ){
TA.setText("");
message="Fichier Non Enregistrer";
setTitle("Fichier Non Enregistrer - WordbaD - Sans Nom");
}
if ( e.getActionCommand().equals("Ouvrir...") && !(TAorig.equals(TAactu) ) ){
try {
System.out.println("Ouvrir"+" Fichier Non Enregistrer "+" !(TAorig.equals(TAactu)) ");
EnregistrerSous s= new EnregistrerSous(TA,this);
message="Fichier Enregistrer";
setTitle(message+" - WordbaD"+ " "+s.myFile());
NomFile=s.myFile();
NomDirect=s.myDirect();
} catch (Exception exc) {
System.out.println("Erreur dans Enregistrerif");
exc.printStackTrace();
}
}
if ( e.getActionCommand().equals("Ouvrir...") && (TAorig.equals(TAactu)) ){
try {
System.out.println("Attention je vais ouvrir un fichier et mon fichier actuel est inchangé ");
Ouvrir o= new Ouvrir(TA,this);
TAactu=TA.getText();
message="Fichier Enregistrer";
NomFile=o.myFile();
NomDirect=o.myDirect();
setTitle(message+" - WordbaD"+ " - "+o.myFile());
} catch (Exception exc) {
System.out.println("Erreur dans Enregistrer Sous...");
exc.printStackTrace();
}
}
if (e.getActionCommand().equals("Enregistrer") && message=="Fichier Non Enregistrer" ){
try {
System.out.println("Attention, je vais enregistrer un Fichier Non Enregistrer.");
EnregistrerSous s= new EnregistrerSous(TA,this);
message="Fichier Enregistrer";
setTitle(message+" - WordbaD"+ " "+s.myFile());
NomFile=s.myFile();
NomDirect=s.myDirect();
} catch (Exception exc) {
System.out.println("Erreur dans Enregistrerif");
exc.printStackTrace();
}
}
if (e.getActionCommand().equals("Enregistrer") && message=="Fichier Enregistrer"){
try{
System.out.println("Attention, je vais ecraser un Fichier Enregistrer.");
File fichier=new File(NomDirect,NomFile);
FileWriter out= new FileWriter(fichier);
out.write(TA.getText());
out.close();
}catch(Exception exc){
System.out.println("Erreur dans Enregistrerelse");
exc.printStackTrace();
}
}
if (e.getActionCommand().equals("Enregistrer sous...")){
try {
System.out.println("Attention, je vais enregistrer un fichier");
EnregistrerSous s= new EnregistrerSous(TA,this);
message="Fichier Enregistrer";
setTitle(message+" - WordbaD"+ " "+s.myFile());
} catch (Exception exc) {
System.out.println("Erreur dans Enregistrer Sous...");
exc.printStackTrace();
}
}
if (e.getActionCommand().equals("Imprimer...")) {System.out.println("Imprimer");}
if (e.getActionCommand().equals("Quitter")) {System.exit(0);}
if (e.getActionCommand().equals("Annuler")) {System.out.println("Annuler");}
if (e.getActionCommand().equals("Coller")){TA.insert(selection, TA.getCaretPosition());}
else if (e.getActionCommand().equals("Copier")) {selection = TA.getSelectedText();}
else { selection = TA.getSelectedText();
TA.replaceRange("", TA.getCaretPosition(), TA.getCaretPosition() + selection.length());
}
if(e.getActionCommand().equals("Selectionner tout"))TA.selectAll();
if (e.getActionCommand().equals("Police...")){FModale2 f2= new FModale2(this, "Police... ", true);TA.setForeground(f2.getsonForeground());TA.setBackground(f2.getsonBackground());/*cp.select(f2.getsonForeground());*/}
if (e.getActionCommand().equals("Heure/Date")){
GregorianCalendar d = new GregorianCalendar();
int heure = d.get(Calendar.HOUR);
int min = d.get(Calendar.MINUTE);
int sec = d.get(Calendar.SECOND);
int mois = d.get(Calendar.MONTH) + 1;
int annee = d.get(Calendar.YEAR) ;
int aujourdhui = d.get(Calendar.DAY_OF_MONTH);
TA.append(heure + ":" + min + " " + aujourdhui + "." + mois + "." + annee) ;
}
if (e.getActionCommand().equals("A propos...")) new FModale(this, "A propos... ", true);
if(e.getActionCommand().equals("Italique")){f= new Font(f.getName(),Font.ITALIC,f.getSize());TA.setFont(f);}
if(e.getActionCommand().equals("Gras")){f= new Font(f.getName(),Font.BOLD,f.getSize());TA.setFont(f);}
if(e.getActionCommand().equals("Standard")){f= new Font(f.getName(),Font.PLAIN,f.getSize());TA.setFont(f);}
TAorig=TAactu;
System.out.println("Fin actionoPerformed " + message + " "+TAorig.equals(TAactu) );
//System.out.println("->"+TAactu+"<- ->"+TAorig+"<-");
System.out.println("Nomfichier: "+">"+NomFile+"<"+" / Chemin fichier: "+">"+NomDirect+"<");
}
public void itemStateChanged(ItemEvent e) {
if( (String)e.getItem() == "Vert") TA.setForeground(Color.green);
if( (String)e.getItem() == "Rouge")TA.setForeground(Color.red);
if( (String)e.getItem() == "Jaune") TA.setForeground(Color.yellow);
if( (String)e.getItem() == "Noir") TA.setForeground(Color.black);
if( (String)e.getItem() == "Bleu") TA.setForeground(Color.blue);
if( (String)e.getItem() == "Cyan") TA.setForeground(Color.cyan);
if( (String)e.getItem() == "Magenta") TA.setForeground(Color.magenta);
if( (String)e.getItem() == "Orange") TA.setForeground(Color.orange);
if( (String)e.getItem() == "Rose") TA.setForeground(Color.pink);
if( (String)e.getItem() == "Blanc") TA.setForeground(Color.white);
if( (String)e.getItem() == "Gris") TA.setForeground(Color.gray);
if( (String)e.getItem() == "10") { f= new Font(f.getName(),f.getStyle(),10); TA.setFont(f);}
if( (String)e.getItem() == "12") { f= new Font( f.getName(),f.getStyle(),12); TA.setFont(f);}
if( (String)e.getItem() == "14") {f= new Font( f.getName(),f.getStyle(),14); TA.setFont(f);}
if( (String)e.getItem() == "16") {f= new Font( f.getName(),f.getStyle(),16);TA.setFont(f);}
if( (String)e.getItem() == "18") {f= new Font( f.getName(),f.getStyle(),18);TA.setFont(f);}
if( (String)e.getItem() == "20") {f= new Font( f.getName(),f.getStyle(),20);TA.setFont(f);}
if( (String)e.getItem() == "22") {f= new Font( f.getName(),f.getStyle(),22); TA.setFont(f);}
if( (String)e.getItem() == "24") {f= new Font( f.getName(),f.getStyle(),24);TA.setFont(f);}
if( (String)e.getItem() == "26") {f= new Font( f.getName(),f.getStyle(),26);TA.setFont(f);}
if( (String)e.getItem() == "28") {f= new Font( f.getName(),f.getStyle(),28);TA.setFont(f);}
if( (String)e.getItem() == "36") {f= new Font(f.getName(),f.getStyle(),36);TA.setFont(f);}
if( (String)e.getItem() == "48") {f= new Font( f.getName(),f.getStyle(),48);TA.setFont(f);}
if( (String)e.getItem() == "72") {f= new Font( f.getName(),f.getStyle(),72);TA.setFont(f);}
}
public static void main(String args[]) {
System.out.println("Chargement...");
WordbaD W=new WordbaD();
W.show();
}
}
//fenetre A PROPOS DE WordbaD
class FModale extends Dialog implements ActionListener,WindowListener {
public FModale(Frame owner, String title, boolean modal) {
super(owner, title, modal);
setLayout(new FlowLayout());
Button b;
setBackground(Color.white);
setSize(270,170);
add(new Label("Chiaramonti - WordbaD"));
add(new Label("Version 1.0"));
add(new Label("Freeware - 2002 - CoolStuff Corporation"));
add(b = new Button("OK"));
b.addActionListener(this);
addWindowListener(this);
setBackground(Color.gray);
setVisible(true);
}
public void actionPerformed(ActionEvent e) { setVisible(false); }
public void windowClosing(WindowEvent e) {dispose();}
public void windowClosed(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
}
/** Fenetre Ouvrir
Ouvre un fichier
*/
class Ouvrir extends FileDialog implements ActionListener,WindowListener {
String NomFile,NomDirect;
WordbaD frame;
public Ouvrir(TextArea t, WordbaD frame) throws Exception {
super(frame,"Ouvrir",FileDialog.LOAD);
addWindowListener(this);
setVisible(true);
NomFile=getFile();
NomDirect=getDirectory();
File fichier=new File(NomDirect,NomFile);
FileReader in=new FileReader(fichier);
char[] data = new char[(int)fichier.length()];
in.read(data);
t.setText(new String(data));
in.close();
}
public String myDirect(){ return NomDirect;}
public String myFile() { return NomFile;}
public void actionPerformed(ActionEvent e) { setVisible(false);}
public void windowClosing(WindowEvent e) {dispose();}
public void windowClosed(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
//public void itemStateChanged(ItemEvent e){}
}
/** Fenetre Enregistrer Sous
Enregistre un nouveau fichier
*/
class EnregistrerSous extends FileDialog implements ActionListener,WindowListener{
String NomFile,NomDirect;
WordbaD frame;
public EnregistrerSous(TextArea t,WordbaD frame) throws Exception {
super(frame,"Enregistrer Sous...",FileDialog.SAVE);
addWindowListener(this);
setVisible(true);
NomFile=getFile();
NomDirect=getDirectory();
File fichier=new File(NomDirect,NomFile);
FileWriter out= new FileWriter(fichier);
out.write(t.getText());
out.close();
}
public String myDirect(){return NomDirect;}
public String myFile() { return NomFile;}
public void actionPerformed(ActionEvent e) { setVisible(false); }
public void windowClosing(WindowEvent e) {dispose();}
public void windowClosed(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
}
/** Fenetre Police...
Selection de la couleur de la police et de la coukeur du fond d'ecran
*/
class FModale2 extends Dialog implements ActionListener,WindowListener,ItemListener {
Color sonBackground,sonForeground;
TextArea TB;
public FModale2(Frame owner, String title, boolean modal) {
super(owner, title, modal);
setLayout(new FlowLayout());
/**---------------------------------------------------------------------------------------------------
Menu déroulant czt Couleur de la Zone de texte
----------------------------------------------------------------------------------------------------*/
add(new Label("Couleur de la Zone de Texte"));
Choice czt= new Choice();
czt.addItem("Blanc"); czt.addItem("Noir"); czt.addItem("Gris"); czt.addItem("Vert");
czt.addItem("Cyan"); czt.addItem("Jaune");czt.addItem("Bleu");czt.addItem("Rose");
czt.addItem("Magenta"); czt.addItem("Rouge");czt.addItem("Orange");
czt.addItemListener(this);
add(czt);
/**---------------------------------------------------------------------------------------------------
Menu déroulant cp Couleur de la Police
----------------------------------------------------------------------------------------------------*/
add(new Label("Couleur du Texte"));
//Choice cp
Choice cp= new Choice();
cp.addItem("Noir "); cp.addItem("Gris "); cp.addItem("Blanc "); cp.addItem("Vert ");
cp.addItem("Cyan "); cp.addItem("Jaune ");cp.addItem("Bleu ");cp.addItem("Rose ");
cp.addItem("Magenta "); cp.addItem("Rouge ");cp.addItem("Orange ");
cp.addItemListener(this);
add(cp);
Button o,c;
setBackground(Color.gray);
setSize(350,300);
TB = new TextArea(" Aperçu", 10, 50,TextArea.SCROLLBARS_NONE );
TB.setEditable(false);
Font f= new Font( "Dialog",Font.PLAIN,10);
TB.setFont(f);
add(TB);
add(o = new Button("OK"));
o.addActionListener(this);
add(c = new Button("Annuler"));
c.addActionListener(this);
addWindowListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("OK")){
sonForeground=TB.getForeground();
sonBackground=TB.getBackground();
dispose();
}
if(e.getActionCommand().equals("Annuler")){dispose();}
}
public Color getsonForeground(){return sonForeground;}
public Color getsonBackground(){return sonBackground;}
public void windowClosing(WindowEvent e) {dispose();}
public void windowClosed(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void itemStateChanged(ItemEvent e){
if( e.getItem() == "Blanc") {TB.setBackground(Color.white); }
if( (String)e.getItem() == "Vert") TB.setBackground(Color.green);
if( (String)e.getItem() == "Rouge")TB.setBackground(Color.red);
if( (String)e.getItem() == "Jaune") TB.setBackground(Color.yellow);
if( (String)e.getItem() == "Noir") TB.setBackground(Color.black);
if( (String)e.getItem() == "Bleu") TB.setBackground(Color.blue);
if( (String)e.getItem() == "Cyan") TB.setBackground(Color.cyan);
if( (String)e.getItem() == "Magenta") TB.setBackground(Color.magenta);
if( (String)e.getItem() == "Orange") TB.setBackground(Color.orange);
if( (String)e.getItem() == "Rose") TB.setBackground(Color.pink);
if( (String)e.getItem() == "Gris") TB.setBackground(Color.gray);
if( e.getItem() == "Blanc ") {TB.setForeground(Color.white); }
if( (String)e.getItem() == "Vert ") TB.setForeground(Color.green);
if( (String)e.getItem() == "Rouge ")TB.setForeground(Color.red);
if( (String)e.getItem() == "Jaune ") TB.setForeground(Color.yellow);
if( (String)e.getItem() == "Noir ") TB.setForeground(Color.black);
if( (String)e.getItem() == "Bleu ") TB.setForeground(Color.blue);
if( (String)e.getItem() == "Cyan ") TB.setForeground(Color.cyan);
if( (String)e.getItem() == "Magenta ") TB.setForeground(Color.magenta);
if( (String)e.getItem() == "Orange ") TB.setForeground(Color.orange);
if( (String)e.getItem() == "Rose ") TB.setForeground(Color.pink);
if( (String)e.getItem() == "Gris ") TB.setForeground(Color.gray);
}
}
Conclusion
sous cmd compiler javac WordbaD.java executer java WordbaD
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
éditeur de texte évolué [ par predateuraud ]
Bonjour,je programme actuellement en java une sorte d'éditeur de texte un peu comme word mais à ma sauce. La zone de texte est en
Jlist ° JLabel -> Texte [ par Kickaha59 ]
Bonjour,Mon problème est le suivant, je passe des JLabel à une JList dans l'espoir qu'il m'affiche un icon et le texte associé, mais le résultat est t
Taille Texte Jlabel [ par eldiablo25 ]
Bonjour a tous,Je suis debutant et je voudrais savoir comment on fait pour ajuster le teste d'un jlabel à la taille de celui-ci. En gros je veux que m
changer texte dans jlabel pendant thread.sleep() [ par nwemba ]
Bonjour je suis debutant en java et j'aurai aimer savoir comment changer texte pendant ou avant thread.sleep()Voici ce que j'ai faitif (evt.getKeyCode
Boite de dialogue en java [ par chouki221 ]
Bonjour,Voila je voudrais ajouter ds mon pgm une boite de dialogue, qui permet a l'user de taper du texte, ensuite je dois récupérer ce texte et effec
lire et ecrire dans fichier texte en java [ par saif87 ]
Bonjour,je veut une aide a propos des fichier en java je veut sauvegarder mon travail dans un fichierexemple l'utilisateur entre le nom ,prénom,age...
JScrollPane [ par chris081 ]
Salut J'ai le code de newbee qui suit, mais le JTextArea ne s'affiche pas. Quelqu'un peut m'aider? import javax.swing.*; public class compteurChars
tempo sur JLabel [ par nwemba ]
Bonjour comment changer le texte d'un JLabel pendant 3 seconde.Par exemple le texte du JLabel est "bonjour" et si j'appuie sur une touche le texte dev
Créer un tooltiptext sur une zone de texte [ par Telemak67 ]
Bonjour à tous, comment faire pour créer un tooltiptext sur une zone de texte..?Je sais comment faire un tooltiptext lorsque la souris pointe sur un c
Comment connaître le style appliqué sur un texte d'un JTextPane (est-ce en gras, italique...) ? [ par cbil ]
Bonjour,J'aimerais savoir comment connaître le style qui est appliqué à un texte d'un JTextPane ?J'ai compris comment appliquer un style (mise en gras
|
Derniers Blogs
L'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIESL'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIES par odewit
La tendance est aux interfaces naturelles (NUI), et le keynote de Bill Buxton au MIX l'a bien souligné.
La charte graphique et ergonomique de Windows Phone 7 a donc été entièrement repensée en vue d'obtenir un maximum d'efficacité sur ce point. En re...
Cliquez pour lire la suite de l'article par odewit COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|