Thread: [731] AWT Canvas keyboard inputs

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 [731] AWT Canvas keyboard inputs 
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    I currently have a JFrame with a Canvas inside it (through JPanels, not directly) and whenever I click on it, my JTextFields stop working:

    Attached image

    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
    Reply With Quote  
     

  2. #2  
    Registered Member GameMaster's Avatar
    Join Date
    Jun 2015
    Posts
    153
    Thanks given
    46
    Thanks received
    21
    Rep Power
    46
    hard to tell without any code examples. are we supposed to guess? lol
    Attached image
    Reply With Quote  
     

  3. #3  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    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
    Reply With Quote  
     

  4. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    bump
    Project thread
    Reply With Quote  
     

  5. #5  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    bump
    Project thread
    Reply With Quote  
     

  6. #6  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    bump
    Project thread
    Reply With Quote  
     

  7. #7  
    Discord Johnyblob22#7757


    Join Date
    Mar 2016
    Posts
    1,384
    Thanks given
    365
    Thanks received
    575
    Rep Power
    5000
    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  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    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
    Reply With Quote  
     

  10. #9  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,312
    Thanks received
    691
    Rep Power
    1098
    Quote Originally Posted by clem585 View Post
    Swing is hard oky, pls be nice
    czech skype
    Reply With Quote  
     

  11. #10  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    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 http://stackoverflow.com/

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

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. C# Embedded Runescape Client Doesn't Take Keyboard Input
    By Tigra in forum Application Development
    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
  •