OpenSuse 12.3 + Java Dual Display - java

I have a Java application that displays two JFrames on two separate monitors. On Ubuntu and Windows the application displays just fine. I can configure the JFrames to display on the monitors with the specified screen ID. However on openSUSE it keeps displaying on the same monitor regardless of the setting. What is different to openSUSE?
Here is some of the code that I use to determine on which monitor the JFrame must display:
GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for (int s = 0; s &lt screens.length; s++) {
GraphicsConfiguration configuration = null;
for (int c = 0; c &lt screens[s].getConfigurations().length; c++) {
if (AWTUtilities.isTranslucencyCapable(screens[s].getConfigurations()[c])) {
configuration = screens[s].getConfigurations()[c];
break;
}
}
if (configuration == null) {
configuration = screens[s].getDefaultConfiguration();
}
if (screens[s].getIDstring().equals[frame1_id]) {
frame1 = new JFrame("Frame 1", configuration);
frame1.setResizable(false);
frame1.setUndecorated(true);
frame1.setBounds(configuration.getBounds());
frame1.setVisible(true);
}
if (screens[s].getIDstring().equals[frame2_id]) {
frame2 = new JFrame("Frame 2", configuration);
frame2.setResizable(false);
frame2.setUndecorated(true);
frame2.setBounds(configuration.getBounds());
frame2.setVisible(true);
}
}

The OpenSuse implementation of GraphicsEnvironment may depend on the choice of a particular window manager. You'll have to experiment to find the optimal one.
Addendum: #bouncer comments, "I have used the Gnome window manager, which caused the problem. After switching to KDE, the problem was solved." See also 10 things to do after installing openSUSE 12.3.

Related

swing component not fully functioning into javafx application

I have two separate based on Swing and Javafx. Now i need to open Swing application inside Javafx Tab pane by below code
SyntaxTester ob = new SyntaxTester(filepath);
SwingNode swingnode = new SwingNode();
JComponent jcomp = new JComponent() {
};
jcomp.add(ob.getContentPane());
swingnode.setContent(jcomp);
BorderPane borderpane = new BorderPane(swingnode);
tab.setContent(borderpane);
Basically this Swing application is JEditorPane based editor. Swing application is added and working successfully inside Tab pane but the issue is that, there is hinting feature and after selecting text from hint, editor looses it's cursor and user again manually click on the editor. Although Swing application separately working fine. Please help me with resolve it. Thanks in advance.
This is what happening when user select from hint list.
if (jLstItems.getSelectedIndex() >= 0) {
result = jLstItems.getSelectedValue().toString();
} else {
result = jTxtItem.getText();
}
char pressed = evt.getKeyChar();
if (pressed != '\n') {
result += (pressed == '\t') ? ' ' : pressed;
}
setVisible(false);
target.replaceSelection(result);

SWT Shell is not raised above in xfwm4

