Flicker with heavyweight swing component and setVisible(false) on Linux
Hi All,
I'm using Java 6 update 14 on Ubuntu Jaunty.
I'm developing a GUI for a system running linux. I'm using the Swing framework for the GUI but need to include 3D animation accelerated in hardware. I'm using the JOGL framework for applying the 3D animations which supplies one with two swing-like components, the GLJPanel and GLCanvas. These two components are lightweight and heavyweight swing components respectively.
The difficulty arises when adding the heavyweight GLCanvas component into the gui. Often I need to do a setVisible(false) on the component in which case the GLCanvas hides correctly, but shows a flicker before the background is displayed. On digging a little deeper I found that because the GLCanvas is heavyweight, on linux it calls down to the sun.awt.X11 classes to do the setVisible(false) on hide. The very deepest call, the xSetVisible(false) method of the XBaseWindow class, causes the component to be replaced by first a grey backgound, and then the correct background. This intermediate grey background is causing the flicker.
The source for the sun.awt.X11 packages was not available with the standard JDK 6 but I've found the open jdk source which matches the steps taken by the call. The xSetVisible method is as follows:
0667: public void xSetVisible(boolean visible) {
0668: if (log.isLoggable(Level.FINE))
0669: log.fine("Setting visible on " + this + " to " + visible);
0670: XToolkit.awtLock();
0671: try {
0672: this .visible = visible;
0673: if (visible) {
0674: XlibWrapper.XMapWindow(XToolkit.getDisplay(),
0675: getWindow());
0676: } else {
0677: XlibWrapper.XUnmapWindow(XToolkit.getDisplay(),
0678: getWindow());
0679: }
0680: XlibWrapper.XFlush(XToolkit.getDisplay());
0681: } finally {
0682: XToolkit.awtUnlock();
0683: }
0684: }I've found that the XlibWrapper.XFlush(XToolkit.getDisplay()) line (680) causes the grey to appear and then the XToolkit.awtUnlock(); line repaints the correct background.
Using the lightwieght GLJPanel resolves this issue as it is a light weight component but unfortunately I'm unable to use it as the target system does not have the GLX 1.3 libraries required because of intel chipset driver issues (it has GLX 1.2). I cannot enable the opengl pipline either (-Dsun.java2d.opengl=True) for the same reason.
Is there a way to configure a heavyweight component to avoid the operation in line 680? As far as I can tell, the flicker would disappear and the display would still be correctly rendered had this line not been executed. This problem is not present in windows.
I've put together a minimal example of the problem. It requires the JOGL 1.1.1 libraries in the classpath. They can be found here: [JOGL-download|https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=11509&expandFolder=11509&folderID=11508]
I've also found that running the program with the -Dsun.awt.noerasebackground=true vm argument reduces the flicker to just one incorrect frame.
The program creates a swing app with a button to switch between the GLCanvas and a normal JPanel. When switching from the GLCanvas to the JPanel a grey flicker is noticeable on Linux. Step through the code in debug mode to the classes mentioned above to see the grey flicker frame manifest.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.media.opengl.GLCanvas;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
public class SwitchUsingJInternalFrameSwappedExample {
private static JPanel glPanel;
private static JPanel mainPanel;
private static JPanel swingPanel1;
private static boolean state;
private static JInternalFrame layerFrame;
private static GLCanvas glCanvas;
public static void main(String[] args) {
state = true;
JFrame frame = new JFrame();
frame.setSize(800, 800);
frame.setContentPane(getMainPanel());
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setBackground(Color.GREEN);
// The main component.
public static JPanel getMainPanel() {
mainPanel = new JPanel();
mainPanel.setBackground(new Color(0, 0, 255));
mainPanel.setBorder(new EmptyBorder(new Insets(20, 20, 20, 20)));
mainPanel.setLayout(new BorderLayout());
mainPanel.add(getButton(), BorderLayout.NORTH);
mainPanel.add(getAnimationPanel(), BorderLayout.CENTER);
return mainPanel;
// Switch button.
private static JButton getButton() {
JButton button = new JButton("Switch");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switchToOpenGl();
return button;
// Do the switch.
protected static void switchToOpenGl() {
// Make the OpenGL overlay visible / invisible.
if (!state) {
glCanvas.setVisible(false);
} else {
glCanvas.setVisible(true);
state = !state;
// Normal swing panel with buttons
public static JPanel getNormalPanel() {
if (swingPanel1 == null) {
swingPanel1 = new JPanel();
for (int i = 0; i < 10; i++) {
swingPanel1.add(new JButton("Asdf" + i));
swingPanel1.setBackground(Color.black);
return swingPanel1;
// Extra panel container just for testing whether background colors show through.
public static JPanel getAnimationPanel() {
if (glPanel == null) {
glPanel = new JPanel(new BorderLayout());
glPanel.setBorder(new EmptyBorder(new Insets(20, 20, 20, 20)));
glPanel.setBackground(Color.YELLOW);
glPanel.add(getLayerFrame(), BorderLayout.CENTER);
return glPanel;
// A component that has two layers (panes), one containing the swing components and one containing the OpenGl animation.
private static JInternalFrame getLayerFrame() {
if (layerFrame == null) {
// Create a JInternalFrame that is not movable, iconifyable etc.
layerFrame = new JInternalFrame(null, false, false, false, false);
layerFrame.setBackground(new Color(155, 0, 0));
layerFrame.setVisible(true);
// Remove the title bar and border of the JInternalFrame.
((javax.swing.plaf.basic.BasicInternalFrameUI) layerFrame.getUI())
.setNorthPane(null);
layerFrame.setBorder(null);
// Add a normal swing component
layerFrame.setContentPane(getNormalPanel());
// Add the OpenGL animation overlay on a layer over the content layer.
layerFrame.setGlassPane(getGLCanvas());
return layerFrame;
// OpenGL component.
public static GLCanvas getGLCanvas() {
if (glCanvas == null) {
glCanvas = new GLCanvas();
glCanvas.setBackground(Color.CYAN);
return glCanvas;
}
Oracle employees typically don't read these forums, you can report bugs here: http://bugs.sun.com/bugdatabase/
Similar Messages
-
Problem with java swing button and loop
Problem with java swing button and loop
I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
When I click on start button it must do next:
Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
And when I click on stop button it must do next:
Start button must set enabled and selected and Stop button must set disenabled.
Field status is set to 0.
This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
There is java code, so you can get better picture:
/** start button */
public void gStart_ActionEvents() {
try {
ivjGStart.setEnabled(false);
ivjGStop.setEnabled(true);
ivjGStop.setSelected(true);
getJTextPane1().setText("Program is running ...");
Status = 1;
} catch (Exception e) {}
/** stop button */
public void gStop_ActionEvents() {
try {
ivjGStart.setEnabled(true);
ivjGStart.setSelected(true);
ivjGStop.setEnabled(false);
getJTextPane1().setText("Program is NOT running ...");
Status = 0;
} catch (Exception e) {
/** procedure IzvajajNeprekinjeno() */
public void IzvajajNeprekinjeno() { //RunLoop
try {
int zamik = 2000; //delay
do {
Thread.sleep(zamik);
PreberiDat(); //procedure
} while (Status == 1);
} catch (Exception e) {
So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
Any help will be appreciated.
Best regards,
TomiThis is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
Since java is task-based this will happen if you do like this:
1. Button "Start" is pressed. Thread running: GUI_Thread
2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
5. Call PreberiDat(). Thread running: GUI_Thread
6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
http://java.sun.com/docs/books/tutorial/uiswing/index.html
This tutorial explains how to build a multi threaded gui.
/Lime -
Difference between dispose and setVisible(false)?
What is the difference between dispose() and setVisible(false)? The only difference I see is that setVisible(false) and bring a window back by using a true flag, while dispose() cannot. Other than that, they appear to do the same thing.
If I want to get rid of a window (with no intention of bring it back), which should I use?
Also, is there a memory advantage to using one or the other?
Thanks for any responses.setVisible just makes it visible or not...the advantage would be that you would not have to constantly spend time creating a new object, downside is it sits in memory until you really need it again.
dispose will actually tell the gc it's ok to clean up the object...and you would have to make a new one each time you wanted to use it...advantage, frees up ram, disadvantage, takes time to create objects over and over. -
Probleme with swing component and keyEvt
hi ,
I program this JFrame , when it is empty ( without the Jbutton ) the key Event works fine , but when I add the Jbutton the key event doesn't work anymore.
I try some focus method but it doesn't seem to work , can you tell me what i can do ...
Thx.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame implements KeyListener
private JButton jb_;
public test()
setSize(320,200);
this.addKeyListener(this);
this.getContentPane().setLayout(null);
jb_ = new JButton("button");
jb_.setBounds(10,10,100,100);
this.getContentPane().add(jb_);
public void keyPressed(KeyEvent e) { System.out.println("OK"); }
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
public static void main(String args[])
test t = new test();
t.setDefaultCloseOperation(EXIT_ON_CLOSE);
t.show();i've solved it with creating a JTextArea and putting the button in there
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame implements KeyListener
private JButton jb_;
private JTextArea area;
public Test()
area = new JTextArea(200,200);
area.setEditable(false);
area.addKeyListener(this);
jb_ = new JButton("button");
jb_.setBounds(10,10,100,100);
getContentPane().add(jb_);
getContentPane().add(area);
setSize(300,300);
public void keyPressed(KeyEvent e)
System.out.println("OK");
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
public static void main(String args[])
Test t = new Test();
t.setDefaultCloseOperation(EXIT_ON_CLOSE);
t.show();
} -
Please help me with centering a component and clearing a JRadioButton
Hi, could someone help me to cener the label and clear the selected JRadioButton?
I have put a comment beside the problematic place. Thanks a lot! ann
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ButtonAction extends JPanel implements ActionListener {
private JRadioButton button1, button2;
private JButton send, clear;
private JTextField text;
private JLabel label;
private ButtonGroup group;
public ButtonAction() {
setPreferredSize(new Dimension(300, 200));
setLayout(new GridLayout(0, 1, 5, 5));
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
setBorder(BorderFactory.createLineBorder(Color.blue));
JPanel p1 = new JPanel();
button1 = new JRadioButton("Button One");
button2 = new JRadioButton("Button Two");
group = new ButtonGroup();
group.add(button1);
group.add(button2);
p1.add(button1);
p1.add(button2);
JPanel p2 = new JPanel();
send = new JButton("Send");
clear = new JButton("Clear");
label = new JLabel(" ");
label.setAlignmentX(Component.CENTER_ALIGNMENT); //this doesn't work
send.addActionListener(this);
clear.addActionListener(this);
p2.add(send);p2.add(clear);
add(p1); add(p2); add(label);
public void DisplayGUI(){
JFrame frame = new JFrame();
frame.getContentPane().add(this);
frame.pack();
frame.setVisible(true);
public String getButton(){
String result = "";
if (button1.isSelected())
result += "\t You have clicked the first button";
else if (button2.isSelected())
result += "\t You have clicked the second button";
return result;
public void setButton(){ // this method doesn't work
if (button1.isSelected() == true)
button1.setSelected(false);
else if (button2.isSelected() == true)
button2.setSelected(false);
public void actionPerformed (ActionEvent e) {
if (e.getSource() == send) {
label.setText(getButton());
else if (e.getSource() == clear) {
setButton();
label.setText("no button is selected");
public static void main(String[] args) {
ButtonAction ba = new ButtonAction();
ba.DisplayGUI();
}setHorizontalAlignmentX(Component.CENTER_ALIGNMENT) is a container method and I don't think it does what you think. Try this instead:label = new JLabel("Some text");
//label.setHorizontalAlignmentX(Component.CENTER_ALIGNMENT); //this doesn't work
label.setHorizontalAlignment(SwingConstants.CENTER);When you alter the state of a radio button you should probably use the group methods - because the group "coordinates" the state of the buttons as a whole. Note that setSelection() isn't quite like a user click in that it doesn't fire a method. Now, in your case you are essentially clearing the selection of the group and ButtonGroup provides a method for that. public void setButton(){ // this method doesn't work
if (button1.isSelected() == true)
button1.setSelected(false);
else if (button2.isSelected() == true)
button2.setSelected(false);
group.clearSelection();
}Note we don't usually write if(foo == true), it's enough to say if(foo).
You will get better and faster help from the Swing forum and it helps everyone if posts are made to the right place. http://forum.java.sun.com/forum.jspa?forumID=57 -
Dispose() and setVisible(false)
I'm developing a program containing a wizard and I think the memory is not correctly managed.
Here is an example of the implementation of two dialogs :
public class A extends JDialog {
private B nextDialog= null;
nextButton.addActionListener(new ActionListener() {
setVisible(false);
if (nextDialog== null) {
nextDialog= new B();
nextDialog.setVisible(true);
public class B extends JDialog {
private A previousDialog= null;
previousButton.addActionListener(new ActionListener() {
setVisible(false);
if (previousDialog== null) {
previousDialog= new A();
previousDialog.setVisible(true);
Whenever I click on the nextButton, a new instance of the nextDialog is created and the present dialog is hidden.
Similarly, whenever I click on the previousButton of the second Dialog, a new instance of the first Dialog is created and the present dialog is hidden.
Thus, if I click on the nextButton then previousButton, nextButton, previousButton, etc... a lot of instances will be created.
Should I use dispose() instead of setVisible(false) ?
In this case each instance will be destroyed, won't it ?
Should I use the singleton pattern ?
In this case, the setVisible() method would be preferred to the destroy method ?
Could you help me ?> int visIndex = getVisibleIndex(cont);
String name = cont.getComponent(visIndex).getName();
public static int getVisibleIndex(Container cont) {
if(cont != null && cont.getLayout() instanceof
CardLayout) {
Component[] comps = cont.getComponents();
for(int x = 0; x < comps.length; x++) {
if(comps[x].isVisible()) {
return x;
return -1;
Thanks for re-phrasing my point in a much more understandable way (it was late last night) -
No vídeo in my TV with original cable component and Ipad air, help please.
How can I see my Ipad air and moviles in my TV with the original component cable, at the moment no works.
Help please.Hey adbridge683,
This is usually in reference to USB issues. This article has great step by step troubleshooting, so you can see the steps first hand yourself to try. http://support.apple.com/kb/ts3694#error50
There's really only about 7 things to look for in there, and I hope that one of them helps you out!
Let me know.
-Regards -
Create a PDF file from swing component and print
Hi,
Suppose i have a JFrame where in i add a JScrollpane which has a JPanel with some painting on it, suppose i want to create a pdf file of the total JPanel, and not of what i see on screen like taking a screen shot, or print the total JPanel, and not only the screen that is displayed
how can i do it
I am attaching the code below, how can i create a pdf for MyPanel and print it
//start code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestDisplaySize extends JFrame
JScrollPane scrollPane ;
public TestDisplaySize()
super("layered pane");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
MyPanel panel = new MyPanel();
scrollPane = new JScrollPane(panel);
Container contentPane = this.getContentPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
setSize(new Dimension(800,600));
this.setVisible(true);
JViewport viewPort = scrollPane.getViewport();
class MyPanel extends JPanel
public MyPanel()
setPreferredSize(new Dimension(2000,600) );
this.setBackground(Color.white);
this.setOpaque(true);
public void paintComponent(Graphics g)
super.paintComponent(g);
setBackground(Color.white);
Rectangle r = scrollPane.getViewport().getViewRect();
g.setClip((Shape)r);
g.setColor(Color.blue);
int x = 0;
for(int i = 0; i < 60; i++)
x +=60;
g.drawLine(x, 0, x, 600);
g.drawString(String.valueOf(i), x, 50);
public static void main(String args[])
new TestDisplaySize();
//end codecreate a class wich implements printable, redefine the print method of this class with the this you want to print
and at the end of the constructor...
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat myFormat = new PageFormat();
myFormat.setOrientation(PageFormat.LANDSCAPE);
myFormat.setPaper(ps.getMyPaper());
printJob.setPrintable(this, myFormat);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception pe) {
System.out.println(pe); -
Help needed-regarding swing component and linux
Hi
I am trying to run java program on Linux machine which doesn't have GUI support. Due to that following exception is throwing,
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
at org.jfree.ui.ApplicationFrame.<init>(ApplicationFrame.java:66)
at ismschart.AbstractIsmsChart.<init>(AbstractIsmsChart.java:82)
at ismschart.CHART_DAILY_PEAK_ACTIVITY.<init>(CHART_DAILY_PEAK_ACTIVITY.java:56)
at ismschart.jChartTbl.createIsmsChart(jChartTbl.java:197)
at ismschart.jChartTbl.main(jChartTbl.java:98)
Can any one tell me, How to overcome this?
Is there any tool which provides UI support for Linux?
Thnaks
-Ravicut and paste from API
Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.
environment issue -
SetVisible(false) doesn't work with JDialog
Hi evry one in this forum, i am using JDialog to get some inputs from user, when the user click on the ok button, i start processing and the JDialog must be invisible, for that i use myJdialog.setVisible(false) methode, but the JDialog is still visible, i may be use the wrong component or there is a problem.
I write some thing like this:
actionPerformed(){
//getinputs and make some controls
if(test){
this.setVisible(false);
//some traitments
//some traitments
}I think there is no thing wrong, not? what happen?I am sorry, this is some thing complicated:
public class OpenKeyStore
extends JDialog
implements ActionListener, KeyListener, WindowListener {
JPanel jPanel1 = new JPanel();
Border border1;
JLabel lprivateKey = new JLabel();
JLabel lkeyPass = new JLabel();
JTextField tkeyStorePath = new JTextField();
JPasswordField tkeyPass = new JPasswordField();
JButton bvalidate = new JButton();
JButton bopenKeyStore = new JButton();
JButton breset = new JButton();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JFileChooser jfc = new JFileChooser();
JOptionPane jop = new JOptionPane();
private UploadParameters uploadParameters;
private OpenRequest openRequest;
private OpenResponse openResponse;
private CheckCertRequest checkCertRequest;
private CheckCertResponse checkCertResponse;
private WaitBox waitBox;
UploadApplet uploadApplet;
public OpenKeyStore(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
catch (Exception ex) {
ex.printStackTrace();
public OpenKeyStore(UploadApplet uploadApplet) {
this(null, "", false);
this.uploadApplet = uploadApplet;
private void jbInit() throws Exception {
uploadParameters = new UploadParameters();
border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white,
new Color(148, 145, 140));
this.setModal(true);
this.setTitle("Ouvrir");
jPanel1.setBorder(border1);
jPanel1.setLayout(gridBagLayout1);
jPanel1.setSize(400, 140);
lprivateKey.setText("Cl� priv�e :");
lkeyPass.setText("Mot de passe : ");
bopenKeyStore.setActionCommand("openKeyStore");
bopenKeyStore.setText("Ouvrir");
bopenKeyStore.setMnemonic(KeyEvent.VK_O);
bopenKeyStore.addKeyListener(this);
bopenKeyStore.addActionListener(this);
bvalidate.setActionCommand("bvalidate");
bvalidate.setText("Valider");
bvalidate.setMnemonic(KeyEvent.VK_V);
bvalidate.addKeyListener(this);
bvalidate.addActionListener(this);
breset.setActionCommand("breset");
breset.setText("R�etablir");
breset.setMnemonic(KeyEvent.VK_R);
breset.addKeyListener(this);
breset.addActionListener(this);
tkeyStorePath.setText("C:\\y.p12");
tkeyStorePath.addKeyListener(this);
tkeyPass.setText("y");
tkeyPass.addKeyListener(this);
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
this.getContentPane().setSize(410, 150);
jPanel1.add(lprivateKey, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(lkeyPass, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(tkeyStorePath, new GridBagConstraints(1, 0, 1, 1, 10.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 5), 150, 0));
jPanel1.add(tkeyPass, new GridBagConstraints(1, 1, 1, 1, 10.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 5), 200, 0));
jPanel1.add(bvalidate, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST,
GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(bopenKeyStore, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(breset, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
this.initFileChooser();
this.tkeyStorePath.requestFocus();
this.pack();
Rectangle screenRect = this.getGraphicsConfiguration().getBounds();
this.setLocation(
screenRect.x + screenRect.width / 2 - this.getSize().width / 2,
screenRect.y + screenRect.height / 2 - this.getSize().height / 2);
this.show();
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("openKeyStore")) {
this.showOpenFileChooser();
return;
if (e.getActionCommand().equals("bvalidate")) {
this.acte();
return;
if (e.getActionCommand().equals("breset")) {
this.reset();
return;
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (e.getSource() == this.bopenKeyStore ||
e.getSource() == this.tkeyStorePath) {
this.showOpenFileChooser();
return;
if (e.getSource() == this.bvalidate ||
e.getSource() == this.tkeyPass) {
this.acte();
return;
if (e.getSource() == this.breset) {
this.reset();
return;
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {
private void initFileChooser() {
jfc.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
return (f.getName().endsWith(".p12") || f.isDirectory());
public String getDescription() {
return "(.p12) fichier key store";
jfc.setDialogTitle("Selectionnez un fichier .p12");
jfc.setMultiSelectionEnabled(false);
jfc.setDialogType(JFileChooser.OPEN_DIALOG);
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
private void showOpenFileChooser() {
int returnVal = jfc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION && jfc.getSelectedFile() != null &&
jfc.getSelectedFile().exists()) {
this.tkeyStorePath.setText(jfc.getSelectedFile().getAbsolutePath());
this.tkeyPass.requestFocus();
else {
this.tkeyStorePath.requestFocus();
private void reset() {
this.tkeyStorePath.setText("");
this.tkeyStorePath.requestFocus();
this.tkeyPass.setText("");
private void acte() {
//waitBox = new WaitBox();
openRequest = new OpenRequest();
openRequest.setStorePath(this.tkeyStorePath.getText());
if (!openRequest.isValide()) {
jop.showMessageDialog(null,
"S.V.P v�rifiez le chemin de votre cl�!",
"Echec...", jop.ERROR_MESSAGE);
this.tkeyStorePath.requestFocus();
this.tkeyStorePath.selectAll();
return;
openRequest.setStorePass(new String(this.tkeyPass.getPassword()));
openRequest.setReciverCert(this.uploadParameters.getReciverCert());
OpenAction openAction = new OpenAction(this.openRequest);
try {
while (openResponse == null) {
Thread.sleep(100);
openResponse = (OpenResponse) openAction.getResponse();
catch (Exception e) {
e.printStackTrace();
if (openResponse.getSenderPK() == null) {
jop.showMessageDialog(null,
"S.V.P entrez une cl� valide, \n ou verifiez votre mot de passe !",
"Echec...", jop.ERROR_MESSAGE);
this.tkeyStorePath.requestFocus();
this.tkeyStorePath.selectAll();
return;
if (openResponse.getCaCert() == null) {
this.setVisible(false);
jop.showMessageDialog(null,
"Votre cl� n'est pas valide.\n contactez votre administrateur!",
"Echec...", jop.ERROR_MESSAGE);
this.gotoPreviousPage();
return;
if (this.uploadParameters.getCipher() && openResponse.getReciverCert() == null) {
this.setVisible(false);//*********************Does not work
jop.showMessageDialog(null,
"Vous ne disposez pas de certificat pour votre correspondant!",
"Echec...", jop.ERROR_MESSAGE);
this.gotoPreviousPage();
return;
this.setVisible(false);//*********************Does not work
if (this.uploadParameters.getCipher()) {
String compte;
while (true) {
compte = (String) JOptionPane.showInputDialog(
this, "S.V.P. entrez le compte de votre correspondant : ",
"Customized Dialog", JOptionPane.PLAIN_MESSAGE, null, null, "");
if (compte == null) {
//gotoprevious page
return;
this.checkCertRequest.setCommunName(compte);
if (this.checkCertRequest.isValide()) {
this.checkCertRequest.setReciverCert(this.openResponse.getReciverCert());
this.checkCertRequest.setCaCert(this.openResponse.getCaCert());
CheckCertAction checkCertAction = new CheckCertAction(this.
checkCertRequest);
try {
while (this.checkCertResponse == null) {
Thread.sleep(100);
this.checkCertResponse = (CheckCertResponse) checkCertAction.
getResponse();
catch (Exception e) {
e.printStackTrace();
if (this.checkCertResponse.getReciverCertState()) {
return;
else {
jop.showMessageDialog(null,
"L'identit� de votre correspondant n'a pas pu etre v�rifier!",
"Echec...", jop.ERROR_MESSAGE);
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
this.gotoPreviousPage();
public void gotoPreviousPage() {
} -
VB 2008, CR component and MS Acc: how to access with database(not user) pwd
These are the detail of the query:
1. MS Access 2003 and later database via OLE DB provide for entry of a u201Cdatabase passwordu201D to provide additional protection.
2. In VB 2005 and in VB2008 environment I have managed to establish a connection with a database password and open recordsets using ADO connection. See code below.
Note. stPassword is user password and stDBPassword is database password with the following code:
With cnn
'set connection string
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0; Password=" & stPassword & ";Data Source=T:\CPI.mdb;User ID=" & stUser & ";Persist Security Info=False;" & "Jet OLEDB:System database=t:\cpi.mdw;Jet OLEDB:Database Password=" & stDBPassword
.Open()
End With
3. When using Crystal Reports component supplied with VS 2008 I can only provide USER NAME and USER PASSWORD. No information is available how and where to enter DATABASE PASSWORD to the Crystal Reports component. As a result, Crystal Reports Viewer starts to run. Obviously access is denied because no DATABASE PASSWORD has been provided to the component. A common dialog comes up to enter database password.
4. User does not necessarily need know the DATABASE password and I am not interested in providing the database password to every user who runs reports. In this project database password serves as a form of protection from tampering with the database structure and contents through the use MS Access to access the database.
5. Here is the code to demonstrate logon via Crystal Component described above:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
And then in a sub:
Dim cnnInfo As ConnectionInfo = New ConnectionInfo()
'cnnInfo.DatabaseName = cnn.DefaultDatabase
cnnInfo.UserID = stUser
cnnInfo.Password = stPassword
No place to input DATABASE password!!!
Does anyone know how can I input database password or provide a connection string or maybe ADO connection object which is opened within the project code.It seems like it is not possible to set the DB level password with the CR Visual Studio bundled version (as stated in the following KB c2010267). You would need to use the full version, and use the code below:
Symptom
A VB .NET application uses Crystal Reports for Visual Studio .NET as the reporting development tool.
A report is created that connects to a password protected Microsoft Access Database.
How do you pass a password (for database level security) or a password and user ID (for user level security) at runtime using the different connection methods(Native/ODBC/OLEDB)?
Resolution
To pass the database level password or a user level
userid/password at runtime, use the following code
sample:
'Add the following namespaces to the top of the code
'page
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Dim crReportDocument As New ReportDocument()
Dim crConnectionInfo as New ConnectionInfo
Dim crtableLogoninfo As New TableLogOnInfo()
Dim CrTables As Tables
Dim CrTable As Table
crReportDocument = New CrystalReport1()
With crConnectionInfo
<**Insert code from below depending on the type of
connection and the version of Crystal Reports you are
using**>
End With
CrTables = crReportDocument.Database.Tables
For Each crTable in crTables
crTableLogonInfo.ConnectionInfo =
crConnectionInfo
CrTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
CrystalReportViewer1.ReportSource =
crReportDocument
Database Level Security
" For Native and ODBC connections, use the following
code:
.Password = "Password"
" For OLEDB connections, use the following code:
.Password = chr(10) + "Password"
====================
NOTE:
You cannot set a database level password when
using Crystal Reports for Visual Studio .NET 2002 or
2003.
====================
User Level Security
" For ODBC and OLEDB connections, use the following
code:
.Password = "Password"
.UserID = "UserID"
For ODBC connections, in the ODBC data source, you
have to point the system database to the appropriate
MDW file. In addition, click the 'Advanced' button and
specify the User ID and password.
====================
NOTE:
You cannot set a user level password when using
a native connection with Crystal Reports 9.2 and
Crystal Reports for Visual Studio .NET 2002 or 2003.
This KB is valid for:
CRYS REPORTS VS .NET.9.1
CR FOR VS .NET 2005
CR FOR VS .NET 2008 -
I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.
Will not work. To my knowledge, dual converting like that isn't supported. The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.
-
I was in a car collision and need proof of my location when I called 911. The Police Dept., refused to respond, since there were no injuries.
Now, I have a dispute with the other driver who is falsely stating accident happened at another intersection. In addition of calling 911 twice, I also took pictures of damages. Unfortunately, I did not take pictures of the intersection signs.
My AT&T carrier states that this info. can only be disclosed by a subpoena. My insurance carrier states that they will not subpoena this info., since it is a civil case only.
The Police Department does not keep records of calls they do not attend to.
How can I get this location info. from my i phone device if at all possible?
Thanks,
Pecosa
iPhone 4, iOS 6.0.1Johnathan Burger,
I did take photos of the damages to car and license plates, but NOT the intersection signs.
How do I get the GPS Data in the exit data of photos? Please advise.
Thanks,
Message was edited by: Pecosa
Message was edited by: Pecosa -
I updated my iMac to 10.7.3 and about an hour later the screen began to flicker with a gray line on the upper side, and it also flicker green and red small pixel lines all over the screen, mainly green. The computer froze with these pixels, so I shut it off and restarted it, and there were this green lines everywere. So I turned it off, and the next day I turned it on and it began to work just fine, but suddenly the same thing happened again, and when I restart the computer again there are these green and some red pixels everywere.
I've read 10.7.3 is giving people many problems, but I never saw that it gave one like this. How can I fix this, or what will Apple do to fix this problem they caused me with their update.
ThanksContact Apple Service, iMac Service or Apple's Express Lane. Do note that if you have AppleCare's protection plan and you're within 50 miles (80 KM) of an Apple repair station, you're eligible for onsite repair since yours is a desktop machine.
-
Problem with setVisible(false)
I everybody!!
I have a some panels in a JFrame, disposed ones underneath the others. But when I make one of the bottom invisble doing:
jPanel.setVisible(false);
the ones in the top becomes down!!
Is there any way to avoid this?
Thanks in advanceIf you have multiple panels sharing the same area in a JFrame then you should be using a [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout.
Or you need to remove the old panel before adding the new panel.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
Maybe you are looking for
-
Can iBooks Author hide sections of a book to be revealed only after the user selects a correct choice?
-
Confirming allowing several dialog box permanently for an plug in.
I'm using the InTranslator 4.0 plug-in. But can't find any way to permanently confirm to Firefox to allow all the necessary dialog windows. Now I have to manual allow them every time i run an translation whit spell check activated. I have an print sc
-
Syncronisation time takes ages
I recently purchased an Ipod Touch but after connecting to the computer it takes more than 2 hours to syncronise with my IPOD Touch - I thought this was just because it was the first time - but every time since it takes more than 2 hours - I do not t
-
Material Availability Check Web service required
Hi, I am after a standard web service that accepts a material code and returns a plant/location/s and availability/quantity. ex: input: code:CMA0001 output: plant: E100 QTY 3 plant: E200 QTY 1 Any help much appreciated Darren
-
I can't get my contacts on my iphone to sync with my icloud