So I am trying to port a somewhat large java program from windows to linux (CENTOS 7). The program works just fine on windows, but in my linux set up only the main frame of the application shows up (title, maximize minimize exit buttons found on the top bar of most applications). All the java swing elements (buttons, tables, drop down menus) are invisible at the frame (clicking on them will bring up an invisible menu). Again it works fine on windows, so it probably isn't the code.
Things I've tried:
-Attempt: trying to run a different program I wrote that has a a java swing
gui
Result: same problem.
conclusions: probably not a code problem
-Attempt: Downloading a simple gui example that works on windows
Result: same problem
Conclusions: definitely not a code problem
-Attempt: Downloading another even simpler gui example that works on windows
Result: same problem
Conclusions: definitely not a code problem
-Attempt: reinstall java (yum remove, yum install)
Result: same problem
conclusions: I don't know what to draw from this, probably not my installation of java?
-Attempt: reconfigure build and classpaths
result: same problem
conlusions: I don't know what to draw from this, probably not my build and classpaths?
-Attempt: get a new CENTOS 7 vm and reinstall on there
result: same problem
conlusions: Does CENTOS have a problem with swing?
Useful? somewhat random facts:
Java -version returns OpenJDK Runtime Environment (build 1.8.0_141-b16) OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
which java returns /usr/bin/java
whereis java returns java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz
I'm using eclipse Oxygen Standard Edition Java to run and compile
under run configurations my jre is set to java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64
runtime classpath, source, environment are all default.
buildpath includes some libraries but otherwise is default.
my firefox gui is broken too (the tabbar is transparent) I wonder if that has anything to do with it
the buttons work on the gui, but they are invisible.
I uninstalled and reinstalled java and mariadb
I tried building with apache ant.
I did an export JAVA_HOME at one point but I don't think it's set to anything anymore because I get nothing if I echo $JAVA_HOME. but ant seems to think it is /usr/lib/jvm/java? I don't know.
Suspicions: -incorrect java installation/versioning
-corrupted gnome gui
-I messed somthing up when I did yum update/all the yum installing and reinstalling that I did.
-swings setlookandfeel function, although unlikely because it doesnt work with simple programs that dont use that
Fairly new to everything. Software Engineering, This community, etc.
EDIT
Here is a piece of code that produces the same invisible button problem on my linux computer but works on windows:
package com.zetcode;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
public class QuitButtonEx extends JFrame {
public QuitButtonEx() {
initUI();
}
private void initUI() {
JButton quitButton = new JButton("Quit");
quitButton.addActionListener((ActionEvent event) -> {
System.exit(0);
});
createLayout(quitButton);
setTitle("Quit button");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private void createLayout(JComponent... arg) {
Container pane = getContentPane();
GroupLayout gl = new GroupLayout(pane);
pane.setLayout(gl);
gl.setAutoCreateContainerGaps(true);
gl.setHorizontalGroup(gl.createSequentialGroup()
.addComponent(arg[0])
);
gl.setVerticalGroup(gl.createSequentialGroup()
.addComponent(arg[0])
);
}
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
QuitButtonEx ex = new QuitButtonEx();
ex.setVisible(true);
});
}
EDIT
Pictures:
Functional buttons, but invisible and on semi transparent Jframe
EDIT: A tail -F /var/log/messages gives the following two errors: "gnome-session: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x2e00004 specified for 0x2e0001a (Progress..)" and "Window manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x2200048 ()"