Thread: [731] AWT Canvas keyboard inputs

Results 1 to 10 of 10
  1. #1 [731] AWT Canvas keyboard inputs 
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    I currently have a JFrame with a Canvas inside it (through JPanels, not directly) and whenever I click on it, my JTextFields stop working:



    I've managed to boil it down to the Display.update() method for lwjgl that updates the 3d model and also polls the input devices. I'm guessing it monopolizes the input without ever letting go. Any way to fix this? (I've tried doing Display.update(false) so input doesn't process but that hangs the whole JFrame...)
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. #2  
    Registered Member GameMaster's Avatar
    Join Date
    Jun 2015
    Posts
    93
    Thanks given
    29
    Thanks received
    12
    Rep Power
    37
    hard to tell without any code examples. are we supposed to guess? lol
    Reply With Quote  
     

  3. #3  
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    Quote Originally Posted by GameMaster View Post
    hard to tell without any code examples. are we supposed to guess? lol
    Item panel window (That's the right panel named "Tool" that takes the 2/3 right part of the screenshot):

    Code:
    private void createUIComponents() {
            UIManager.put("TabbedPane.contentOpaque", false);
    
            contentPane = new ContentPanel();
            canvasPanel = new TransparentPanel();
            modelOptionsPane = new TransparentPanel();
    
            generalTab = new TransparentPanel();
            modelTab = new TransparentPanel();
            unknownsTab = new TransparentPanel();
            clientscriptsTab = new TransparentPanel();
    
            generalPanel = new TransparentPanel();
            nameLbl = new DefaultLabel();
            nameTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.NOT_EMPTY);
            valueLbl = new DefaultLabel();
            valueTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_INTEGER);
            stackableCheckbox = new DefaultCheckbox(null);
    
            equipPanel = new TransparentPanel();
            equipslotLbl = new DefaultLabel();
            equipSlotCombobox = new DefaultCombobox();
            for (ItemDefinitions.EquipSlot es : ItemDefinitions.EquipSlot.values()) {
                equipSlotCombobox.addItem(es);
            }
    
            equipTypeLbl = new DefaultLabel();
            equipTypeCombobox = new DefaultCombobox();
            for (ItemDefinitions.EquipType et : ItemDefinitions.EquipType.values()) {
                equipTypeCombobox.addItem(et);
            }
    
            teamLbl = new DefaultLabel();
            teamTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
    
            stackPanel = new TransparentPanel();
            stacksLbl = new DefaultLabel();
    
            notedPanel = new TransparentPanel();
            notedCheckbox = new DefaultCheckbox(null);
            notedLbl = new DefaultLabel();
            notedTField = new DefaultTextField(parent.getParent(), getItemIdValidator());
            lentCheckbox = new DefaultCheckbox(null);
            lentLbl = new DefaultLabel();
            lentTField = new DefaultTextField(parent.getParent(), getItemIdValidator());
            boughtCheckbox = new DefaultCheckbox(null);
            boughLbl = new DefaultLabel();
            boughtTField = new DefaultTextField(parent.getParent(), getItemIdValidator());
    
            invModelLbl = new DefaultLabel();
            invModelTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
            zoomLbl = new DefaultLabel();
            zoomTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
            rotationXLbl = new DefaultLabel();
            rotationXTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
            rotationYLbl = new DefaultLabel();
            rotationYTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
            offsetXLbl = new DefaultLabel();
            offsetXTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
            offsetYLbl = new DefaultLabel();
            offsetYTField = new DefaultTextField(parent.getParent(), DefaultTextField.Validator.SIGNED_BYTE);
    
            canvas = new Canvas() {
                private static final long serialVersionUID = -1069002023468669595L;
    
                public void removeNotify() {
                    super.removeNotify();
                    modelViewer.stopOpenGL();
                }
            };
            canvas.addComponentListener(new ComponentListener() {
                public void componentShown(ComponentEvent e) {
                    setNeedValidation();
                }
    
                public void componentResized(ComponentEvent e) {
                    setNeedValidation();
                }
    
                public void componentMoved(ComponentEvent e) {
                    setNeedValidation();
                }
    
                public void componentHidden(ComponentEvent e) {
                    setNeedValidation();
                }
            });
            //canvas.setFocusable(false);
            //canvas.setIgnoreRepaint(true);
            canvas.setPreferredSize(new Dimension(720, 720));
            canvas.setMinimumSize(new Dimension(320, 240));
    
            //canvas.setVisible(true);
            canvasPanel.add(canvas);
    
            characterModelCBox = new DefaultCheckbox(e -> switchModel());
            maleCBox = new DefaultCheckbox(e -> switchMale());
    
            addItemBtn = new DefaultButton(e -> addItem());
            overwriteItemBtn = new DefaultButton(e -> overwriteItem());
            deleteItemBtn = new DefaultButton(e -> deleteItem());
            dumpItemBtn = new DefaultButton(e -> dumpItem());
            dumpAllItemsBtn = new DefaultButton(e -> dumpAllItems());
    
            modelViewer = new ModelViewer(parent.getStore(), canvas);
        }
    Lwjgl canvas init:

    Code:
    public void startOpenGL() {
            Logger.log("StartOpenGL");
    
            gameThread = new Thread() {
    
                public void run() {
                    while (Display.isCreated());//this isn't the issue, I actually tested and the thread runs. Just a pretty freaking ugly fix instead of a singleton or something
                    while (!Display.isCreated()) {
                        try {
                            Display.setParent(canvas);
                            if (!Display.getParent().isDisplayable())
                                continue;
                            Display.create();
    
                            Rectangle rect = canvas.getBounds();
                            int w = (int) rect.getWidth();
                            int h = (int) rect.getHeight();
    
                            GL11.glMatrixMode(GL11.GL_PROJECTION);
                            GL11.glLoadIdentity();
                            GL11.glViewport(0, 0, w, h);
    
                            GL11.glMatrixMode(GL11.GL_MODELVIEW);
                            GL11.glLoadIdentity();
                            GL11.glEnable(GL11.GL_DEPTH_TEST);
    
                            camera = new Camera();
                            running = true;
                        } catch (LWJGLException e) {
                            e.printStackTrace();
                        }
                    }
                    while (running && !Display.isCloseRequested()) {
                        updateGL();
                        try {
                            if (currentDefs != null) {
                                Thread.sleep(currentDefs.getFrameDurations()[frameId] * 20);
                            } else
                                Thread.sleep(50);
                        } catch (InterruptedException e) {
                            Logger.error("huh thread interupted", true);
                        }
                    }
                    if (Display.isCreated()) {
                        Display.destroy();
                    }
                }
            };
            gameThread.start();
        }
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    bump
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    bump
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    bump
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. #7  
    Donator


    Join Date
    Mar 2016
    Posts
    547
    Thanks given
    95
    Thanks received
    112
    Rep Power
    82
    Quote Originally Posted by clem585 View Post
    bump


    Clem is the master of help section yet cant get a text box to work




    Good meme tho
    Reply With Quote  
     

  8. Thankful user:


  9. #8  
    Registered Member
    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,196
    Thanks given
    459
    Thanks received
    552
    Rep Power
    124
    Quote Originally Posted by Johnyblob22 View Post
    Clem is the master of help section yet cant get a text box to work




    Good meme tho
    Swing is hard oky, pls be nice
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. #9  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    20
    Posts
    1,216
    Thanks given
    2,413
    Thanks received
    502
    Rep Power
    510
    Quote Originally Posted by clem585 View Post
    Swing is hard oky, pls be nice
    czech skype
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  11. #10  
    Registered Member
    Admiral Slee's Avatar
    Join Date
    Jul 2015
    Posts
    397
    Thanks given
    145
    Thanks received
    158
    Rep Power
    149
    If you want me to help you, you should create a demo application of yours where this problem persists.

    Also, if nobody here can help you, go to [Only registered and activated users can see links. ]

    But then again, they'll ask for a demo where the problem persists.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 07-23-2015, 10:32 PM
  2. Sprite and Background to java.awt.image
    By Meanz in forum Snippets
    Replies: 4
    Last Post: 03-22-2009, 08:26 PM
  3. Replies: 3
    Last Post: 07-11-2008, 10:06 AM
  4. Replies: 5
    Last Post: 07-11-2008, 09:04 AM
  5. making a command with an input sub int/String
    By littleplop in forum Tutorials
    Replies: 0
    Last Post: 02-22-2008, 08:39 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •