Adding icon in JTableHeader (Java 1.3)

I need to add Up, Down or not Icon in the header sorted Table with java 1.3.1
Can you send my some example ?

This worked in 1.2.
JButton icon = new JButton(SomeImage.gif);
table.getColumnModel.getColumn(0).setHeaderValue(icon);
table.getColumnModel().getColumn(0).setHeaderRenderer( new JComponentCellRenderer() );
class JComponentCellRenderer implements TableCellRenderer
/**overwrites the getTableCellRendererComponent method to return
* a swing componet on the table header
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
return (JComponent)value;
}

Similar Messages

  • Adding icons to menu items

    Okay, I'm a newbie at Java. I have a problem that I'm trying to solve. I added icons to the File menu item, that was easy, but how do I add icons to the other menu items? They are DefaultEditorKit. actions (cut copy paste undo redo) I can't seem to change their names either.
    I'm also having problems with saving the changes I make in the text area.
    Here's the whole code.
    package components;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.HashMap;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.AbstractButton;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.undo.*;
    public class TextComponentDemo extends JFrame implements ActionListener {
        JTextPane textPane;
        AbstractDocument doc;
        JTextArea changeLog;
        JButton newButton, openButton, saveButton, undoButton, redoButton, /*cutButton, copyButton, pasteButton,*/ boldButton, italicButton, underlineButton;
        protected String newline = "\n";
        HashMap<Object, Action> actions;
         File fFile = new File("default.txt");
         JavaFilter fJavaFilter = new JavaFilter();
        protected UndoAction undoAction;
        protected RedoAction redoAction;
        protected UndoManager undo = new UndoManager();
        public TextComponentDemo() {
            super("Notepad v1.0");
            //Create the text pane and configure it.
            textPane = new JTextPane();
            textPane.setCaretPosition(0);
            textPane.setMargin(new Insets(5,5,5,5));
            StyledDocument styledDoc = textPane.getStyledDocument();
            if (styledDoc instanceof AbstractDocument) {
                doc = (AbstractDocument)styledDoc;
            } else {
                System.err.println("Text pane's document isn't an AbstractDocument!");
                System.exit(-1);
            JScrollPane scrollPane = new JScrollPane(textPane);
            scrollPane.setPreferredSize(new Dimension(600, 350));
            newButton = new JButton ("", createImageIcon("images/new.png"));
            newButton.setBackground(Color.white);
       //     newButton.setActionCommand("nou");       
       //     newButton.addActionListener(this);        
            openButton = new JButton("", createImageIcon("images/open.png"));
            openButton.setBackground(Color.white);
            openButton.setActionCommand("deschide");       
            openButton.addActionListener(this);
            saveButton = new JButton("", createImageIcon("images/save.png"));
            saveButton.setBackground(Color.white);
            saveButton.setActionCommand("salveaza");       
            saveButton.addActionListener(this);
            Action actionBold = new StyledEditorKit.BoldAction();
            actionBold.putValue(Action.NAME, "Bold");
            boldButton = new JButton(actionBold);
            boldButton.setBackground(Color.white);
            Action actionItalic = new StyledEditorKit.ItalicAction();
            actionItalic.putValue(Action.NAME, "Italic");
            italicButton = new JButton(actionItalic);
            italicButton.setBackground(Color.white);
            Action actionUnderline = new StyledEditorKit.UnderlineAction();
            actionUnderline.putValue(Action.NAME, "Underline");
            underlineButton = new JButton(actionUnderline);
            underlineButton.setBackground(Color.white);
              String[] fontStrings = { "Arial", "Arial Black", "Comic Sans MS", "Georgia", "Serif", "SansSerif", "Times New Roman", "Trebuchet MS", "Verdana" };
              JComboBox fontList = new JComboBox(fontStrings);
            fontList.setSelectedIndex(0);
            fontList.setBackground(Color.white);
            fontList.setActionCommand("font");
            fontList.addActionListener(this);
               String[] sizeStrings = { "12", "14", "16", "18", "20", "22", "24", "36", "48" };
              JComboBox sizeList = new JComboBox(sizeStrings);
            sizeList.setSelectedIndex(0);
            sizeList.setBackground(Color.white);
            sizeList.setActionCommand("size");
            sizeList.addActionListener(this);
            JPanel buttonPanel = new JPanel(); //use FlowLayout
              buttonPanel.add(newButton);
            buttonPanel.add(openButton);
            buttonPanel.add(saveButton);
         //   buttonPanel.add(cutButton);
         //   buttonPanel.add(copyButton);
         //   buttonPanel.add(pasteButton);
            buttonPanel.add(boldButton);
            buttonPanel.add(italicButton);
            buttonPanel.add(underlineButton);
            buttonPanel.add(fontList);
            buttonPanel.add(sizeList);
            getContentPane().add(buttonPanel, BorderLayout.PAGE_START);
             getContentPane().add(scrollPane, BorderLayout.CENTER);
            //Set up the menu bar.
            createActionTable(textPane);
            JMenu fileMenu = createFileMenu();
            JMenu editMenu = createEditMenu();
            JMenu fontMenu = createFontMenu();
            JMenu ajutorMenu = createAjutorMenu();
            JMenuBar mb = new JMenuBar();
            mb.add(fileMenu);
            mb.add(editMenu);
            mb.add(fontMenu);
            mb.add(ajutorMenu);
            setJMenuBar(mb);
            //Start watching for undoable edits and caret changes.
            doc.addUndoableEditListener(new MyUndoableEditListener());
           //This one listens for edits that can be undone.
        protected class MyUndoableEditListener
                        implements UndoableEditListener {
            public void undoableEditHappened(UndoableEditEvent e) {
                //Remember the edit and update the menus.
                undo.addEdit(e.getEdit());
                undoAction.updateUndoState();
                redoAction.updateRedoState();
    private ImageIcon createImageIcon (String fileName) {
          return new ImageIcon(fileName);
    protected JMenu createFileMenu() {
              JMenu menu = new JMenu("Fisier");
              menu.setMnemonic(KeyEvent.VK_F);
            JMenuItem menuItem;
            ImageIcon iconNou = new ImageIcon("images/new.png");
            menuItem = new JMenuItem("Nou", iconNou);
            menuItem.setMnemonic(KeyEvent.VK_N);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
       //   menuItem.setActionCommand("nou");       
       //   menuItem.addActionListener(this);         
            menu.add(menuItem);
         menu.addSeparator();
              ImageIcon iconOpen = new ImageIcon("images/open.png");
              menuItem = new JMenuItem("Deschide", iconOpen);
            menuItem.setMnemonic(KeyEvent.VK_O);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("deschide");       
            menuItem.addActionListener(this);
              menu.add(menuItem);
              ImageIcon iconSave = new ImageIcon("images/save.png");
              menuItem = new JMenuItem("Salveaza", iconSave);
            menuItem.setMnemonic(KeyEvent.VK_S);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("deschide");       
            menuItem.addActionListener(this);
              menu.add(menuItem);          
         menu.addSeparator();     
              ImageIcon iconQuit = new ImageIcon("images/quit.png");
              menuItem = new JMenuItem("Iesire", iconQuit);
            menuItem.setMnemonic(KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("iesire");       
            menuItem.addActionListener(this);
              menu.add(menuItem);                    
              return menu;
         public void actionPerformed(ActionEvent e) {
             boolean status = false;
           /* if ("nou".equals(e.getActionCommand())) {
                 nou();
            if ("deschide".equals(e.getActionCommand())) {
                 status = openFile();
                   if(!status)
                        JOptionPane.showMessageDialog(
                             null,
                             "Eroare la deschiderea fisierului!", "Fisierul nu a putut fi deschis.",
                             JOptionPane.ERROR_MESSAGE
          /* if ("salveaza".equals(e.getActionCommand())) {
                 status = saveFile();
                   if(!status)
                        JOptionPane.showMessageDialog(
                             null,
                             "Eroare IO in salvarea fisierului!", "Fisierul nu a putut fi salvat.",
                             JOptionPane.ERROR_MESSAGE
            if ("iesire".equals(e.getActionCommand())) {
                 System.exit(-1);
            if ("font".equals(e.getActionCommand())) {
                 JComboBox cb = (JComboBox)e.getSource();
                 String fontName = (String)cb.getSelectedItem();
                 String t = new String(textPane.getSelectedText());
    //               t.setText("fontName");
    //             t.setFont(new java.awt.Font(fontName, 0, 12));
    //               StyledEditorKit.FontFamilyAction font = new StyledEditorKit.FontFamilyAction(fontName, fontName);
         boolean openFile() {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle("Deschide Fisier");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setCurrentDirectory(new File ("."));
                fc.setFileFilter(fJavaFilter);
                int result = fc.showOpenDialog(this);
                if(result == JFileChooser.CANCEL_OPTION) {
                     return true;
                else if(result == JFileChooser.APPROVE_OPTION) {
                     fFile = fc.getSelectedFile();
                     String file_string = readFile(fFile);
                     if(file_string != null) {
                          textPane.setText(file_string);
                     else
                          return false;
                else {
                     return false;
                return true;                                         
            public String readFile (File file) {
              StringBuffer fileBuffer;
             String fileString=null;
             String line;   
             try {
                   FileReader in = new FileReader (file);
                    BufferedReader dis = new BufferedReader (in);
                    fileBuffer = new StringBuffer () ;
                   while ((line = dis.readLine ()) != null) {
                     fileBuffer.append (line + "\n");
                    in.close ();
                    fileString = fileBuffer.toString ();
                  catch  (IOException e ) {
                    return null;
             return fileString;
    /* boolean saveFile () {
         File file = null;
         JFileChooser fc = new JFileChooser ();
         fc.setCurrentDirectory (new File ("."));
         fc.setFileFilter (fJavaFilter);
         fc.setSelectedFile (fFile);
         int result = fc.showSaveDialog (this);
         if (result == JFileChooser.CANCEL_OPTION) {
             return true;
         } else if (result == JFileChooser.APPROVE_OPTION) {
             fFile = fc.getSelectedFile ();
             if (fFile.exists ()) {
                 int response = JOptionPane.showConfirmDialog (null,
                   "Overwrite existing file?","Confirm Overwrite",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
                 if (response == JOptionPane.CANCEL_OPTION) return false;
             return writeFile (fFile, textPane.getText ());
         } else {
           return false;
      protected JMenu createEditMenu() {
            JMenu menu = new JMenu("Editare");
            menu.setMnemonic(KeyEvent.VK_E);
            JMenuItem menuItem;
            undoAction=new UndoAction();
            menu.add(undoAction);   
            redoAction = new RedoAction();
            menu.add(redoAction);
            menu.addSeparator();
              menu.add(getActionByName(DefaultEditorKit.cutAction));       
            menu.add(getActionByName(DefaultEditorKit.copyAction));
            menu.add(getActionByName(DefaultEditorKit.pasteAction));
            menu.addSeparator();
            menu.add(getActionByName(DefaultEditorKit.selectAllAction));
            return menu;
        //Create the style menu.
        protected JMenu createFontMenu() {
            JMenu menu = new JMenu("Font");
            menu.setMnemonic(KeyEvent.VK_F);
            JMenu subMenu = new JMenu ("Stil ");
            Action action = new StyledEditorKit.BoldAction();
            action.putValue(Action.NAME, "Bold");
            subMenu.add(action);
            action = new StyledEditorKit.ItalicAction();
            action.putValue(Action.NAME, "Italic");
            subMenu.add(action);
            action = new StyledEditorKit.UnderlineAction();
            action.putValue(Action.NAME, "Underline");
            subMenu.add(action);
              menu.add(subMenu);
            menu.addSeparator();
            JMenu subMenu2 = new JMenu ("Marime ");
            subMenu2.add(new StyledEditorKit.FontSizeAction("12", 12));
            subMenu2.add(new StyledEditorKit.FontSizeAction("14", 14));
            subMenu2.add(new StyledEditorKit.FontSizeAction("16", 16));
            subMenu2.add(new StyledEditorKit.FontSizeAction("18", 18));
            subMenu2.add(new StyledEditorKit.FontSizeAction("20", 20));
            subMenu2.add(new StyledEditorKit.FontSizeAction("22", 22));
            subMenu2.add(new StyledEditorKit.FontSizeAction("24", 24));
            subMenu2.add(new StyledEditorKit.FontSizeAction("36", 36));
            subMenu2.add(new StyledEditorKit.FontSizeAction("48", 48));
            menu.add(subMenu2);
            menu.addSeparator();
            JMenu subMenu3 = new JMenu ("Familie ");
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Arial", "Arial"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Arial Black", "Arial Black"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Comic Sans MS", "Comic Sans MS"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Georgia", "Georgia"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Times New Roman", "Times New Roman"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Trebuchet MS", "Trebuchet MS"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Verdana", "Verdana"));
            menu.add(subMenu3);
            menu.addSeparator();
            JMenu subMenu4 = new JMenu ("Culoare ");
            subMenu4.add(new StyledEditorKit.ForegroundAction("Rosu", Color.red));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Verde", Color.green));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Albastru", Color.blue));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Galben", Color.yellow));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Gri", Color.gray));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Gri inchis", Color.darkGray));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Negru", Color.black));
            menu.add(subMenu4);
            return menu;
        protected JMenu createAjutorMenu() {
             JMenu menu = new JMenu("Ajutor");
            menu.setMnemonic(KeyEvent.VK_J);
            return menu;
        private void createActionTable(JTextComponent textComponent) {
            actions = new HashMap<Object, Action>();
            Action[] actionsArray = textComponent.getActions();
            for (int i = 0; i < actionsArray.length; i++) {
                Action a = actionsArray;
    actions.put(a.getValue(Action.NAME), a);
    private Action getActionByName(String name) {
    return actions.get(name);
    class UndoAction extends AbstractAction {
    public UndoAction() {
    super("Undo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e) {
    try {
    undo.undo();
    } catch (CannotUndoException ex) {
    System.out.println("Unable to undo: " + ex);
    ex.printStackTrace();
    updateUndoState();
    redoAction.updateRedoState();
    protected void updateUndoState() {
    if (undo.canUndo()) {
    setEnabled(true);
    putValue(Action.NAME, undo.getUndoPresentationName());
    } else {
    setEnabled(false);
    putValue(Action.NAME, "Undo");
    class RedoAction extends AbstractAction {
    public RedoAction() {
    super("Redo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e) {
    try {
    undo.redo();
    } catch (CannotRedoException ex) {
    System.out.println("Unable to redo: " + ex);
    ex.printStackTrace();
    updateRedoState();
    undoAction.updateUndoState();
    protected void updateRedoState() {
    if (undo.canRedo()) {
    setEnabled(true);
    putValue(Action.NAME, undo.getRedoPresentationName());
    } else {
    setEnabled(false);
    putValue(Action.NAME, "Redo");
    private static void createAndShowGUI() {
    final TextComponentDemo frame = new TextComponentDemo();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
         createAndShowGUI();
    class JavaFilter extends javax.swing.filechooser.FileFilter
    public boolean accept (File f) {
    return f.getName ().toLowerCase ().endsWith (".txt")
    || f.isDirectory ();
    public String getDescription () {
    return "Fisiere text (*.txt)";

    Hi,
    unfortunatly you cannot change the properties of Action object as you would do with JavaBeans. Instead you have to use the 'put' method.
    eg.:
    myAction.put(Action.SMALL_ICON, new ImageIcon(...));IMHO this was a bad decision, because it's not like the JavaBeans standard and you loose static type information. :-/
    -Puce
    Message was edited by:
    Puce

  • [svn:osmf:] 10017: Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons.

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

  • [svn] 1376: eclipse projects: added a flex-flextasks Java project

    Revision: 1376
    Author: [email protected]
    Date: 2008-04-23 17:22:58 -0700 (Wed, 23 Apr 2008)
    Log Message:
    eclipse projects: added a flex-flextasks Java project
    * If you are going to work on flex-flextasks, you need an additional Classpath variable: ANT17_JAR which should point to an appropriate ant.jar on your system (since we don't keep an ant.jar checked into lib).
    Modified Paths:
    flex/sdk/trunk/development/eclipse/readme.txt
    Added Paths:
    flex/sdk/trunk/development/eclipse/java/flex-flextasks/
    flex/sdk/trunk/development/eclipse/java/flex-flextasks/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-flextasks/.project

    Hi Yair
    It appears that WLS only supports mapping a directory to a jar in APP-INF/lib/
    C\:/runtime-New_configuration/Common/bin = APP-INF/lib/Common.jar
    but NOT to a jar in WEB-INF/lib.
    Engineering will look into it sometime to fix it.
    Workaround Suggested:
    As a workaround, you can include the Java/Utility project as part of the EAR and set as dependent J2EE module to the Web project.
    Hope this helps.
    Vimala-

  • Dynamically adding JRE for IE, Java Security Warnings, & Next Gen Plugin.

    I wrote an portal application to control the environment for a third party application, the portal uses a JRE version that I supply with it, this was to ensure that users are using the same JRE so any issues can be limited to one version of Java. The only piece of the application that I could not specify the JRE version and path was for Internet Explorer. Please keep in mind that I do not control when the system JRE is updated or not, this is pushed to our systems and the latest JRE would be enabled automatically. I wanted to be able to dynamically add and enable the version of the JRE that Microsoft Internet Explorer uses for applets. So I was digging around recently and if I have the next-generation plugin enabled I could programmatically update the deployment.properties file prior to launching Internet Explorer(assuming I have closed all prior instances of IE that were running) to add and enable a version of the JRE which I choose to use. When I launch IE and run an applet I see that it is using the JRE I had dynamically supplied. However everytime I run the applet a Java security warning comes up saying "The application requires an earlier version of Java", I wanted to suppress this message but after research I tried adding 'deployment.security.mixcode=HIDE_RUN' to the deployment.properties, that did not work. I tried disabling the Next Generation Plugin, that worked to suppress the message however internet explorer was no longer using my dynamically supplied JRE for applets in IE, so that was not going to work for my purposes. My questions are:
    1. Is there a reliable way(not using ssvagent) to programmatically enable and disable Java's Next Generation Plugin option? (I want to make sure it is enabled when launching third party application from the portal)
    2. Is there a programmatic way to suppress the Java Security Warning "The application requires an earlier version of Java", without disabling Java's Next Generation Plugin option?
    deployment.properties entries after addition of my jre entry:
    #deployment.properties
    #Fri Sep 28 14:09:24 PDT 2012
    deployment.javapi.lifecycle.exception=true
    deployment.trace=true
    deployment.javaws.viewer.bounds=323,144,720,360
    deployment.javaws.autodownload=NEVER
    deployment.version=6.0
    deployment.browser.path=C\:\\Program Files (x86)\\Internet Explorer\\iexplore.exe
    deployment.security.mixcode=HIDE_RUN
    deployment.log=true
    deployment.console.startup.mode=SHOW
    deployment.capture.mime.types=true
    #Java Deployment jre's
    #Fri Sep 28 14:09:24 PDT 2012
    deployment.javaws.jre.0.registered=true
    deployment.javaws.jre.0.platform=1.6
    deployment.javaws.jre.0.osname=Windows
    deployment.javaws.jre.0.path=C\:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe
    deployment.javaws.jre.0.product=1.6.0_33
    deployment.javaws.jre.0.osarch=x86
    deployment.javaws.jre.0.location=http\://java.sun.com/products/autodl/j2se
    deployment.javaws.jre.0.enabled=false
    deployment.javaws.jre.0.args=
    deployment.javaws.jre.1.enabled=true
    deployment.javaws.jre.1.registered=true
    deployment.javaws.jre.1.osname=Windows
    deployment.javaws.jre.1.location=http\\\://java.sun.com/products/autodl/j2se
    deployment.javaws.jre.1.osarch=x86
    deployment.javaws.jre.1.path=C\:\\Portal\\dist\\java\\jre6\\bin\\javaw.exe
    deployment.javaws.jre.1.platform=1.6
    deployment.javaws.jre.1.product=1.6.0_29
    Note: The reason not to use most recent version of Java is the necessity to test the third party application prior to deployment of a new Java version and since I do not control when a new version of Java is deployed and enabled to our machines, I am required to find an transparent solution. I understand the security issues by doing so, but the time between testing and acceptance of a new Java version for our application is within an acceptable timeframe. On exiting the application, I would restore the JRE settings and restore previous settings, to minimize the exposure of a potential security risk. Also any manual configurations are trying to be avoided as to maintain transparency to the user.

    I'm having a similar problem and I think it is related with this.
    If, after a Java--->Javascript call, a Javascript--->Java call isn't made soon after the first, it works. But, if the Java--->Javascript call triggers a Javascript--->Java call, any Java--->Javascript call that is made after that doesn't reach Javascript :/
    I have a method that handles the Java--->Javascript calls and goes something like this:
    System.out.println("Calling Javascript...");
    JSObject win = JSObject.getWindow(this);
    win.call(jsEventHandler, new Object[] { json.toString() });
    System.out.println("Done.");I further found out that, after looking at the Java debug console in the scenario where a Java--->Javascript call triggers a Javascript--->Java call, only after this last method returns is the "Done" message printed, even though the respective Javascript call was already invoked.
    Could you explain in more detail the queue based solution you found? Any other ideas?
    Regards,
    Andr&eacute; Tavares.

  • Double click on icon to run java application

    Hello,
    I want to write a code in java so that if i double click on icon the program will start showing the window as it appears when we double click acrobat and the we get the main screen. How this can be achieved?
    Thank you

    The OP should first learn to develop GUIs and only
    then should you think of developing double-clickable
    jar files. hey, OP asked a question; what's wrong with answering it? And who are you to decide whether s/he is ready to learn about jars?
    That said, double clickable jars and
    everything you need to know about running you Java
    program by clicking on something is well discussed in
    the
    Jar
    thread.Yes, but why pass the buck to them if you can answer it just fine yourself?
    OK so I'm being a bit aggro, the forums are moving really slowly.
    lutha

  • Adding binary numbers in java please help!!

    Hello all, im a total newbie to java and i need your help urgently, i have two variables
    that are integers, that store binary numbers i.e.
    int tmpIntOne, tmpIntTwo;
    tmpIntOne = 1010;
    tmpIntTwo = 1110;
    i want to add these numbers together and return a binary result so far when you add them together you get:
    2120
    however i would like a binary result so that
    result = tmpIntOne + tmpIntTwo;
    = 11000
    Thank you.

    Hello all, im a total newbie to java and i need your
    help urgently, i have two variables
    that are integers, that store binary numbers i.e.
    int tmpIntOne, tmpIntTwo;
    tmpIntOne = 1010;
    tmpIntTwo = 1110;These are not binary numbers. These are decimal numbers whose digits consist of ones and zeros. If you want to interpret the characters "010" as a binary number, then do
    int tmp1 = Integer.parseInt("1010", 2);
    etc.
    i want to add these numbers together
    int result = tmp1 + tmp;
    and return a
    binary result Adding two ints will give an int. Int's are always binary. If you want to display it as a binary String, as opposed to the usual decimal String, then, as suggested, use toBinaryString.

  • An icon to run Java Application

    Can you please tell me any way to run a Java Application by simply clicking on an icon in the Windows environment? This means i can run the application easily in Windows instead of the usual "
    java ApplicationName" command in DOS. If it's possible, how can i create such icon?

    hi again,
    as dewangs as pointed out, yes you can create a Jar file too, for creating that, you first need to create a Manifest file generally with name manifest.mf the contents of the file will be in the following format.
    Manifest-Version: 1.0
    Created-By: 1.4.0-beta3
    Main-Class: Filename
    the important part is the Main-Class, you must replace the FileName with the name of the class file which has the main method.
    after that use the jar command, for eg
    jar cvfm myprog.jar manifest.mf -C build/ .
    this will create a jar file with name myprog.jar (it will include all files under the build directory).
    you can then repeat the steps of creating a shortcut for the jar file using the steps i earlier mentioned for a batch file.
    (you will require to choose "all files" instead of "programs" in the "Create shortcut" -> Browse file chooser dialog.)
    hope this was useful.
    cheerz

  • Attaching window system tray icon events to java frame

    I need to bring java frame to front on an event with the icon placed in the system tray. Like if I click the mouse on it.. the frame should come to front.
    Any body who can help, I will really appreciate.
    Thanks in advance
    Zeeshan

    I am very interested in implementing just such a thing with my Java application. I am in the starting phases of this project and ran across your post in my search for info.
    How much do you already have implemented? I.E., can you display the icon but are just having trouble catching the events for when the icon is clicked? Or do you not even have the ability to display the icon yet? I have found the Windows documentation on the MSDN site for the shell function Shell_NotifyIcon(), which is what we want to use but I have not begun any attempts to use it yet.
    If you (or anyone else) have any info or have had any success at all with this yet, I would be very interested in hearing how it works. I'll be happy to share any info I find, when/if I get that far.
    Thanks,
    j

  • Icon DLL in Java

    I have a lot of icons I use for my java application and instead of having all the icons in the directory whether I could use microangelo to put them all in a DLL and then use that DLL in java to access the relevant icon I want, any help one this would be great, thanx =)
    Luppy

    I have to ask... why would you want to do this? The icons will get bundled into a jar file allong with the class files when you deploy, so what's te advantage. The disadvantge is you make your app. platform dependant.

  • Adding Icon / Image on a Submit / ValueHelp button

    Hi:
    Can any one tel me how to add Icon / Image on a Submit / ValueHelp button.
    Thanks
    Vijai

    Vijai,
    Check out Juergen's reply in below thread:-
    Adding Image in Button.
    Chintan

  • HOw to call desktop icons to my java application

    Hi All,
    i want to call all desktop icons to my swing appliation
    pls tell me how to do this, very important for us.
    bye
    N.S

    So "we" have created several applications that want to
    replace task manager, explorer, and now call desktop
    icons? What are "we" writing?
    http://forum.java.sun.com/thread.jsp?thread=213683&foru
    =4&message=735627guys, why are you fucking around ? maybe the originator of this thread will have to rephrase the question (I agree on that), but there is no need to get nasty.

  • Adding a package to java

    I'm trying to use a package to write some programs out of a java book. (The package comes from the same book.) I read a tutorial at java.sun.com on adding packages to the jre/lib/ext folder. I made a .jar file (named bookclass.jar), put it there and was able to compile a sample program. However, when I tried to execute the program, it gives me this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: ann/easyio/Screen
            at Greeter1.main(Greeter1.java:15)I also tried just putting the package in a folder and setting the CLASSPATH enviroment variable, which also allowed me to compile, but gave me the same error when trying to run.
    Any help would be greatly appreciated

    RE: Radish 21
    I already have that in my class.
    Here's the sample class: (the blank comments are to force line spacing)
    /* Greeeter1.java is a simple first Java program that displays a greeting to a user */
    /* Output: A greeting that includes the current date and time                       */
    import ann.easyio.*; // Screen class
    import java.util.*; // Date class
    class Greeter1 extends Object
       public static void main(String args[])
          Date currentDate = new Date();
          String today = currentDate.toString();
          Screen theScreen = new Screen();
          theScreen.println("Welcome! Today, " + today + ", you begin your study of Java!");
       }Before I made the .jar file, the javac couldn't find the package while compiling. After I was able to copile, java couldn't find the package while executing. I checked, and there's no main in the ann.easyio.Screen class.
    Re: YATArchivist
    CLASSPATH was C:\j2sdk1.4.1_02\classes , and like I said before, when I put the package in the classes folder, the program compiled to a class, but the class would not execute.
    I then deleted CLASSPATH when I tried the other solution
    CLASSPATH isn't necessary to run the classes, is it?

  • Adding icon to a button

    Hello
    When I put a JButton on a frame I see in Property Inspector , Visial tab a icon section which it's follow is "<none>"
    how I can use it for adding a icon to the button
    my mean is I want add an icon to button by Property Inspector , but I don't know how I can do it
    can you say to me ?
    thanks

    Hi,
    I don't think the property inspector will help you adding the icon because it needs to be added from the class loader path. In an older JCLient Demo we used the following class
    public class ImageLoader
       public ImageLoader()
       public ImageIcon getImageIcon(String name)
          return new ImageIcon(getClass().getResource(name + ".gif"));
    }This then could be called when setting the icon to a JButton at runtime, passing the icon name to it
    Frank

  • Adding gravity into a Java applet

    Hey guys,
    I have an array of 10,000 dots (ovals) on my screen, and I am trying to make a simple physics simulator, that simulates gravity between these dots. I would like them to interact.
    I'm not really sure where to start, Im not sure if there is a Java method that does this, but anyhow, can someone please explain to me how i would go about doing somthing like this.
    Thanks in advance!
    Andrew

    sabre150 wrote:
    masijade. wrote:
    Futurisdom_Developer wrote:
    Have a thread in an infinite loop that loops through each dot.
    Everytime it checks a dot, it adds x amount of speed to the object (obviously down, seeing as gravity is pulling it down).
    Hope this helps.Except that he wants gravity between the dots (i.e. as in between the Sun and the Earth).and 10,000 masses require each of the 10,000 to compute the interaction with the other 9,999 so there are about 100,000,000 calculations per iteration.I guess I should have further refined the quote, as I was taking note of "down" part. ;-)
    Edit: And the "down" makes it sound as though he is talking only about adding in one direction, rather than adding in the direction from which the next dot is coming, and simply adding one does not, of course, take proximity, or mass into account, which it would need to.

Maybe you are looking for

  • "No Signal Input" on external VGA monitor

    About a year ago my 4 yr emac that I gave my dad starting having the video on the built in display go out periodically. When it started happening more and more, rather than get a whole new computer, we purchased a 22 widescreen VGA monitor and hooked

  • Relation between business process and functional area during the role search

    Hi Experts, We have 2 functional areas in which we have different business process involved. During the Access request, if the user selects  one functional area then business process related to that functional area should come. Is there any functiona

  • About oracle 9i in windows 2003 server

    Oracle 9i not run properly in my server running windows 2003 server, can anybody tell me if there is a problem or i need something else like parch

  • Mix AVG and Total for the same column in ALV grid

    Hi, We are using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY, and I'd like to know if the following situation is possible. Let's say we have a column which contains a number of hours, and we set it up to subtotal by period, but as an average rather

  • Net Update 10.5.6

    Recently the Net update prompted me to instal a new update after re-start. However, my computer seems to hang. The message is "Install 1 item" and below the band "Configuring installation". Nothing happens even after 30 minutes. Can anyone help? I ha