Keymap usage in Swing

I've used <b>setKeyCode()</b>method of Keymap interface to trap key events in a <b>JTextField(in the keyPressed() method).</b>
It's not working with Swing, but is working with AWT.(TextField)
Anybody please get me the the details and its usage in Swing.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class sundar_ind extends JFrame implements KeyListener {
  JTextField field;
  String keyText;
  char   keyChar;
  int    keyCode;
  public sundar_ind() {
    field = new JTextField(10);
    field.addKeyListener(this);
    JPanel panel = new JPanel();
    panel.add(field);
    getContentPane().add(panel);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(200,100);
    setLocationRelativeTo(null);
    setVisible(true);
  public void keyPressed(KeyEvent e) {
    keyChar = e.getKeyChar();
    keyCode = e.getKeyCode();
    keyText = KeyEvent.getKeyText(keyCode);
    write("keyPressed");
  public void keyReleased(KeyEvent e) {
    keyChar = e.getKeyChar();
    keyCode = e.getKeyCode();
    keyText = KeyEvent.getKeyText(keyCode);
    write("keyReleased");
  public void keyTyped(KeyEvent e) {
    keyChar = e.getKeyChar();
    keyCode = e.getKeyCode();
    keyText = KeyEvent.getKeyText(keyCode);
    write("keyTyped");
  private void write(String id) {
    //if(keyText.indexOf("Unknown") != -1)
    if(keyCode == KeyEvent.VK_UNDEFINED)
      keyText = "?";
    System.out.println(id + "\tkeyText = " + keyText +
                       "\tkeyChar = " + keyChar + "\tkeyCode = " + keyCode);
  public static void main(String[] args){
    new sundar_ind();
}

Similar Messages

  • Swing and VTK

    Hi guys,
    who knows something about the usage of swing combined with vtk?
    Are there any tutorials or examples available?
    How do i embedding a vk-rendering into a swing-app?
    Best regards & Thanks in advance
    Thomas

    Is there no one out there with some experience about vtk + java?
    Please help!

  • Tricky problem in JTable

    Hi there,
    I am trying to make a JTable display the keyText of all the keys pressed, meaning if I write an "A" I want it to be shown as " shift + a ". Now I'm not quite sure about the way to handle the focus and how to trigger of the action that makes the editing textField receive the focus. Currently, when the table is called for the first time or when I switch between the fields, no modifier or actionKey can be displayed until the first keyTypedEvent. E.g when I press the a-key I get to be shown an "a". After having done This I get "Aa" or, having pressed the shift-key, "shift" and then "AA". The keyListener is added to the textField and as new instance to the table as well. Can anybody tell me, how to modify myKeyListener to directly focus the textField or give me any idea for a different approach of this problem?
    Thanks in advance, Bjorn
    package com.brain.keymap;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class MyKeyListener implements KeyListener{
        public MyKeyListener() {
            super();
        public void keyTyped(KeyEvent e) {
        public void keyPressed(KeyEvent e) {
            boolean focus = false;
            Component c, editor;
            int keyCode = e.getKeyCode();
            c = (Component) e.getSource();
            if (c instanceof InputTable) {
                InputTable tbl = (InputTable) c;
                editor = tbl.getEditorComponent();
                if (editor instanceof JTextField) {
                    ((JTextField) editor).setText(KeyEvent.getKeyText(keyCode));
                    e.consume();
            }else {
                if( c instanceof JTextField){
                    ((JTextField) c).setText(KeyEvent.getKeyText(keyCode));
                    e.consume();
        public void keyReleased(KeyEvent e) {
    }

    Hey scheide,
    thanks, it was the tip about consuming the consuming the keyStroke that solved it. I simply had to consume the keyTypedEvent. Now It all works fine. Just in case you might want to have a look at it, here's the code.
    public class MyKeyListener implements KeyListener{
        String input = "", temp;
        public MyKeyListener() {
            super();
        public void keyTyped(KeyEvent e) {
            e.consume();
        public void keyPressed(KeyEvent e) {
            createInput(e);
        public void keyReleased(KeyEvent e) {
        public void createInput(KeyEvent e){
            Component c, editor = null;
            int keyCode = e.getKeyCode();
            //disable focusTraversal except for tab and enter
            if (!(keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB)){
                try{
                    editor.setFocusTraversalKeysEnabled(false);
                }catch(NullPointerException ex){}
            c = (Component) e.getSource();
            if (c instanceof InputTable) {
                InputTable tbl = (InputTable) c;
                editor = tbl.getEditorComponent();
                //focussing the table in field [0/0] at first call of table
                if (editor == null) {
                    try{
                        int row = tbl.getSelectedRow();
                        int column = tbl.getSelectedColumn();
                        if( row == -1 )
                            row = 0;
                        if( column == -1)
                            column = 0;
                        tbl.editCellAt(row , column );
                        editor = tbl.getEditorComponent();
                    }catch(Exception ex){}
                if( editor instanceof JTextField && !(keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ENTER )){
                    if (input == ""){
                        input = (KeyEvent.getKeyText(keyCode));
                        ((JTextField) editor).setText(input);
                        temp = input;
                    }else{
                        input = input.concat(" + ").concat(KeyEvent.getKeyText(keyCode));
                        ((JTextField) editor).setText(input);
                        temp = input;
                //when editing the input call of method editFieldValue
            }else if( c instanceof JTextField){
                ((JTextField) c).setText(editFieldValue(temp, e));
            //clear the inputString in case of tab or enter
            if(keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ENTER ){
                input = "";
        public String editFieldValue(String val, KeyEvent event){
            int code;
            String value = val;
            code = event.getKeyCode();
            StringTokenizer tokenizer;
            switch(code){
                case KeyEvent.VK_BACK_SPACE:
                    int count = 0;
                    tokenizer = new StringTokenizer(value,"+");
                    value = "";
                    while ( count < tokenizer.countTokens()){
                        value = value.concat("+").concat(tokenizer.nextToken());
                        count++;
                    break;
            return value;
    }Now I am trying to design a way to edit the input when the JTextfield has the focus. I don't really think I am trying in the right spot, since both the JTable and the TextField get different instances of the KeyListener.
    I guess, I'll try and make a different Listener for the Textfield.
    One more time thanks a lot for your help, Bjorn

  • FileDialog in AWT Applet

    Hi,
    I have an applet with menu options for Opening and saving a file. Is there any way to create a file dialog for opening and saving through AWT without any usage of SWING?
    Any response will be greatly appreciated!!

    /*  <applet code="FileApplet" width="400" height="400"></applet>
    *  use: >appletviewer FielApplet.java
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class FileApplet extends Applet
        public void init()
            final TextArea textArea = new TextArea();
            final FileDialog
                openDialog = new FileDialog(new Frame(), "open", FileDialog.LOAD),
                saveDialog = new FileDialog(new Frame(), "save", FileDialog.SAVE);
            openDialog.setDirectory(".");
            saveDialog.setDirectory(".");
            final Button
                open = new Button("open"),
                save = new Button("save");
            ActionListener l = new ActionListener()
                String newLine = System.getProperty("line.separator");
                public void actionPerformed(ActionEvent e)
                    Button button = (Button)e.getSource();
                    if(button == open)
                        openDialog.show();
                        if(openDialog.getFile() == null)
                            return;
                        File file = new File(openDialog.getFile());
                        BufferedReader br = null;
                        try
                            br = new BufferedReader(new InputStreamReader(
                                                    new FileInputStream(file)));
                            textArea.setText("");
                            String line = "";
                            while((line = br.readLine()) != null)
                                textArea.append(line + newLine);
                            br.close();
                        catch(FileNotFoundException fnfe)
                            System.out.println(fnfe.getMessage());
                        catch(IOException ioe)
                            System.out.println(ioe.getMessage());
                    if(button == save)
                        saveDialog.show();
                        if(saveDialog.getFile() == null)
                            return;
                        File file = new File(saveDialog.getFile());
                        // write to file...
            open.addActionListener(l);
            save.addActionListener(l);
            Panel northPanel = new Panel();
            northPanel.add(open);
            northPanel.add(save);
            setLayout(new BorderLayout());
            add(northPanel, "North");
            add(textArea);
        public static void main(String[] args)
            Applet applet = new FileApplet();
            Frame f = new Frame();
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            f.add(applet);
            f.setSize(400,400);
            f.setLocation(200,200);
            applet.init();
            applet.start();
            f.setVisible(true);
    }

  • JSplitPane with external panel

    Hi,
    I want to use a JSplitPane wich:
    Displays a JTree in the left-component
    Displays application selected from JTree in right-component
    Sounds simple. The right-component has a 'card-deck' which will
    swap whenever an other application is selected in the JTree.
    I have written a short test which does almost exactly what I want.
    Problem is that a panel, which was a standalone Frame-app first,
    is not shown in the right-component (but it is running!)
    It seems that cannot put a standalone application (extending a JFrame) on a component.
    So I decided to change the application and use a JPanel in stead
    of a JFrame. The panel is accepted but isn't shown. (application is
    running though).
    I created a short testpanel_class which should be shown when
    the first app is selected from JTree.
    Current Result when JSplitPane-app is started
    ==> I get the 'home'-card first
    ==> When App2 is selected, I get correct card
    ==> When App1 is selected, the right-component is blank (app runs!)
    Herewith the codesnippet of my JSplitPane-app which is showing
    how I put the components on the left/right components:
    ===================================================
         private JSplitPane getJSplitPane() {
              if (jSplitPane == null) {
                   jLabel = new JLabel("Tekst");
                   jSplitPane = new JSplitPane();
                   jSplitPane.setLeftComponent(getJTree());               
                   myPanel.setLayout(new BorderLayout());
                   pCards.setLayout(cardlayout);
                   pCards.add("home", new JLabel("Home"));
                   pCards.add("App1", new SplitBasePanel());
                   pCards.add("App2", new JLabel("Menu2 Selected"));
                   myPanel.add(pCards, BorderLayout.CENTER);
                   myApp.getViewport().add(myPanel);
                   jSplitPane.setRightComponent(myApp);
              return jSplitPane;
    ===================================================
    And I swap the cards as follows:
    ===================================================
         public void valueChanged(TreeSelectionEvent event) {
              if (!firstRun){
    System.out.println
    ("Current Selection: " +
    jTree.getLastSelectedPathComponent().toString());
    if ((jTree.getLastSelectedPathComponent().toString()).equals("App 1")){
                   cardlayout.show(pCards, "App1");
    if ((jTree.getLastSelectedPathComponent().toString()).equals("App 2")){
                   cardlayout.show(pCards, "App2");
              firstRun = false;
    ======================================================
    Here is my application-panel to be shown
    =================================
    package application;
    import javax.swing.*;
    import java.awt.*;
    public class SplitBasePanel
         extends JPanel {
         // Panel Layout
         private JPanel c = new JPanel();
         // APPLICATION BASE FRAME
         public SplitBasePanel() {
         // Create Application panel
         c.setLayout(new BorderLayout());
         // Initialize CardDeck with basepanels
         c.add(new JLabel("my External Application"), BorderLayout.CENTER);
    }

    a) Sorry for the "code"-formatting, i just copy & paste from my developersoft.
    b) SSCCE ????
    c) I have placed this in this forum because it is not only a question about usage of swing components but also about the concept I try to implement. Maybe what I'm trying to do is just not the right concept !
    d) what do you mean by your final remark (history reply postings)?
    I do not make daily usage of this Developer Forums. So please forgive me when I don't follow the rules completely. I will post the message again in the SWING-forum and try to use the correct formatting.
    Patrick.

  • Optimise RAM usage of Java with Swing

    Hello!
    I have written a little Java SWING Programm. It works great on my P4 3,2 GHz with 512 MB RAM.
    Now I start it on an machine with Celeron 800 MHz with 256 MB RAM. After that I see a big Problem! My applikation consums between 30 and 32 MB RAM! How can I optimise this?! Are there tools to help me at this problem? Can you give me any tips?
    Thanks for help
    Rainer

    one of Swing's problems that people often cite is its memory usage
    jschell pointed out that even native windows wordpad takes ~12MB these days so 30MB isn't that much to worry about
    you can use the recently released HAT (Heap Analysis Tool) from sun to look at where the objects on the heap are
    alternatively HPJMeter (downloadable from hewlett packards website) can analyize the files generated by the -Xrunhprof JVM argument
    I think just a HelloWorldSwing.java style program probably consumes around ~20MB - just because of things that Swing loads in order to run
    asjf

  • BIG swing in data usage?

    I recently upgraded to iphone 6 from a 4s. No change in plan or features other than this. I have noticed a HUGE shift in data being used. I rarely used over 1/2 GB of data but in the past 3 weeks alone have used over 1.5GB. I looked at my data usage analysis and see a big chunk of this has occurred around 3:30am EST over the course of a few mornings. I am sleeping at this hour! I am connected to wifi 95% of the day so hardly any data should be used and I should still be using about the same as my usage of the phone has not changed. Any idea why this is occurring? My guess is maybe verizon is saying I'm using a lot of data even when connected to wifi but I can't seem to get CS to confirm this for me. At 3am when I am sleeping my phone is definitely on wifi. My only guess would be this is when a backup occurs and it's hitting data for some reason????
    p.s. We also have an iphone 5 on the same plan in the same house and that usage has stayed as it always has been.  

        Hi TomCat03 - We want to make sure that you are able to manage your usage at all times! Something to consider about the iPhone is that WiFi will disconnect when the screen is off and in standby mode. If an update is allowed, emails sync or an app syncs cellular data will be used. You can turn off Cellular Data when not in use through Settings>Cellular. Also can view the apps using the most cellular data in the same screen. I am more than happy to offer further assistance if needed.
    Thank you,
    YaleK_VZW
    Follow us on Twitter @VZWsupport

  • LookAndFeel Swing usage

    Hi,
    I have some graphical errors in my application in which i am using both swing and LookandFeel.
    I have two main window and each of them sets two different LookandFeel (UIManager).
    When one window is opening other's backgrond color is corrupting. And application is locked(dont respond anything sometimes).
    How can i use both at the same time correctly ? Can you help?

    Are you trying to use 2 LookAndFeels at the same time? If you are, then like I said earlier, you cannot do that. Well, you can try, but you may not get the expected behavior (i.e., you'll see "bugs" like what you're seeing). LookAndFeels use a data structure called the UIManager, which contains colors, fonts, etc. for a specific LookAndFeel. If you try to use multiple LaFs at the same time, they'll overwrite each others' UIManager values and mess each other up. This was a Swing design choice and so if you choose to use multiple LaFs at the same time, you're on your own, we can't really help you.
    If I'm misunderstanding you, and you're only using one LookAndFeel, please post an SSCCE that demonstrates your problem.

  • Problem with threads in my swing application

    Hi,
    I have some problem in running my swing app. Thre problem is related to threads.
    What i am developing, is a gui framework where i can add different pluggable components to the framework.
    The framework is working fine, but when i press the close action then the gui should close down the present component which is active. The close action is of the framework and the component has the responsibility of checking if it's work is saved or not and hence to throw a message for saving the work, therefore, what i have done is that i call the close method for the component in a separate thread and from my main thread i call the join method for the component's thread.But after join the whole gui hangs.
    I think after the join method even the GUI thread , which is started for every gui, also waits for the component's thread to finish but the component thread can't finish because the gui thread is also waiting for the component to finish. This creates a deadlock situation.
    I dont know wht's happening it's purely my guess.
    One more thing. Why i am calling the component through a different thread, is because , if the component's work is not saved by the user then it must throw a message to save the work. If i continue this message throwing in my main thread only then the main thread doesnt wait for user press of the yes no or cancel button for saving the work . It immediately progresses to the next statement.
    Can anybody help me get out of this?
    Regards,
    amazing_java

    For my original bad thread version, I have rewritten it mimicking javax.swing.Timer
    implementation, reducing average CPU usage to 2 - 3%.
    Will you try this:
    import javax.swing.*;
    import java.awt.*;
    import java.text.*;
    import java.util.*;
    public class SamurayClockW{
      JFrame frame;
      Container con;
      ClockTextFieldW ctf;
      public SamurayClockW(){
        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        con = frame.getContentPane();
        ctf = new ClockTextFieldW();
        con.add(ctf, BorderLayout.SOUTH);
        frame.setBounds(100, 100, 300, 300);
        frame.setVisible(true);
        ctf.start();
      public static void main(String[] args){
        new SamurayClockW();
    class ClockTextFieldW extends JTextField implements Runnable{
      String clock;
      boolean running;
      public ClockTextFieldW(){
        setEditable(false);
        setHorizontalAlignment(RIGHT);
      public synchronized void start(){
        running = true;
        Thread t = new Thread(this);
        t.start();
      public synchronized void stop(){
        running = false;
      public synchronized void run(){
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        try{
          while (running){
            clock = sdf.format(new Date());
            SwingUtilities.invokeLater(new Runnable(){
              public void run(){
                setText(clock);
            try{
              wait(1000);
            catch (InterruptedException ie){
              ie.printStackTrace();
        catch (ThreadDeath td){
          running = false;
    }

  • PL/SQL and Java Swing interface

    Everybody in this forum knows that Oracle is the best database around
    with many functionalities, stability, performance, etc. We also know
    that PL/SQL is a great language to manipulate information directly
    in the database with many built in functions, OOP capability,
    transaction control, among other features. Today an application that
    manipulates information, which needs user interface, requires components
    to be developed using different technologies and normally running in
    different servers or machines. For example, the interface is done using
    a dynamic HTML generator like JSP, PHP, PL/SQL Web Toolkit, etc.
    This page is executed in an application server like Oracle iAS or
    Tomcat, just to name two, which in turn access a database like Oracle to
    build the HTML. Also rich clients like Java applets require an intermediate
    server to access the database (through servlets for example) although
    it is possible to access the database directly but with security issues.
    Another problem with this is that complexity increases a lot, many
    technologies, skills and places to maintain code which leads to a greater
    failure probability. Also, an application is constantly evolving, new
    calculations are added, new tables, changed columns. If you have an
    application with product code for example and you need to increase its
    size, you need to change it in the database, search for all occurrences
    of it in the middle-tier code and perhaps adjust interfaces. Normally
    there is no direct dependency among the tier components. On another
    issue, many application interfaces today are based on HTML which doesn't
    have interactive capabilities like rich-client interfaces. Although it
    is possible to simulate many GUI widgets with JavaScript and DHTML, it is
    far from the interactive level we can accomplish in rich clients like
    Java Swing, Flash MX, Win32, etc. HTML is also a "tag-based" language
    originally created to publish documents so even small pages require
    many bytes to be transmitted, far beyond of what we see on the screen.
    Even in fast networks you have a delay time to wait the page to be
    loaded. Another issue, the database is in general the central location
    for all kinds of data. Most applications relies on it for security,
    transaction and availability. My proposal is to use Oracle as the
    central location for interface, processing and data. With this approach
    we can create not only the data manipulation procedures in the database,
    but procedures that also control and manage user interfaces. Having
    a Oracle database as the central location for all components has many
    advantages:
    - Unique point of maintenance, backup and restore
    - Integrated database security
    - One language for everything, PL/SQL or Java (even both if desired)
    - Inherited database cache, transaction and processing optimizations
    - Direct access to the database dictionary
    - Application runs on Oracle which has support for many platforms.
    - Transparent use of parallel processing, clusters and future
    background technologies
    Regarding the interface, I already created a Java applet renderer
    which receives instructions from the database on how to create GUI
    objects and how to respond to events. The applet is only 8kb and can
    render any Swing or AWT object/event. The communication is done
    through HTTP or HTTPS using Oracles's MOD_PLSQL included in the Apache
    HTTP server which comes with the database or application server (iAS).
    I am also creating a database framework and APIs in PL/SQL to
    create and manipulate the client interface. The applet startup is
    very fast because it is very small, you don't need to download large
    classes with the client interface. Execution is done "on-demand"
    according to instructions received from the database. The instructions
    are very optimized in terms of network bandwidth and based on preliminary
    tests it can be up to 1/10 of a similar HTML screen. Less network usage
    means faster response and means that even low speed connections will
    have a good performance (a future development can be to use this in
    wireless devices like PDAs e even cell phones, just an idea for now).
    The applet can also be executed standalone by using Java Web Start.
    With this approach no business code, except the interface, is executed
    on the client. This means that alterations in the application are
    dynamically reflected in the client, no need to "re-download" the
    application. Events are transmitted when required only so network
    usage is minimized. It is also possible to establish triggering
    events to further reduce network usage. Since the protocol used is
    HTTP (which is stateless), the database framework I am creating will
    be responsible to maintain the state of connections, variables, locks
    and session information, so the developer don't need to worry about it.
    The framework will have many layers, from communication up to
    application so there will be pre-built functions to handle queries,
    pagination, lock, mail, log, etc. The final objective is to have a
    rich client application integrated into the database with minimum
    programming and maintenance requirements, not forgetting customization
    capabilities. Below is a very small example of what can de done. A
    desktop with two windows, each window with two fields, a button with an
    image to switch the values, and events to convert the typed text when
    leaving the field or double-clicking it. The "leave" event also has an
    optimization to only be triggered when the text changes. I am still
    developing the framework and adjusting the renderer but I think that all
    technical barriers were transposed by now. The framework is still in
    the early stages, my guess is that only 5% is done so far. As a future
    development even an IDE can be created so we have a graphical environment
    do develop applications. I am willing to share this with the PL/SQL
    community and listen to ideas and comments.
    Example:
    create or replace procedure demo1 (
    jre_version in varchar2 := '1.4.2_01',
    debug_info in varchar2 := 'false',
    compress_buffer in varchar2 := 'false',
    optimize_buffer in varchar2 := 'true'
    ) as
    begin
    interface.initialize('demo1_init','JGR Demo 1',jre_version,debug_info,compress_buffer,optimize_buffer);
    end;
    create or replace procedure demo1_init as
    begin
    toolkit.initialize;
    toolkit.create_icon('icon',interface.global_root_url||'img/switch.gif');
    toolkit.create_internal_frame('frame1','Frame 1',50,50,300,136);
    toolkit.create_label('frame1label1','frame1',10,10,50,20,'Field 1');
    toolkit.create_label('frame1label2','frame1',10,40,50,20,'Field 2');
    toolkit.create_text_field('frame1field1','frame1',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
    toolkit.create_text_field('frame1field2','frame1',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
    toolkit.set_text_field_event('frame1field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
    toolkit.set_text_field_event('frame1field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
    toolkit.set_text_field_event('frame1field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
    toolkit.set_text_field_event('frame1field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
    toolkit.create_button('button1','frame1',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
    toolkit.set_button_event('button1',toolkit.action_performed_event,'demo1_switch_fields(''frame1field1'',''frame1field2'')','frame1field1:'||toolkit.get_text_method||',frame1field2:'||toolkit.get_text_method);
    toolkit.create_internal_frame('frame2','Frame 2',100,100,300,136);
    toolkit.create_label('frame2label1','frame2',10,10,50,20,'Field 1');
    toolkit.create_label('frame2label2','frame2',10,40,50,20,'Field 2');
    toolkit.create_text_field('frame2field1','frame2',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
    toolkit.create_text_field('frame2field2','frame2',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
    toolkit.set_text_field_event('frame2field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
    toolkit.set_text_field_event('frame2field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
    toolkit.set_text_field_event('frame2field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
    toolkit.set_text_field_event('frame2field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
    toolkit.create_button('button2','frame2',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
    toolkit.set_button_event('button2',toolkit.action_performed_event,'demo1_switch_fields(''frame2field1'',''frame2field2'')','frame2field1:'||toolkit.get_text_method||',frame2field2:'||toolkit.get_text_method);
    end;
    create or replace procedure demo1_set_upper as
    begin
    toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,upper(interface.array_event_value(1)));
    toolkit.set_text_field_event(interface.global_object_name,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
    end;
    create or replace procedure demo1_set_lower as
    begin
    toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,lower(interface.array_event_value(1)));
    toolkit.set_text_field_event(interface.global_object_name,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
    end;
    create or replace procedure demo1_switch_fields (
    field1 in varchar2,
    field2 in varchar2
    ) as
    begin
    toolkit.set_string_method(field1,toolkit.set_text_method,interface.array_event_value(2));
    toolkit.set_string_method(field2,toolkit.set_text_method,interface.array_event_value(1));
    toolkit.set_text_field_event(field1,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(2)),'false');
    toolkit.set_text_field_event(field2,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
    toolkit.set_text_field_event(field1,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(2)),'false');
    toolkit.set_text_field_event(field2,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
    end;

    Is it sound like Oracle Portal?
    But you want to save a layer 9iAS.
    Basically, that was the WebDB.(Oracle changed the name to Portal when version 3.0)
    Over all, I agree with you.
    &gt;&gt;Having a Oracle database as the central location for all components has many
    &gt;&gt;advantages:
    &gt;&gt;
    &gt;&gt;- Unique point of maintenance, backup and restore
    &gt;&gt;- Integrated database security
    &gt;&gt;- One language for everything, PL/SQL or Java (even both if desired)
    &gt;&gt;- Inherited database cache, transaction and processing optimizations
    &gt;&gt;- Direct access to the database dictionary
    &gt;&gt;- Application runs on Oracle which has support for many platforms.
    &gt;&gt;- Transparent use of parallel processing, clusters and future
    &gt;&gt;background technologies
    I would like to build 'ZOPE' inside Oracle DB as a back-end
    Using Flash MX as front-end.
    Thomas Ku.

  • Problem On Windows-XP of Swing App

    The problem of the Heavy-weight Swing appication in the following Operating environment -
    Operating System : Microsoft Windows XP [Version 5.1.2600]
    Processor : Intel Pentium-4 2.20 GHz
    RAM : 256 MB
    Graphics Adapter : RADEON IGP 340M / Intel 82845
    Java Runtime Environment -( java.exe )
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    Problem -
    It takes more than 25 minutes to load. After loading it shows the white screen.
    As we move the cursor over the screen the GUI components under the cursor are displayed.
    When the user interacts with the application e.g. by clicking the button.
    again more than 1 minute is spent the OS in the response
    At the startup , program constructs 13 objects. Each object is one JPanel.
    Each JPanel again contain one JTabbadPane containing 5 tabs.
    Each tab contain 2-3 Jpanels.
    In these JPanels there are lots of Swing GUI components.
    For each constructor of the object 1-2 minutes are required.
    Overall time to load the complete program is 25 minutes.
    During these 25 minutes CPU usage is 100 %
    All other activities are stopped
    The Solutions we have tried.
    1. downloaded the latest JRE 1.4
    2. used various JVM options ( command line arguments to java.exe )
    -Xmx -Xms
    -XX:+AggressiveHeap
    -Dsun.java2d.3d=false
    -Dsun.java2d.ddoffscreen=false
    -Dsun.java2d.noddraw=true
    2. created the executable jar file
    3. analyzed and compared the System properties, Graphics Environment properties
    for Windows 98 and Windows -XP
    4. downloaded the latest update for windows-xp's driver and
    MS JVM( java virtual machine)
    5. tried the jre.exe 's options
    6. sets various options of UIManager
    On Windows 98 SE it takes less than 9 seconds to load that program.

    Hi,
    On the Windows XP machine, are you running a virus checker,
    (like Sophos?), that tries to verify the runtime jar files and
    each class file as it's loaded?
    --Steve                                                                                                                                                                                                                                                                                                                                                   

  • Text input in text components in swing?

    Hi,
    is there any UML diagram, or any site on how text input is carried out in text components? Is it just a simple matter of JTextComponent adding itself as a KeyListener to itself, and then updating the document with each key press? or is there a little more too it?
    thanks,
    J

    justinlawler wrote:
    or is there a little more too it?There's a lot more to it. I think good beginning reading is the summary at the top of the [Javadoc for JTextComponent|http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html] . It is a convoluted API that has many "kludges" that can't be completely removed because of the need for backwards compatibility.
    I'd also recommend reading up on the classes EditorKit, InputMap, ActionMap, Keymap, and (Basic)TextUI. Good luck!

  • Threading Network code in a Swing Application

    For my final High school project i have decided to code a Poker game to be played over the network. Problem is, as soon the host starts waiting for a client to connect, everything Swing related freezes. A friend of mine said to use Threads.
    Strangely enough, when i made a small example class, this did not happen.
    Any e-books,ideas examples about threading please?or a solution to this 'freeze' problem?
    Message was edited by:
    Naks

    There is a ton of stuff in these forums and elsewhere on usage of SwingWorker. It may be helpful to google this and also open the Sun tutorials on concurrency and Swing, and study the the articles.
    Good luck!
    /Pete

  • Unable to download images in a swing applet (1.3.1) behind proxy

    Hi
    One of my client have a proxy server and firewall and when they try to access my webserver
    then all the AWT applet are downloaded and rendered on client properly. However, the swing applet written
    using JDK 1.3.1 is downloaded and rendered but it doesn't display anything properly as images
    are not down loaded. I have used media tracker to add images to it like oMediaTracker.addImage( oImage, index );
    and then oMediaTracker.waitForAll();
    Java console display at client looks as follows:
    Java(TM) Plug-in: Version 1.3.1
    Using JRE version 1.3.1 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\toy
    Proxy Configuration: no proxy
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    Applet Initialization start...
    Applet Image Initialization start...
    Trace level set to 5: basic, net, security, ext, liveconnect ... completed.
    Opening      http:MyServer/24/x.gif
    Connecting     http:MyServer/24/x.gif with no proxy
    Connecting
    http:MyServer/24/x.gif with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening      http:MyServer/40/y.gif
    Connecting      http:MyServer/40/y.gif with no proxy
    Connecting      http:MyServer/40/y.gif with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening     http://MyServer/sun/beans/infos/PanelBeanInfo.class
    Connecting     http://MyServer/sun/beans/infos/PanelBeanInfo.class with no proxy
    Connecting http://MyServer/sun/beans/infos/PanelBeanInfo.class with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening http://MyServer/java/awt/ContainerBeanInfo.class
    Connecting http://MyServer/java/awt/ContainerBeanInfo.class with no proxy
    Connecting http://MyServer/java/awt/ContainerBeanInfo.class
    Client machine tries to access these images but i never receive a call at web server end when i see
    IIS log.
    CLient environment:
    -Windows 2000/XP/NT
    -Internet explorer 6.0 SP1 or IE 5.5 SP2
    with connection->LAN Setting->Use Automatic configuration script(only checked)
    -Java Plugin configured like proxies->Use Browser Setting
    -JDK 1.3.1 plug in at client(downloaded and Installed automatically on demand)
    -Object tag used to download applet and plugin
    -Firewall and proxy(i don't know about vendor)
    My webserver environment
    Windows 2000/iis 5.0 with anonymous authentication and
    cache-control header set to no-store (so that proxy doesn't cache anything)
    QUESTIONS:
    ~~~~~~~~~
    Q.1. When i try from home network that has a proxy then everything works fine. At client site everything except
    image download works fine. I mean jars are downloaded and i can see anything drawn using JAVA API.
    When i try from home i see following java console trace
    Java(TM) Plug-in: Version 1.3.1
    Using JRE version 1.3.1 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\wuko
    Proxy Configuration: Automatic Proxy Configuration
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    Trace level set to 5: basic, net, security, ext, liveconnect ... completed.
    Applet Initialization start...
    Applet Image Initialization start...
    Opening http://MyServer/24/connec.gif
    Connecting http://MyServer/24/connec.gif with proxy=197.168.1.100:808
    Connecting http://MyServer/24/connec.gif with cookie "ASPSESSIONIDQQGQQCYU=GBJFAOABCJFPDMGFHEKLDACA; JSESSIONID=26yu5m1b4upVuXoAoDmtMbWXQmetQpyzqjFANszo9vFubujT4qGX!-1149265879"
    Opening http://MyServer/24/cool.gif
    Connecting http://MyServer/24/cool.gif with proxy=197.168.1.100:808
    Connecting http://MyServer/24/cool.gif with cookie "ASPSESSIONIDQQGQQCYU=GBJFAOABCJFPDMGFHEKLDACA; JSESSIONID=26yu5m1b4upVuXoAoDmtMbWXQmetQpyzqjFANszo9vFubujT4qGX!-1149265879"
    etc
    I can't set the plugin at client to use automatic script just like IE browser uses. This option is not supported in JRE1.3.1. Looks to be supported in JRE1.4.1. My client doesn't want to set manual proxy ip and port in plugin as they don't want to reveal this info to everyone within the company for security reason.
    Q.2. Why some classes like PanelBeanInfo.class, JAppletBeanInfo.class are downloaded
    from my server while it doesn't exist at my webserver. Any thing stupid IE or plugin doing
    at client. Any Idea?
    Thanks in advance for any help.
    Ratan

    Thanks to Mike and other friends who already replied on this topic.
    Here is my research analysis:
    Answer to Question 1:
    ~~~~~~~~~~~~~~~~~~~~~
    The solution is to bundle all the images with JAR. Bundle with jar whichever needs it. However, it might require duplicacy.
    Image img = null;
    try
    img = Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileName));
    catch (Exception e) { }
    In this case make sure that you have image at the same location where you access it. For example if you have to access an image in package class com.awt.ui.MyClass then your image should also be at location ..\com\awt\ui
    Note: It will require image duplicacy in your JAR but it solves the problem. It gives the advantage of fewer download from server.
    Answer to Question 2:
    ~~~~~~~~~~~~~~~~~~~~~
    IE treats applet as an active-X and try to look for these classes in your JAR. SUN has stopped its support in JDK1.3.1 and plus. What one can do is to create dummy classes with these names and bundle it with your JAR. You have to create these dummy classes if you enable Basic authentication on your web server then browser will try to look for these classes on the server and continue to prompt you for login and password. It might bother your customer un-necessarily to enter login and password too many times prompted by plug-in (plug in).
    --Ratan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Removing a window and adding a new one with swing.

    Hi,
    A friend of mine recently asked me to add a GUI for a small chat he made, so I thought I'd help him out. I've come across something that's troubled me in the past, and I could never find a solution. What I'm trying to do is make it so a log in window pops up (have that working alright) and then when you press sign in, it removes that window (log in) and adds the main chat window (have this fully functional, too).
    If someone could provide an example or point me in the direction of the proper API to look into, so that I don't have to look through them all, I'd be extremely grateful.
    Here's an SSCCE example:
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import javax.swing.DefaultListModel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.JTextPane;
    import javax.swing.ListSelectionModel;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.SwingUtilities;
    public class Gui extends JFrame {
         public static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
         public String sessionId;
         public int returnCode;
         public boolean recievedReturnCode;
         public boolean errorConnecting;
         public long lastActionDelay;
         private JScrollPane listScrollPane;
         private JList list;
         private JTextPane console;
         private JButton signInButton;
         private JScrollPane consoleScrollPane;
         private JTextField typingField;
         private DefaultListModel userList;
         private JButton sendButton;
         public static void main(String[] args) {
              try {
                   SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                             new Gui().setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
         public Gui() {
              setResizable(false);
              setSize(500, 500);
              consoleScrollPane = new JScrollPane();
              console = new JTextPane();
              typingField = new JTextField();
              userList = new DefaultListModel();
              sendButton = new JButton();
              initializeLoginWindow();
              setDefaultCloseOperation(EXIT_ON_CLOSE);
         public void initializeLoginWindow() {
              setTitle("Login");
              signInButton = new JButton("Sign in");
              signInButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        initializeChatWindow();
              signInButton.setBounds(5, 100, 75, 20);
              getContentPane().add(signInButton);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(new JPanel());
         public void initializeChatWindow() {
              consoleScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
              consoleScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
              consoleScrollPane.setViewportView(console);
              consoleScrollPane.setBounds(5, 5, 575, 350);
              console.setEditable(false);
              typingField.setEditable(true);
              typingField.setBounds(5, 360, 575, 25);
              list = new JList(userList);
            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            list.setSelectedIndex(0);
            list.setVisibleRowCount(5);
            listScrollPane = new JScrollPane(list);
              listScrollPane.setBounds(585, 5, 110, 350);
              sendButton.setText("Send");
              sendButton.setBounds(585, 360, 111, 25);
              getContentPane().add(consoleScrollPane);
              getContentPane().add(typingField);
              getContentPane().add(listScrollPane);
              getContentPane().add(sendButton);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(new JPanel());
    }Thanks in advanced!

    jduprez wrote:
    I've come across something that's troubled me in the past, and I could never find a solutionWhat is the problem?
    a log in window pops up (have that working alright)
    and then when you press sign in, it removes that window (log in) and adds the main chat window (have this fully functional, too).Hum, between what is working alright and what is already functional, I fail to see what is missing. Again, what is your problem/question?
    If someone could provide an example or point me in the direction of the proper API to look into, so that I don't have to look through them all, I'd be extremely grateful.
    [url http://download.oracle.com/javase/tutorial/uiswing/components/frame.html]JFrames and [url http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html]dialogs seem to show enough API usage to do that. Still, I stronlgy encourage you to read the whole Swing tutorial: http://download.oracle.com/javase/tutorial/uiswing/index.html
    Incase you didn't see the hyperlink above, here's the SSCCE link: http://www.mediafire.com/?e5e3ci3kbvickla
    The "S" in SSCCE stands for "Short" (or, depending on authors, "Simple"). Anyway, a decent SSCCE should fit within a forum post (between code tags please). The whole idea is to provide the simplest thing to people willing to help. No doubtful sites. No non-standard extensions.
    Best regards,
    The problem is that I cannot seem to remove the first pane, leaving the second one to be drawn on the current one.
    In reguards to SSCCE, I always thought it was just a short runnable class example, but I've added the class to the main post. I'll take a look at the API in a few as well.

Maybe you are looking for

  • Satellite L300 keeps freezing

    My laptop keeps freezing ... it doesn't always happen, but it's started happening regularly over the past few weeks, where all programs stop responding and I can't open Task Manager, so the only thing to do is to turn the power off. I tried restartin

  • Itunes lost files

    I have imported some audiobooks from my computer into itunes. Normally they show up in music. and i need to select autiobook. However I imported a bunch, and they are no where to be found. music, audiobooks, movies, etc... And if I try reimporting th

  • Stopping the iPhoto launch when syncing an iDevice to iTunes

    Am I overlooking a simple way to prevent iPhoto automatically launching on my Mac when I connect one of my iDevices (iPad, iPhone, iPod, etc) to sync them manually with iTunes? I am not streaming photos over iCloud, and that option is off on each of

  • CS6 Production Premium installed on my G5 but won't validate the serial number on my imac

    CS6 Production Premium installed on my G5 but won't validate the serial number on my imac? I'm sure you can install this version on 3 machines to use non simultaniously, why will it accept the serial on one machine but not another?

  • Netflix 104 Error on new AppleTV 2...

    I JUST purchased AppleTV 2.  Everything works great except for Netflix.  What is up with this?  The exact error: "Sorry we could not reach the Netflix service.  Please try again later.  If the problem persists please visit the Netflix website. (104).