I have problem with xfwm4. Using following code:
Shell s = windowVector.get(0).getShell();
s.setActive();
Shell window that is covered by other shells is not raised above. Using kwin (KDE window manager) it works correctly. Shell is created using following constructor:
shell = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);
In both cases SWT method:
OS.gdk_window_focus (window, OS.GDK_CURRENT_TIME);
is called but in xfwm4 shell get focus and is NOT raised above all other shell windows (in my application). Is this bug in xfwm4? Maybe some configuration issue or I am missig something.
EDIT:
I might be not precise. Shell that i try to setActive is "under" other child shells. Following code explains and simplfy what I am trying to achieve:
Shell mainShell = new Shell(Display.getDefault(), SWT.NO_TRIM);
mainShell.setBounds(0, 0, 300, 200);
mainShell.open();
final Shell shell1 = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);
shell1.setBounds(0, 0, 300, 200);
shell1.open();
Shell shell2 = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);
shell2.setBounds(0, 0, 300, 200);
shell2.open();
Thread thread = new Thread() {
#Override
public void run() {
try {
Thread.sleep(2000);
System.out.println("Raise shell1 above");
shell1.setActive();
}
catch(InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();
while( !mainShell.isDisposed()) {
if( !Display.getDefault().readAndDispatch()) {
Display.getDefault().sleep();
}
}
Display.getDefault().dispose();
This code works correctly in kwin, in xfwm4 shell1 stays "under" shell2 and remains hidden.
I can't speak about xfwm4 specifically but yes, many window managers have some form of input stealing prevention.
You don't want any random application being allowed to steal your focus or force your attention away from what you are doing.
How they implement this behaviour differs between window managers however. Most should (ideally) allow the currently focused application to give focus to a newly created window of that application but I imagine not all do that.

How can i run my java application for virtual screens?

In Linux, we have virtual screens like desktop 1, 2, 3, 4. Most cases we use desktop 1 (screen 1, with one monitor).
Now, my question is how can i tell my java application to launch on desktop 2 (screen 2, with one monitor)
By default when i run java -cp /var/tmp/SystemX.jar run.X it will launch in desktop 1, screen 1. Which is not my case.
Tried: following but did not helped cause, it runs for dual monitor scenario. Not what i am expecting.
screen = Toolkit.getDefaultToolkit().getScreenSize();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screenDevices = ge.getScreenDevices();
for (int i = 0; i < screenDevices.length; i++) {
System.out.println(screenDevices[i].getIDstring());
int screenWidth = 1024;
int screenHeight = 764;
if (screenDevices[i].getDisplayMode()!=null) {
DisplayMode dm = screenDevices[i].getDisplayMode();
screenWidth = dm.getWidth();
screenHeight = dm.getHeight();
}
System.out.println("[myResolution]: " + screenWidth + " " + screenHeight);
screen.width = screenWidth;
screen.height = screenHeight;
}
Follow up:
#!/bin/sh
(export DISPLAY=:0.0 && java -cp /var/tmp/SystemX.jar run.X) & (wmctrl -r "WINDOW_TITLE" -t DESKTOP_NUMBER)
* But what if my application is border less, when it has no window title ? how do i tell wmctrl ?
The borderless applications should still have window titles. (ie. xfce4-panel shows.) You can check what they are by using:
wmctrl -l
From the command line. If you're having a hard time figuring out which window is yours, try the command before you open it, then once it's open. That way, you can just look for the new window.

Java screen resolution change

I am following a series of tutorials on game development in Java by thenewboston on Youtube. I am at the point where I can make a fullscreen window, but the resolution refuses to resize to 800x600. I have tested vc, a GraphicsEnvironment.getDefaultScreenDevice object, and dm, a DisplayMode, and they don't seem to be the problem. I am running Snow Leopard. Any ideas?
if(dm != null && vc.isDisplayChangeSupported()){
try{
vc.setDisplayMode(dm);
System.out.println("Display mode set");
}catch(Exception ex){System.out.println("Despite the vc saying it is display change supported and the DM is not null, something went wrong");}
}
}
Add this code to your Core.java (or GameClient.java) class. The issue may be that you are not passing the required DM[] args to your ScreenManager.java class.
private static final DisplayMode modes[] = { //common monitor DMs
new DisplayMode(1366,768,32, DisplayMode.REFRESH_RATE_UNKNOWN), //1366x768px w/32-bit depth
new DisplayMode(1366,768,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(1366,768,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
new DisplayMode(800,600,32, DisplayMode.REFRESH_RATE_UNKNOWN), //800x600px w/32-bit depth
new DisplayMode(800,600,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(800,600,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
new DisplayMode(640,480,32, DisplayMode.REFRESH_RATE_UNKNOWN), //640x480px w/32-bit depth
new DisplayMode(640,480,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(640,480,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
};
I'm assuming that the error is with your public void setFullScreen(DisplayMode dm) method. In that case, the full syntax for this method is:
/*****************************************************************************
* #description: Creates window for program to run in, using appropriate DM
* #param DisplayMode dm
*/
public void setFullScreen(DisplayMode dm){
JFrame f = new JFrame();
f.setUndecorated(true); //no titlebars/scroll bars etc.
f.setIgnoreRepaint(true);
f.setResizable(false); //user cannot resize window
vc.setFullScreenWindow(f);
if(dm!=null && vc.isDisplayChangeSupported()){ //if DM is changeable
try {
vc.setDisplayMode(dm);
} catch (Exception e){/*Catch 'em all*/}
}
f.createBufferStrategy(2); //set # of screen buffers to 2
}//setFullScreen()
Noticed this was a mild necro-post after posting. Aaahh...

How to make transparent JLayeredPane() and JPanel()? It always shows background of super window

How can i completely make this grey panel as transparent, so that i can see only the button "Test" but not the grey box (JPanel or JLayeredPane)
Screen shot:
public class win extends JWindow
{
...
public win()
{
super(new JFrame());
layers = new JLayeredPane();
button = new JButton("close");
this.setLayout (new BorderLayout ());
..
button.setBackground(Color.RED);
button.setSize(200,200);
button.setLocation(0,20);
this.add("North", button);
JPanel p = new JPanel();
p.setOpaque(false);
p.setSize(300, 200);
p.setLocation(0, 0);
p.add(new JButton("Test"));
layers.add(p, new Integer(1));
layers.setSize(400,300);
layers.setLocation(400,50);
layers.setOpaque(false);
this.add("North", layers);
canvas.setSize(screenSize.width,screenSize.height);
this.add("North",canvas);
//com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.5f); // gives error in my Java version
}
}
Follow up: installed as recommended, but no luck yet.
ERROR not solved: Exception in thread "main" java.lang.UnsupportedOperationException: The TRANSLUCENT translucency kind is not supported.
Installed:
compiz-gnome.i686 0:0.9.4-2.fc15
Dependency Installed:
compiz-gtk.i686 0:0.9.4-2.fc15 compiz-plugins-main.i686 0:0.9.4-1.fc15
libcompizconfig.i686 0:0.9.4-1.fc15 protobuf.i686 0:2.3.0-7.fc15
Complete!
You have mail in /var/spool/mail/root
[root#example ~]# xdpyinfo | grep -i render
RENDER
You have mail in /var/spool/mail/root
[root#example ~]# xdpyinfo | grep -i comp
Composite
XVideo-MotionCompensation
[root#example ~]#
See this article or this article. Note that not all environments support all the features (translucency, per pixel transparencyt etc.) described in the article.
EDIT: On my system (Ubuntu 10.04.2 LTS, Sun java 1.6.0_26) the following code:
System.out.println("TRANSLUCENT supported: " + AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT));
System.out.println("PERPIXEL_TRANSPARENT supported: " + AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.PERPIXEL_TRANSPARENT));
System.out.println("PERPIXEL_TRANSLUCENT supported: " + AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT));
gives:
TRANSLUCENT supported: false
PERPIXEL_TRANSPARENT supported: true
PERPIXEL_TRANSLUCENT supported: true
EDIT2: Inspired by this discussion, I just installed and configured compiz and now the 'constant opacity level' slider of the web start application at the second article linked above suddenly can be moved to values smaller than 100% and the demo frame actually is translucent. Also the code snipped shown above now prints true for all three kinds of translucency/transparency. And AWTUtilities.setWindowOpacity(..) does not throw any more but produces a transparent window.

Categories