Can any bod sol thıs problem?

Hi..I wore some text editor ..and found some codes for highlighting ...My text editor has menu bar and 3 menus..Open ,save and exit..it works well. but in cods of highlighting there is a window too whit out any menubar..ext..I want to use my window with menubar instead of this window...i tryed to connecet them ..but allways i see window of SyntaxText class... What I must do? My class which i wrote JText ..i must delete some thing but i couldnt find..does any body can help me?
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
class SyntaxTest extends DefaultStyledDocument
Element rootElement;
String wordSeparators = ",:;.()[]{}+-/*%=!&|~^@? ";
Vector keywords = new Vector();;
SimpleAttributeSet keyword;
public SyntaxTest()
rootElement= this.getDefaultRootElement();
keyword = new SimpleAttributeSet();
StyleConstants.setForeground(keyword, Color.blue);
keywords.add( "abstract" );
keywords.add( "boolean" );
keywords.add( "break" );
keywords.add( "byte" );
keywords.add( "case" );
keywords.add( "catch" );
keywords.add( "char" );
keywords.add( "class" );
keywords.add( "continue" );
keywords.add( "default" );
keywords.add( "do" );
keywords.add( "double" );
keywords.add( "else" );
keywords.add( "extends" );
keywords.add( "false" );
keywords.add( "final" );
keywords.add( "finally" );
keywords.add( "float" );
keywords.add( "for" );
keywords.add( "if" );
keywords.add( "implements" );
keywords.add( "import" );
keywords.add( "instanceof" );
keywords.add( "int" );
keywords.add( "interface" );
keywords.add( "long" );
keywords.add( "native" );
keywords.add( "new" );
keywords.add( "null" );
keywords.add( "package" );
keywords.add( "private" );
keywords.add( "protected" );
keywords.add( "public" );
keywords.add( "return" );
keywords.add( "short" );
keywords.add( "static" );
keywords.add( "super" );
keywords.add( "switch" );
keywords.add( "synchronized" );
keywords.add( "this" );
keywords.add( "throw" );
keywords.add( "throws" );
keywords.add( "true" );
keywords.add( "try" );
keywords.add( "void" );
keywords.add( "volatile" );
keywords.add( "while" );
public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
super.insertString(offset, str, a);
int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+str.length())).getEndOffset() -1;
//highlight the changed line
highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
public void remove(int offset, int length) throws BadLocationException
super.remove(offset, length);
int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+length)).getEndOffset() -1;
//highlight the changed line
highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
public void highlightKeyword(String content,int startOffset, int endOffset)
char character;
int tokenEnd;
while (startOffset < endOffset)
tokenEnd = startOffset;
//find next wordSeparator
while(tokenEnd < endOffset)
character = content.charAt(tokenEnd);
if(wordSeparators.indexOf(character) > -1)
break;
else
tokenEnd++;
//check for keyword
String token = content.substring(startOffset,tokenEnd).trim();
if(keywords.contains(token))
this.setCharacterAttributes(startOffset, token.length(), keyword, true);
startOffset = tokenEnd+1;
public class JText extends JFrame{
     private JTextPane textarea ;
     private JFileChooser fileChooser = new JFileChooser();
private Action open =new OpenAction() ;
private Action save = new SaveAction();
private Action exit = new ExitAction();
public static void main(String args[])
     JFrame f = new JFrame();
     JTextPane pane = new JTextPane(new SyntaxTest());
     JScrollPane scrollPane = new JScrollPane(pane);
     f.setContentPane(scrollPane);
     f.setSize(600,400);
     f.setVisible(true);
     //Text Area
     public JText(){
     JPanel content = new JPanel();
     //Menu Bar
JMenuBar menu=new JMenuBar();
JMenu file=menu.add(new JMenu("FILE"));
file.setMnemonic('F');
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
setContentPane(content);
setJMenuBar(menu);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Project");
pack();
setLocationRelativeTo(null);
setVisible(true);
     class OpenAction extends AbstractAction {
     //============================================= constructor
     public OpenAction() {
     super("Open...");
     putValue(MNEMONIC_KEY, new Integer('O'));
     //========================================= actionPerformed
     public void actionPerformed(ActionEvent e) {
     int retval = fileChooser.showOpenDialog(JText.this);
     if (retval == JFileChooser.APPROVE_OPTION) {
     File f = fileChooser.getSelectedFile();
     try {
     FileReader reader = new FileReader(f);
     textarea.read(reader, ""); // Use TextComponent read
     } catch (IOException ioex) {
     System.out.println(e);
     System.exit(1);
          class SaveAction extends AbstractAction {
          //============================================= constructor
          SaveAction() {
          super("Save...");
          putValue(MNEMONIC_KEY, new Integer('S'));
          //========================================= actionPerformed
          public void actionPerformed(ActionEvent e) {
          int retval = fileChooser.showSaveDialog(JText.this);
          if (retval == JFileChooser.APPROVE_OPTION) {
          File f = fileChooser.getSelectedFile();
          try {
          FileWriter writer = new FileWriter(f);
          textarea.write(writer); // Use TextComponent write
          } catch (IOException ioex) {
          JOptionPane.showMessageDialog(JText.this, ioex);
          System.exit(1);
               class ExitAction extends AbstractAction {
               //============================================= constructor
               public ExitAction() {
               super("Exit");
               putValue(MNEMONIC_KEY, new Integer('X'));
               //========================================= actionPerformed
               public void actionPerformed(ActionEvent e) {
               System.exit(0);
}

import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
class SyntaxTest extends DefaultStyledDocument
Element rootElement;
String wordSeparators = ",:;.()[]{}+-/*%=!&|~^@? ";
Vector keywords = new Vector();;
SimpleAttributeSet keyword;
public SyntaxTest()
rootElement= this.getDefaultRootElement();
keyword = new SimpleAttributeSet();
StyleConstants.setForeground(keyword, Color.blue);
keywords.add( "abstract" );
keywords.add( "boolean" );
keywords.add( "break" );
keywords.add( "byte" );
keywords.add( "case" );
keywords.add( "catch" );
keywords.add( "char" );
keywords.add( "class" );
keywords.add( "continue" );
keywords.add( "default" );
keywords.add( "do" );
keywords.add( "double" );
keywords.add( "else" );
keywords.add( "extends" );
keywords.add( "false" );
keywords.add( "final" );
keywords.add( "finally" );
keywords.add( "float" );
keywords.add( "for" );
keywords.add( "if" );
keywords.add( "implements" );
keywords.add( "import" );
keywords.add( "instanceof" );
keywords.add( "int" );
keywords.add( "interface" );
keywords.add( "long" );
keywords.add( "native" );
keywords.add( "new" );
keywords.add( "null" );
keywords.add( "package" );
keywords.add( "private" );
keywords.add( "protected" );
keywords.add( "public" );
keywords.add( "return" );
keywords.add( "short" );
keywords.add( "static" );
keywords.add( "super" );
keywords.add( "switch" );
keywords.add( "synchronized" );
keywords.add( "this" );
keywords.add( "throw" );
keywords.add( "throws" );
keywords.add( "true" );
keywords.add( "try" );
keywords.add( "void" );
keywords.add( "volatile" );
keywords.add( "while" );
public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
super.insertString(offset, str, a);
int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+str.length())).getEndOffset() -1;
//highlight the changed line
highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
public void remove(int offset, int length) throws BadLocationException
super.remove(offset, length);
int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+length)).getEndOffset() -1;
//highlight the changed line
highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
public void highlightKeyword(String content,int startOffset, int endOffset)
char character;
int tokenEnd;
while (startOffset < endOffset)
tokenEnd = startOffset;
//find next wordSeparator
while(tokenEnd < endOffset)
character = content.charAt(tokenEnd);
if(wordSeparators.indexOf(character) > -1)
break;
else
tokenEnd++;
//check for keyword
String token = content.substring(startOffset,tokenEnd).trim();
if(keywords.contains(token))
this.setCharacterAttributes(startOffset, token.length(), keyword, true);
startOffset = tokenEnd+1;
public class JText extends JFrame{
private JTextPane textarea ;
private JFileChooser fileChooser = new JFileChooser();
private Action open =new OpenAction() ;
private Action save = new SaveAction();
private Action exit = new ExitAction();
public static void main(String args[])
JFrame f = new JFrame();
JTextPane pane = new JTextPane(new SyntaxTest());
JScrollPane scrollPane = new JScrollPane(pane);
f.setContentPane(scrollPane);
f.setSize(600,400);
f.setVisible(true);
//Text Area
public JText(){
JPanel content = new JPanel();
//Menu Bar
JMenuBar menu=new JMenuBar();
JMenu file=menu.add(new JMenu("FILE"));
file.setMnemonic('F');
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
setContentPane(content);
setJMenuBar(menu);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Project");
pack();
setLocationRelativeTo(null);
setVisible(true);
class OpenAction extends AbstractAction {
//============================================= constructor
public OpenAction() {
super("Open...");
putValue(MNEMONIC_KEY, new Integer('O'));
//========================================= actionPerformed
public void actionPerformed(ActionEvent e) {
int retval = fileChooser.showOpenDialog(JText.this);
if (retval == JFileChooser.APPROVE_OPTION) {
File f = fileChooser.getSelectedFile();
try {
FileReader reader = new FileReader(f);
textarea.read(reader, ""); // Use TextComponent read
} catch (IOException ioex) {
System.out.println(e);
System.exit(1);
class SaveAction extends AbstractAction {
//============================================= constructor
SaveAction() {
super("Save...");
putValue(MNEMONIC_KEY, new Integer('S'));
//========================================= actionPerformed
public void actionPerformed(ActionEvent e) {
int retval = fileChooser.showSaveDialog(JText.this);
if (retval == JFileChooser.APPROVE_OPTION) {
File f = fileChooser.getSelectedFile();
try {
FileWriter writer = new FileWriter(f);
textarea.write(writer); // Use TextComponent write
} catch (IOException ioex) {
JOptionPane.showMessageDialog(JText.this, ioex);
System.exit(1);
class ExitAction extends AbstractAction {
//============================================= constructor
public ExitAction() {
super("Exit");
putValue(MNEMONIC_KEY, new Integer('X'));
//========================================= actionPerformed
public void actionPerformed(ActionEvent e) {
System.exit(0);
}

Similar Messages

  • IPhone 5 locksreen is green. Do any bod have the same problem?

    When my iphone is locked and i press the homebutton i get a green shine under the slider. Is this normal or should i send my iphone back?

    Battery life will depend heavily on what you're doing with it. The advertised battery life is a maximum, achievable through extreme measures like turning off wifi and Bluetooth, turning the screen brightness to minimum, turning the sound off and running only very low-demand apps. If you're getting up to 6 hours while not maximizing your power-savings, you're not seeing anything unusual.

  • Trying to attach my time capsule to my cable modem box, which is a Virgin media Scientific Atlanta box. Problem is the apple set up tells my to put in the IP address for the virgin cable modem, which I cannot find. Can any on assist?

    can any one help with is problem.

    In what screen of what application are you asked to enter that IP address?  The only place I'd expect to see such a prompt is to let AirPort Utility access another AirPort base station.  Your Scientific Atlanta box isn't one.
    By the way, you've been misled by poor field labeling on this forum into typing a large part of your message into the field intended for the subject.  In the future just type a short summary of your post into that field and type the whole message into the field below that.

  • Safari keeps crashing every time I try to open a link from a different application, i.e. Mail. The trouble report says that some problem occurs with libcooliris.dylib plug-in. Can any one help?

    Safari keeps crashing every time I try to open a link from a different application, i.e. Mail. The trouble report says that some problem occurs with libcooliris.dylib plug-in. Can any one help?
    Thanks!

    Dear Linc,
    Thank you for the advice, John Blanchard1  and Linc Davis
    As suggested in your reference thread I removed "/Library/Printers/hp/PDEs/hpPostScriptPDE.plugin" and the problem has been resolved.
    I am guessing the the plug-in for the hp printers got corrupted and effected every thing, or became unsuitable when I installed an Apple update. I would be most grateful if you can confirm how the problem was coursed so I can understand and learn from this experiance.
    Ash

  • Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    You might find useful information in item D1 of Time Machine Troubleshooting.

  • Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Go to Settings/General/Reset - Erase all content and settings. the connecto to iTunes and restore as a New phone. Do not restore any backup. If the problem persists you have a hardware problem. Take it to Apple for exchange.
    This assumes that the phone is not hacked or jailbroken. If it is you will have to go elsewhere on the internet for help.

  • Can you help I was having problems with my iPod so I restored it but I accidentally set it up as a new iPod is there any way to restore it from an old  backup when I right click iPod in iTunes there isn't one anyway to recover one or find it on computer

    Hi can you help I was having problems with my iPod so I restored it but I
    accidentally set it up as a new iPod is there any way to restore it from an old
    backup when I right click iPod in iTunes there isn't one anyway to recover one
    or find it on computer

    The following says how to restore from backup.
    iOS: How to back up
    If you go to iTunes>Preferences>Devices you can see if you have an iTunes backup. You need one dated before or the exact time you started the restore.

  • My iPhone 3gs is not recognized by my PC or iTunes and i can't open it. Any idea what's the problem?

    My iPhone 3gs is not recognized by my PC or iTunes and i can't open it. Any idea what's the problem?

    I had the same problem with my phone, its a 3gs, out of no where my laptop stop recognizing it and wouldnt charge either, i got worried because i had all my pix and videos on my phone and didn't have a copy, so i started searching on the internet for an answer to my issue, bought extra usb cables, used different laptops and nothing worked .. Untill i took my cell phone apart and thought about replacing the (charge port assembly for apple Iphone 3gs) so ordered the part online and 3 days later got it and i just replaced it right now... and guess what/??? IT WORKED!!! YEAP.. NOW MY CELL IS CHARGING AND I JUST SYNC MY STUFF.. I HOPE THIS CAN SOLVE YOUR PROBLEM... AND ONLY COST ME 8 DLLS

  • I can't get any contact info for installation problem- I just bought a Mac Air and my CS5 is asking for a reinstall. Mac Air has no DVD slots. HELP I al VERY FRUSTRATED THAT ADOBE HAS NO WAY TO GET HELP

    I can't get any contact info for installation problem- I just bought a Mac Air and my CS5 is asking for a reinstall. Mac Air has no DVD slots. HELP I al VERY FRUSTRATED THAT ADOBE HAS NO WAY TO GET HELP

    You are right, Adobe does not support CS5 because it is no longer sold.
    Simply download the trial version of CS5 from this Adobe web site and input your serial number.
    Adobe - Photoshop : For Macintosh

  • I have an Iphone 5S and used to sync it to my computer in the past without any problem, but now I can't and appears the message "usb device not recognized", and the cable is good and so the USB port. Do you have any idea what's the problem?

    I have an Iphone 5S and used to sync it to my computer in the past without any problem, but now I can't, and appears the message "usb device not recognized", and the cable is good and so the USB port. Do you have any idea what's the problem?

    Try leaving it plugged in and then restart the computer.
    If you are on Windows this link may help but it is a bit old.
    http://www.technologynext.org/error-usb-device-not-recognized-how-to-fix/

  • Hey, I had met a problem with installation. Can any one help me?

    Hi everyone, I'm an user of Windows 7(64 bit),
    I had just download "Master Collection CS5.5"
    Everything are fine but Adobe Acrobat Professional can't install on my computer.
    There are the details..:
    Exit Code: 6
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 4 error(s), 1 warning(s)
    WARNING: DW066: OS requirements not met for {AC76BA86-1033-F400-7760-000000000005}
    ----------- Payload: {AC76BA86-1033-F400-7760-000000000005} Acrobat Professional 10.0.0.0 -----------
    ERROR: Error 1324.The path R嶰up廨er un document num廨is?sur un multifonction.sequ or the volume is invalid. Please enter it again.
    ERROR: Install MSI payload failed with error: 1603 - 安裝時發生嚴重錯誤。
    MSI Error message: Error 1324.The path R嶰up廨er un document num廨is?sur un multifonction.sequ or the volume is invalid. Please enter it again.
    ERROR: DW050: The following payload errors were found during install:
    ERROR: DW050:  - Acrobat Professional: Install failed
    Thanks

    Re: Hey, I had met a problem with installation. Can any one help me?
    This worked for an English version and the concept should work with all Adobe programs - new or old (hopefully in any language). My guess is that you have/had an older version of Acrobat/Reader on your computer hard drive that needs to be *completely* removed first. Uninstall the new (and any old) Acrobat; then try using the "kb2..." guideline link below before reinstalling the new Acrobat. I am including the lengthy instructions in order to help others with more extensive installation problems. Good luck!
    I live on a fixed income and use CS for a hobby. I had problem installing Adobe Creative Suite (CS1) to Windows 7 64-bit Pro on my new computer. Also installed Adobe Photoshop LR3. What I learned: All Adobe products (Flash, Acrobat/Reader, Photoshop, Creative Suites, etc.) leave a VERY pervasive footprint on your hard drive. Logic finally worked for me.... think of building a house; there is an order you have to do things in. First, you have to clean the area before laying the foundation; then you have to build the framework before you put the roof on. You cannot install an older program over ANY newer program; and you will sometimes have a problem installing a newer program containing Flash, Reader, etc. unless you "erase" the older versions of Flash, Reader beforehand. If installing older programs, do a Custom/Manual install; do not install older versions of Flash, Reader, etc.  packaged with your Adobe software.
    SOLUTION (not easy, but it works):
    I first tried this; it did not solve my problem (but, if applicable, may help others).  http://windows.microsoft.com/en-us/windows7/Make-older-programs-run-in-this-version-of-Win dows
    Before doing anything, make document and any database/presets/cache back-ups beforehand (keep notes on their designated location*); manually create a System Restore point. (Be prepared to reinstall Windows if necessary - I didn't have to.)
    Completely and meticulously eradicate (clean) your hard drive of ALL Adobe programs [uninstall, remove remaining folders, and remove only the registry entries that have the Adobe name attached (unless you are an expert and fully understand the other entries)]. Use this as a guideline  http://kb2.adobe.com/cps/400/kb400769.html
    Do a Custom/Manual reinstall of all your Adobe products *in order of release dates* (OLDEST first).... do not include Reader, Flash, etc. If your CD will not automatically run at this point, click "Open folder to view files" (use Computer/Windows Explorer, if necessary). Click "Adobe Creative Suite (or your desired program) ==> Setup.exe" (IMPORTANT: Make sure that Reader, Flash, etc. are unchecked.)
    After each of your desired Adobe programs are installed, test to insure they boot up. Then download the latest Reader, Flash, etc. apps and install them (I did this in order of release date - oldest first). Do test boot(s) again.
    Copy/Paste your document and any database/presets/cache back-ups into the appropriate folders (*this will vary depending on your programs and your filing system).
    It has been four weeks and all my Adobe programs work flawlessly - system is stable, no problems!

  • My Imac is ejecting every disk inserted in it, I cannot access the disks, can any body help me troubleshoot the problem. I am using snow leopard.

    My Imac is ejecting every disk inserted in it, I cannot access the disks, can any body help me troubleshoot the problem. I am using snow leopard.

    Try resetting the SMC Intel-based Macs: Resetting the System Management Controller (SMC) - Apple Support
    and PRAM How to Reset NVRAM on your Mac - Apple Support
    If those don't help you can try a cleaning disc or a quick shot of compressed air. Chances are that your drive has failed, join the club it's not all that uncommon. You can either have it replaced or purchase an inexpensive external drive. Don't buy the cute little Apple USB Superdrive, it won't work on macs with internal drives working or not.

  • Can any one tell what is the problem in this code?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.util.*;
    public class AppletTest2 extends JApplet implements ActionListener,MouseMotionListener,WindowListener{
    JFrame fr = new JFrame("Visual Tool -- Work Flow Editor");
         JPanel panel1 = new JPanel();
         JPanel panel2 = new JPanel();
         JButton sButton = new JButton("Source");
         JButton rButton = new JButton("Redirection");
         JButton dButton = new JButton("Destination");
         JButton connect = new JButton("Connect");
         BasicStroke stroke = new BasicStroke(2.0f);
         int flag = 1 ;
         Vector lines = new Vector();
         JButton sBut,rBut,dBut;
    int x1 = 0 ;
         int y1 = 0 ;
         int x2 = 0 ;
         int y2 = 0;
         int x3 = 0;
         int y3 = 0;
         int i=0;
         int j=0;
         int k=0;
         int l = 100;
    int b = 50;
    public void init(){
              /*********Frame ******************/
    fr.getContentPane().setLayout(new BorderLayout());
         fr.setSize(700,500);
              fr.getContentPane().add(panel1,BorderLayout.CENTER);
              fr.getContentPane().add(panel2,BorderLayout.SOUTH);
              fr.addWindowListener(this);
              /*****************PANEL 1*********************/
              panel1.setLayout(null);
    panel1.setBounds(new Rectangle(0,0,400,400));
              panel1.setBackground(new Color(105,105,205));
    /************************PANEL 2 *************/
              panel2.setLayout(new FlowLayout());
              panel2.setBackground(new Color(105,205,159));
              panel2.add(sButton);
              panel2.add(rButton);
              panel2.add(dButton);
              panel2.add(connect);
              connect.setToolTipText("Use this button after selecting From and To position to connect");
              /***************************LISTENER********************/
    sButton.addActionListener(this);
              rButton.addActionListener(this);
              dButton.addActionListener(this);
              connect.addActionListener(this);
              fr.setVisible(true);     
              fr.setResizable(false);
         } // init clse
    /************************** START METHOD **********************************************/
              public void start(){                                 
                   System.out.println("inside start");
                   paint(panel1.getGraphics());
    /*******************************APPLET METHODS **************************************************/
              public void stop(){}
              public void destroy(){}
    /******************************MOUSE MOTION LISTENERS METHOD*************************************/
              public void mouseMoved(MouseEvent e){System.out.println("moved");}
              public void mouseDragged(MouseEvent e){System.out.println("dragged");}
    /***************************************ACTION EVENT IMPLEMENTAION *******************************/
         public void actionPerformed(ActionEvent e){
              if (e.getSource().equals(sButton)){          
              sourceObject("Source Object");          
              else if (e.getSource().equals(rButton)){          
              redirectionObject("Redirection");
              i = i+1;
              else if (e.getSource().equals(dButton)){
              destinationObject("Destination");
                   j= j+1;
              else if (e.getSource().equals(connect)){
                   System.out.println("am inside connect");                
                   paint(panel1.getGraphics());               
    else if(e.getSource().equals(sBut)){
                   System.out.println("am s button");                
                   x1 = sBut.getX() + l;
                   y1 = sBut.getY() + (b/2);
              else if(e.getSource().equals(rBut)){
                   System.out.println("am r button");               
                   x2 = rBut.getX() ;
                   y2 = rBut.getY()+ b/2;
                   System.out.println("x2 : " + x2 + "y2 :" +y2 );
              else if(e.getSource().equals(dBut)){
                   System.out.println("am d button");                
                   x3 = dBut.getX();
    y3 = dBut.getY()+ b/2;
    } // action close
    /**********************Main **********************************/     
         public static void main(String args[]){
         JApplet at = new AppletTest2();
              at.init();
              at.start();
    /********************my methods starts here *******************/
         public void sourceObject(String name){     
    sBut = new JButton(name);
         panel1.add(sBut);
         sBut.setBounds(new Rectangle(20,208,l,b));     
         sBut.addActionListener(this);
    System.out.println("am inside the source object") ;
         public void redirectionObject(String name){     
         rBut = new JButton(name);
         panel1.add(rBut);
         rBut.setBounds(new Rectangle(290,208,l,b));     
    rBut.addActionListener(this);
    System.out.println("am inside the redirection :" + j) ;
    public void destinationObject(String name){     
         dBut = new JButton(name);
         panel1.add(dBut);     
    System.out.println("am inside the destination object") ;
    if (j == 0)
                   dBut.setBounds(new Rectangle(566,60,l,b));                    
                   System.out.println("am inside the destination:" + j) ;
                   } else if (j == 2)
                        dBut.setBounds(new Rectangle(566,208,l,b));     
                        System.out.println("am inside the destination :" + j) ;
                   } else if (j == 1)
    dBut.setBounds(new Rectangle(566,350,l,b));     
                        System.out.println("am inside the destination :" + j) ;
    dBut.addActionListener(this);
    /* public void connectObject(Object obj1,Object obj2){
    System.out.println("nothing");
    /************************************* PAINT **************************/
    public void paint(Graphics g){
         System.out.println("inside paint");
         Graphics2D g2 = (Graphics2D) g;
         g2.setStroke(stroke);
    if(flag == 1){
    System.out.println("inside flag");
    int np = lines.size();
                        System.out.println(np);
                             for (int I=0; I < np; I++) {                       
         Rectangle p = (Rectangle)lines.elementAt(I);
                             System.out.println("width" + p.width);
                             g2.setColor(Color.red);
                             g2.drawLine(p.x,p.y,p.width,p.height);
                             System.out.println(p.x +"" +""+ p.y + ""+ ""+ p.width+ "" + ""+ p.height);
    flag = -1;
    }else if(flag == -1){
         if(x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0 ){
    // Graphics2D g2 = (Graphics2D) g;
         // g2.setStroke(stroke);
    g2.setColor(Color.red);
         g2.drawLine(x1,y1,x2,y2);
         lines.addElement(new Rectangle(x1,y1,x2,y2));     
         x1 = 0 ;y1 = 0 ;
         x2 = 0 ;y2 = 0 ;
    //     g2.drawLine(100,100,200,200);
    else if (x2 != 0 && y2 != 0 && x3 != 0 && y3 != 0 )
              // Graphics2D g2 = (Graphics2D) g;
                   // g2.setStroke(stroke);
              g2.setColor(Color.green);
                        g2.drawLine(x2,y2,x3,y3);
                        lines.addElement(new Rectangle(x2,y2,x3,y3));
                        x2 = 0; y2 = 0 ;
                        x3 = 0 ; y3 = 0 ;                    
    else if (x1 != 0 && y1 != 0 && x3 != 0 && y3 != 0)
                   //     Graphics2D g2 = (Graphics2D) g;
                   // g2.setStroke(stroke);
                   g2.setColor(Color.red);
                   g2.drawLine(x1,y1,x3,y3);
                        lines.addElement(new Rectangle(x1,y1,x3,y3));                              
                        x1 = 0; y1 = 0 ;
                        x3 = 0 ; y3 = 0 ;                    
    // repaint();
    /********************************WINDOW LISTENER IMPLEMENTATION *****************************/
    public void windowActivated(WindowEvent we) { 
              flag = 1;
              paint(panel1.getGraphics());
    System.out.println("windowActivated -- event 1");
         //start();               
         public void windowClosed(WindowEvent we) {
                                                                System.out.println("windowClosed -- 2");
         public void windowClosing(WindowEvent we){
                                                                System.out.println("windowClosing -- 3");
    public void windowDeactivated(WindowEvent we) {
                                                                     System.out.println("windowDeactivated -- 4");
    public void windowDeiconified(WindowEvent we) {
                                                                     flag = 1;
                                                                     System.out.println("windowDeiconified -- 5");          
                                                                     paint(panel1.getGraphics());           
    public void windowIconified(WindowEvent we) {           
                                                           System.out.println("windowIconified -- 6");
                                                           //paint(panel1.getGraphics());
    public void windowOpened(WindowEvent we) {             
                                                      //     flag = 1;
                                                      //     paint(panel1.getGraphics());
                                                           System.out.println("windowopened -- 7");     
    The problem am facing here is that when i minimize the frame and maximize , my old lines are getting disappared.
    For avoiding that i am storing the old coordinates and
    try to redraw , when maximize.
    but the lines are coming for flash of second and disappearing once again ?
    can any one help?
    thanks all

    Very interestingly the same code is repainting in
    Linux SUSE,jdk1.3.
    but not in WINNT , jdk 1.3
    Any reason ?
    Is the swing 100 % platform independenet ?????
    Does swing also uses native thread ???

  • I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.

    I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.
    I saw the below quote on Adobe forum
    "You may install software on up to two computers. These two computers can be Windows, Mac OS, or one each."
    If i install each application in single single system the system count is more than two. In this case, are we have any license issue? Please advice how the problem will solve?
    If possible please send the advise to my mail id: <Removed by Moderator>
    Thanks
    Uvaraj S

    I already answered that.  If you purchased a Suite then you can only install and activate it on two machines.  Even if you only insdtall one of the applications of that suite, it counts as one activation of the suite.  You cannot take the six or seven different applications that might be in a suite and install and activate them in six or seven different machines... only two machines.
    If your scenario will allow for it, one thing you can do is install the programs on all the different machines and only activate two of the machines at any given time.  If you need to activate a program on a third machine then you need to deactivate on one of the currently activate machines first so that you have an open activation to use again.  I do not remember if there is a limit to the total number of activations you can process for the life of the software.

  • I have problem in quicklook for mp4 files in my mountain lion os 10.8.2 so please help me what i need to do? but i can view mov,3gp,jpeg files problem is only with mp4 files.... any one help me...

    I have problem in quicklook for mp4 files in my mountain lion os 10.8.2 so please help me what i need to do? but i can view mov,3gp,jpeg files problem is only with mp4 files.... any one help me...

    I have problem in quicklook for mp4 files in my mountain lion os 10.8.2 so please help me what i need to do? but i can view mov,3gp,jpeg files problem is only with mp4 files.... any one help me...

Maybe you are looking for

  • ID3 Plug-in equivalent to Resize XT for Quark

    Is there a plug-in for ID3 or procedure w/in ID3 that lets you select a group of page elements and scale them to a specified percentage ... scale proportionally, keeping the horizontal and vertical ratio even, or non-proportionally, choosing two diff

  • Is it possible to create new GROUPS in the Contacts of I phone?

    Does anyone know if one can create a group other than <all contacts>? It would be nice to be able to send out multiple text messages to several people by selecting one group for example. I used to do this on my blackberry and miss being able to do so

  • Ability to exclude (generated) files form spell-checking.

    I'd love a check box or something that would enable me to exclude generated files -- especially TOC files -- from spell checking. It's essentially useless to detect a mis-spelled word in the TOC: The mis-spelling needs to be corrected at its source,

  • DMVPN

    Hi , I am setting up an MPLS network for a customer with over 500 sites. There will be two core data centres and the others spokes/remote sites. Customer does not trust MPLS core and so wants an additional layer of ipsec security. I have come up with

  • ICS and Hotmail/MSN Server Deletion Issues

    Hello all, I am posting here after not finding an answer to my question. I am an active member on 3rd party forums and asked my question, but no help received. Here is my problem. My hotmail/msn account will sync fine with my phone, but when I delete