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.
Related
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);
I am doing a little java chatroom and I'm hitting an issue in this little bit of code. I'm not really sure how to pause the GUI from looping before the user sets an input. I have been using the commented out part of the code to pause it, but obviously I cannot have users on the GUI interacting with System.in.
while(username == null)
{
gui.setChat(" Hello! Please enter the usename you'd like to use for the duration of the chat!\n");
//gui.setChat(" Press Any Key To Continue...\n");
//new java.util.Scanner(System.in).nextLine();
username = gui.getInput();
}
short answer dont pause but if you do insist,you would have to take the multi thread approach or use JOptionPane as it blocks UI, and be careful with sleep and wake locks. here's a sample to do it
JFrame frame = new JFrame();
String bigList[] = new String[30];
for (int i = 0; i < bigList.length; i++) {
bigList[i] = Integer.toString(i);
}
JOptionPane.showInputDialog(
frame,
"Select options",
"List",
JOptionPane.PLAIN_MESSAGE,
null,
bigList,
"none");
}
i've been charged with a new software tool, and i m trying to test it.
PROBLEM:
I noticed a difference between mine GUI and the GUI of the tool run on the server:
a component is missing!
It is like if it's not shown, because i went in debug mode, and everything seems to be fine.
this image shows the different:
as you can see, the "Shaft end Dia" component is missing between the others 2 components.
CODE:
here is a code part. There are lots of items that get instantiate and added in the same way, but it doesn't apper on my pc (but they works well in others!!)
//PanelContainerClass
public class myInputPanel extends JPanel {
//myInputPanel fields
private JPanel myPanelMissing = null;
private JLabel jLabel_ofPanelMissing = null;
//myInputPanel is added to the mainFrame.
public myInputPanel() {
super();
initialize();
}
private void initialize() {
//a GridBagConstraints is created for each panel i m going to add to myInputPanel
GridBagConstraints gbc6 = new GridBagConstraints();
gbc6.gridx = 6;
gbc6.ipadx = 46;
gbc6.fill = GridBagConstraints.BOTH;
gbc6.insets = new Insets(0, 0, 0, 0);
gbc6.ipady = 0;
gbc6.gridy = 1;
//in a similiar way others gbc are instantiate
//a layout is given to myInputPanel
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 176, 0, 63, 0, 0, 0, 0, 0, 0, 0};
this.setLayout(gridBagLayout);
this.setSize(1185, 120);
this.setPreferredSize(new Dimension(1164, 143));
this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
// add others panels to myInputPanel using this.add(getPanel_X(), gridBagConstraintsN);
this.add(getmyPanelMissing(), gridBagConstraints6);
// add others panels to myInputPanel using this.add(getPanel_Y(), gridBagConstraintsM);
}
private JPanel getmyPanelMissing() {
if (myPanelMissing == null) {
//in debug it get inside the if
jLabel_ofPanelMissing = new JLabel();
jLabel_ofPanelMissing.setHorizontalAlignment(SwingConstants.CENTER);
jLabel_ofPanelMissing.setText("<html><body>" +
"<table cellspacing='0';cellpadding='0';> <tr> <td align='center'>Shaft end Dia</td> </tr> <tr> <td align='center'>[mm]</td> </tr></table>" +
"</body></html>");
GridLayout lay = new GridLayout();
lay.setRows(1);
myPanelMissing = new JPanel();
myPanelMissing.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED));
myPanelMissing.setLayout(lay);
myPanelMissing.add(jLabel_ofPanelMissing, null);
}
return myPanelMissing;
}
}
What i tried to do is:
running it via my Eclipse: FAIL
running the jar via .bat file: FAIL
(FAIL means it doesn't appear)
running the jar on the server via .bat file: WORKS
running the jar via eclipse on a colleague's computer by downloading the code via cvs: WORKS
running the jar via .bat on colleague's computer giving him my files: WORKS
running the jar via .bat on colleague's computer with files compiled by himself: WORKS
commenting the previous panelColumn on my code: WORKS!!!!
NOTE:
1) java version: 1.7.0.75 (either on mine pc either on my collegue pc)
2) OS: window 7 on Vbox (either me and collegue)
3) Eclipse Luna 4.x (same version again for both)
QUESTION:
Has anyone had this kind of problems?
Any idea about how to solve it?
Thank you all in advance!
You must increase the area of the your panel myInputPanel with the method setBounds()
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 < screens.length; s++) {
GraphicsConfiguration configuration = null;
for (int c = 0; c < 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.
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.