You are not logged in.

#1 2012-11-25 13:54:23

gadget3000
Member
Registered: 2010-05-11
Posts: 23

Java is not displaying JFrame correctly

I'm currently creating a java application and it makes use of JFrames with JPanels drawn directly onto it. I know this works on other machines but on my Arch Linux machine the JFrame is just blank.
I'm currently using the official oracle jdk and jre, but I've tried with openjdk as well. Everything is up to date and I'm using xmonad as my window manager.

Thanks for any help you can give, and let me know if you need any more information.

EDIT:
Here's an example of what type of code isn't functioning properly:

import java.awt*;
import javax.swing.*;

public class JFrameTester {

  public static void main(String[] args) {
   
    JFrame f = new JFrame("A JFrame");
    f.setSize(250, 250);
    f.setLocation(300,200);
    f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10, 40));
    f.getContentPane().add(new JLabel("Testing"));
    f.setVisible(true);
   
  }
 
}

Last edited by gadget3000 (2012-11-25 14:01:30)

Offline

#2 2012-11-25 14:16:56

biltong
Member
From: South Africa
Registered: 2011-09-01
Posts: 118

Re: Java is not displaying JFrame correctly

import java.awt.*;
import javax.swing.*;
public class JFrameTester {  
    public static void main(String[] args) {
    
    JFrame f = new JFrame("A JFrame");
    f.setSize(250, 250);
    f.setLocation(300,200);
    f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10, 40));
    f.getContentPane().add(BorderLayout.NORTH,new JLabel("Testing"));
    f.setVisible(true);
    
  }
  
}

Works for me.

EDIT: Just a thought, did you set java to use a different theme such as your GTK/KDE theme or anything like that? Perhaps everything is there but you can't see it because of your theme. Try change the look and feel to nimbus or something.

Last edited by biltong (2012-11-25 14:28:11)

Offline

#3 2012-11-25 17:01:20

Nepherte
Member
From: Singapore
Registered: 2008-09-09
Posts: 427
Website

Re: Java is not displaying JFrame correctly

Offline

#4 2022-12-21 18:52:28

sucralose
Member
From: Canada
Registered: 2022-12-21
Posts: 1
Website

Re: Java is not displaying JFrame correctly

I had this problem too with jdk-openjdk and jre-openjdk (but using bspwm and not xmonad). I was able to fix it by setting

export _JAVA_AWT_WM_NONREPARENTING=1

which was mentioned in the wiki article that Nepherte linked. It's also mentioned on the Arch Wiki at https://wiki.archlinux.org/title/Java#G … ly_closing .

Last edited by sucralose (2022-12-21 21:21:37)

Offline

Board footer

Powered by FluxBB