Newbie: ActionListener visibility problem
Hello,
i'm new to java, and i'm working on a simple small project.
I've got a problem with the visability of an object.
Maybe you have a look at my code:
Used Class
public class System1T1P extends xyz {
public void switchOn() {
// Important READ HERE
// Important READ HERE
// Important READ HERE
System.out.print("old"); // for debug
// Important READ HERE
// Important READ HERE
// Important READ HERE
public void start() {
public void update() {
// has to be implementated
class TimerListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
update();
Timer oTimer = new javax.swing.Timer(1000, new TimerListener());
}Main Class
public class GUI_1T1P extends GUI_General {
// System
private System1T1P oSys1T1P = new System1T1P() {
public void update() {
public void switchOn() {
// Important READ HERE
// Important READ HERE
// Important READ HERE
System.out.print("mimi"); // for debug it returns something else
// Important READ HERE
// Important READ HERE
// Important READ HERE
// Screen Size
GraphicsEnvironment oGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle oRectangle_ScreenSize = oGraphicsEnvironment.getMaximumWindowBounds();
// Gui
JFrame oJFrame;
JButton oJButton_exit;
JButton oJButton_on;
JButton oJButton_running;
GC_1T1P oGC_1T1P;
public GUI_1T1P() {
// Important READ HERE
// Important READ HERE
// Important READ HERE
oSys1T1P.switchOn(); // Returns "mimi" to out
// Important READ HERE
// Important READ HERE
// Important READ HERE
oJFrame = new JFrame("System 1T1P");
oJFrame.getContentPane().setLayout(null);
oJFrame.addWindowListener(new WindowListener() {
public void windowClosed(WindowEvent arg0) {}
public void windowActivated(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
System.exit(0);
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
oJButton_exit = new JButton("Hide");
oJButton_exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
hide(); // works without problems
oJButton_on = new JButton("Activate");
oJButton_on.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// IMPORTANT This is the Problem
GUI_1T1P.this.oSys1T1P.switchOn(); // returns "old" instead of "mimi"
// seems to be a completely diffrent instance of oSys1T1P
// oSys1T1P.switchOn(); // returns also "old"
oJButton_running = new JButton("Run");
oJButton_running.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// IMPORTANT This is the Problem
GUI_1T1P.this.oSys1T1P.start(); // also uses the wrong instance
// oSys1T1P.start(); // also uses the wrong instance
// set positions
// add elements to window
// finalize
oJFrame.pack();
// init window
public void hide() {
oJFrame.setVisible(false);
}maybe its easy to you but i'm researching for it about two days ...
thank you for reading and answering.
Nem
okay then i ask it in the short way
public class MyClass extends AbstractClass {
// System
private AnyClass objectOfAnyClass = new AnyClass() {
public void aFunction() { // this is a redefined function
System.out.print("new output"); //This was System.out.print("old output"); before
void bFunc() {
objectOfAnyClass.aFunction(); //By calling aFunction here it prints "new output"
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
objectOfAnyClass.aFunction(); // if i call it from here it prints "old output"
// Part where al is used
} My question is simply: why does it print "old output" inside of the actionlistener?
Thanks and sorry ;(
Edited by: Nemcija on Nov 12, 2008 5:53 AM
Similar Messages
-
Email visibility problem fixed?
Since I don't know how to check (and I'm really not that interested) I was wondering if someone can confirm what this e-mail I got from Sun seems to be saying:
In other words, did they fix the e-mail hole?
Hello,
Thank you for writing. I am very sorry for this
trouble and any inconvenience you experienced
as a result. We have followed up on this matter
and it has been fixed.
Sincerely,
Sun Web Team
Sun Microsystems, Inc.
name: ***
url: http://forum.java.sun.com/forum.jspa?forumID=31
descself: Software Development
comments: The privacy hole mentioned the thread:
http://forum.java.sun.com/thread.jspa?messageID=3938145 is serious.
I don't feel like I can trust with my privacy details with something likethis
going on. Please fix this soon. I would appreciate being informed of progresson
this hole.
mailfrom: ***
mailsubject: Forums or Community
thanks_url: /contact/thankyou.jsp
category: sdn
Time Stamp: Tue Oct 18 15:31:02 PDT 2005
Contact Page Referer: http://forum.java.sun.com/forum.jspa?forumID=31
Remote host : ***
Remote IP address : ***
Remote Agent : ***
Script : http://developers.sun.com/jsp_utils/form_mailer.jsp
Referring URL : ***
---Yes, the email visibility problem has been fixed.
-
T70 / tx9 touch screen visibility problems - patchy somewhat iridescent hazing
I currently own a tx9 that has served me well for a year and a half. in the past few months, the surface of the touch screen developed an iridescent patchy filmy look that interferes with my ability to know if the picture I am about to take is in crystal clear focus, and as you might imagine, my photos have suffered as a result. the screen functions, and in certain lighting conditions (indirect mid morning light inside my house) I can mostly see what's going on, but generally, it is as though I am taking pictures mostly on faith, and do not know how the images look for certain from a clarity perspective until I upload them to my pc. think of my problem as sort of an oil slick on water, but not swirly lore more like, peeling paint although nothing has peeled off that I am aware of) is there anything at all that can help remedy this visibility problem or prevent it on future t series camera purchases? I have tried simply wiping it, using a lens cloth dampened with lens cleaner, and today just purchased a zagg screenprotector that I have yet not attempted to install as I ran across this forum. i have for the most part kept my camera in a lined carrying case when not in use and in travels. is it advisable to use a screen protector for the oled screen on the tx66? if so, what kind? ( I honestly would prefer to salvage my tx9 if possible and not shell out the three hundred plus dollars for the tx66, especially if this happens again in only two years..and I would hate to have to start looking at other brands. my first Sony, the t70, also had similar problems and I willingly upgraded for the improvement in light sensitivity, but I really am ok with the tech in my tx9 otherwise ) .
There are MANY of us that have experienced the same issue. This is NOT simply damage to the screen due to misuse, it is a failure of the anti-reflective coating. We experienced this with a previous version of the Sony Cybershot and the store we purchased through advised us that the problem had been corrected on the new models. As we have all found out, the touch screen on the Sony cameras has a serious durability issue and Sony has washed their hands of the problem. We will not buy another sony camera again. It's too bad, because the camera is really nice as a pocket camera and performs well otherwise. Had we known that this was going to be an issue, we would have installed a protective film while it was new or simply chosen another camera. We liked the simplicity of the touch screen but the failure of the anti reflective coating makes the screen almost unusable in areas where there is a lot of light. The only solution that we have been able to find is to use a very fine polishing compound and remove the residual coating. It means that the screen will have reflections but it will at least be more usable. Toothpaste and a soft rag will remove the patchy areas of the coating that remains. A touch sensitive screen should be a lot more durable than the one that Sony has been shipping. Sony has really done a disservice to their customers that have spent good money for a product that has a known failure problem. What's worse is that they deny that there is an issue. We all know better.
-
Revision: 3216
Author: [email protected]
Date: 2008-09-15 18:13:11 -0700 (Mon, 15 Sep 2008)
Log Message:
Fix for MXMLG-228, a visibility problem with graphic elements. This is a quick fix that may force extra display objects when toggling visibility. We should investigate alternate solutions if performance is a problem.
Bugs: MXMLG-228
Reviewer: Deepa
QA: Please check for performance problems when toggling visibility of a large number of graphic elements.
Ticket Links:
http://bugs.adobe.com/jira/browse/MXMLG-228
http://bugs.adobe.com/jira/browse/MXMLG-228
Modified Paths:
flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/GraphicElement .asHello Antonio;
After many, many test I discovered that the problem, at least in my case it is caused by the new ACR 4.5. Please read the Thread that I post under Camera Raw. I include the link below.
I also open two Bug Reports about this, but as usual Adobe (and other Software Companies) will never take responsability for this, until one day they release a new version with "enhancements".
PSE6 Organizer Crash with ACR 4.5 (Vista Only?)
http://www.adobeforums.com/webx/.3bb6a869.59b60d3e -
Data visibility problem in PDF file generated from R/3 system
Hi all,
We are converting the output of a Smartform into a PDF format. From this smart from, we receive data in OTF format, after which the required data is converted from OTF format to PDF format. Then PDF data is sent through mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1 as an attachment.
For the above mentioned Smartform, we have defined Paragraph & Character font type as 'TIMES' in smart style. But when we receive the PDF file (through mail), some data of appears in other fonts:
1) When PDF file is generated from Development system, the different font types which are used by PDF are Arial and Times-Roman. In this case, we are able to see the PDF output and faced no major problems because both of these fonts are supported by PDF file format.
2) When PDF file is generated from Testing system, the font types which is used by PDF is Arial. In this case, we are able to see the PDF output because this font is supported by PDF file format.
3) When PDF file is generated from Production system, the different font types which are used by PDF are Arial, Times-Roman and PBRS. Here, we are able to see the data which is displayed in Arial font and Times-Roman font. But we are not able to see the data which is displayed in PBRS font because this type of font is not supported by PDF file format. If we copy the distorted text from PDF file and paste it in MS-Word then the required data is clearly visible and that is due to the reason that MS-Word supports PBRS font.
But as per smart style we have used only 'TIMES' font, then why different fonts are appearing in PDF file?
What settings are required to be done to make this data visible?
Any pointer to solve this issue will be really appreciable. Thanks in advance for your help.
Thanks and Regards,
Dheeraj TolaniHi,
check the following
http://help.sap.com/bp_biv235/BI_EN/html/bw.htm
business content
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/g-i/how%20to%20co-pa%20extraction%203.0x
https://websmp203.sap-ag.de/co
http://help.sap.com/saphelp_nw04/helpdata/en/37/5fb13cd0500255e10000000a114084/frameset.htm
(navigate with expand left nodes)
also co-pa
http://help.sap.com/saphelp_nw04/helpdata/en/53/c1143c26b8bc00e10000000a114084/frameset.htm
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/fb07ab90-0201-0010-c489-d527d39cc0c6
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1910ab90-0201-0010-eea3-c4ac84080806
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ff61152b-0301-0010-849f-839fec3771f3
FI-CO 'Data Extraction -Line Item Level-FI-CO'
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a7f2f294-0501-0010-11bb-80e0d67c3e4a
FI-GL
http://help.sap.com/saphelp_nw04/helpdata/en/c9/fe943b2bcbd11ee10000000a114084/frameset.htm
http://help.sap.com/saphelp_470/helpdata/en/e1/8e51341a06084de10000009b38f83b/frameset.htm
http://www.sapgenie.com/sapfunc/fi.htm
Please reward for the same. -
Jpopupmenu visibility problem with JWindows
Hello,
BACKGROUND:
I am attempting to implement a feature similar to one found in the netbeans IDE for a programming editor I am helping to write. The feature is an autocomplete/function suggestion based on the current word being typed, and an api popup for the selected function.
Currently a JPopupMenu is used to provide a list of suggested functions based on the current word being typed. EG, when a user types 'array_s' a JPopupMenu pops up with array_search, array_shift, array_slice, etc.
When the user selects one of these options (using the up/down arrow keys) a JWindow (with a jscrollpane embedded in it) is made visible which displays the api page for that particular function.
PROBLEM:
The problem is that when a user scrolls down the JWindow the JPopupmenu disappears so he user cannot select another function.
I have added a ComponentListener to the JPopupMenu so that when componentHidden is called I can do checks to see if it should be visible and make visible if necessary. However, componentHidden is never called.
I have added a focuslistener to the JPopupMenu so that when it loses focus I can do the same checks/make visible if necessary. This function is never called.
I have added a popupMenuListener but this tells me when it is going to make something invisible, not actually when it's done it, so I can't call popup.setVisible(true) from popupMenuWillBecomeInvisible because at that point the menu is still visible.
Does anyone have any suggestions about how I can scroll through a scrollpane in a JWindow whilst still keeping the focus on a separate JPopupMenu in a separate frame?
CheersThe usual way to do popup windows (such as autocomplete as you're doing) is not to create a JPopupMenu, but rather an undecorated (J)Window. Stick a JList in the popup window for the user to select their choice from. The problem with using a JPopupMenu is just what you're experiencing - they're designed to disappear when they lose focus. Using an undecorated JWindow, you can control when it appears/disappears.
See this thread for information on how to do this:
http://forum.java.sun.com/thread.jspa?threadID=5261850&messageID=10090206#10090206
It refers you to another thread describing how to create the "popup's" JWindow so that it doesn't steal input focus from the underlying text component. Then, further down, it describes how you can forward keyboard actions from the underlying text component to the JWindow's contents. This is needed, for example, so the user can keep typing when the autocomplete window is displayed, or press the up/down arrow keys to select different items in the autocomplete window.
It sounds complicated, but it really isn't. :) -
XDK 9.0.2.0.C XSQL parameter visibility problem
Dear Steven,
I consider this as a serious bug:
When one set XSQL page or XSQL session page parameter it
become visible in page/request/session or otherwise only after
the following round trip to the client.
In other words, it is not present in the incoming XML to xslt to
process.
Thank you,
DavidDavid,
I just re-tested with 9.0.2C and things are working as they
should. For example, the following XSQL page:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<page xmlns:xsql="urn:oracle-xsql" connection="demo">
<xsql:set-page-param name="page-param" value="1"/>
<xsql:set-session-param name="sess-param" value="2"/>
<xsql:set-stylesheet-param name="sheet-param" value="3"/>
<xsql:include-param name="page-param"/>
<xsql:include-param name="sess-param"/>
</page>referencing the following stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="sheet-param"/>
<xsl:template match="/">
<html><body>
<b><xsl:value-of select="$sheet-param"/></b>
<b><xsl:value-of select="/page/sess-param"/></b>
<b><xsl:value-of select="/page/page-param"/></b>
</body></html>
</xsl:template>
</xsl:stylesheet>shows an HTML page with the expected "321" the first request.
If you are talking about cookies, then you are correct that the
cookies you set this request are not visible until the next
request (which is the standard way cookies work), however, you
can use the new XSQL 9.0.2C feature to "see" the cookie value
immediately by adding the immediate="yes"] attribute to
your <xsql:set-cookie> action.
If I've misunderstood your problem, please post a testcase that
illustrates the issue. Thanks. -
ActionListener: Thread problem in JApplet with JButton?
Sorry for crossposting, this is my first question on this list, and I posted my question in the "Applet Development" section first. Then I discovered that there is a SWING category as well, which is closer to my problem. So please read about my problem behind this link:
http://forum.java.sun.com/thread.jspa?threadID=634757
Thank you very much
JanMarcin,
you pointed me in the right direction: I put the .java file in a fresh project and checked the bin folder: And there it was: The missing (second) file the VM was complaining about. I had just forgotten to put all the respective .class files in the webdirectory. Now it works (for a start) with these two files in the webdirectory. I will improve this by creating a jar and Manifest file soon.
Thanks again
Jan
PS: This was truly an (applet) newbie mistake, sorry :-( -
Developing new Swing Components - Visibility problems with UI classes
I was wondering if anyone out there had run into the following problems when developing new Swing components. If so it might be worth banding together and putting pressure on Sun to fix them. However, if no one else develops new Swing components then I guess I'm just a lone voice...
I have been writing a new dockable toolpanel Swing component and when it came to implementing the UI manager I was unable to access many of the standard features in basic and metal LAFs because they had been made package protected. This forced me to reimplement quite a bit of existing code which took time as well as being bad practice.
While in some cases I can understand this from a security POV I am pretty sure that in this case it is the result of lazy programming practice. Appart from basic architectural reasons for this I have noticed a trend where newer code seems to suffer from this more than the original code. The practice of using package protection reminds me of C++ style coding, or just that of an inexperienced developer who does not understand the need to code for extensibility.
An additional problem arises because the Security manager stops you cheating the system by putting new classes into the javax.swing.plaf... package structure. Thus the only way to solve this nicely is a proper fix.
This would entail going through all the UI PLAF classes and rationalizing the visibility to either public or protected as appropriate. Really there should be minimal use of package protection unless it is vital for security concerns.
Some Examples (there are many more):
javax.swing.plaf.basic.LazyActionMap
javax.swing.plaf.basic.BasicBorders.RolloverMarginBorder
javax.swing.plaf.basic.BasicBorders.SplitPaneDividerBorder (why are just these two classes package protected when all the others are public?)
javax.swing.plaf.metal.MetalUtils
javax.swing.plaf.metal.MetalBumps
Anyway, I am happy to give advice to other poor saps who wind up fighting the UI manager but it would be better if we could get Sun to sort out this mess (after all they created it).
Cheers, LewisIt may be more a case of creating new Swing components and trying to provide support for all the standard LnFs.
This is very awkward although you can sometimes achieve what you want by borrowing resources from UIManager (a border here, an icon there etc.).
Essentially the problem is that Swing is designed to have new components added to it but the standard LnFs aren't quite so accommodating! -
Photoshop CS4 Pen Tool Visibility Problem
I recently upgraded to CS4 and started using Photoshop to do some work. Working on some clipping path with the pen tool I've come to notice how incredibly light the pen tool outline is. I cant see where or what im tracing cause I can't tell where the line is unlike the other earlier creative suites where the line was visible.
Anyone have any ideas on making this outline more visible so I can actually see what I am doing. Input would be much appreciated.I am having the exact same problem with Photoshop CS 4 on my MacBook OSX 10.5.7 4 GB RAM Intel GMA X3100: graphics card
When I enable Open GL in PS CS4 preferences, the pen tool line is too light, too thin to use and the anchor points aren't accurate , I have to disable Open GL to get the normal pen function back. Adobe should get us a fix to make Open GL compatable with all graphics cards. All functions in Open GL work fine except the Pen Tool. -
Hello everyone. I am relatively new to swing, I've worked with it for less than a month. However, I am not new to Java.
I have an easy problem to resolve and I think I'm doing something basic wrong, so I thought I'd ask for help here.
Consider the following code (an abridged version of what I have):
public class Gui extends JFrame {
private JScrollPane p2;
public Gui() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
buildGUI();
private void buildGUI() {
//initialize p2, add components in it
//due to an event, the following method is invoked
private void somemethod() {
p2.setVisible(false);
//do whatever I need to do
p2.setVisible(true);
validate();
}The problem occurs in somemethod(). The component p2 disappears and doesn't reappear. I tried to use repaint() and validate() on the component and the frame, but it was in vain. I also tried running the instructions toward the swing component in the EDT, as suggested by a swing developer; no luck again.
What is it I am doing that's wrong here?
Message was edited by:
pvangarde
I've achieved the effect I desire. Only I have to remove the component from the ContentPane and add it, instead of doing the setVisible shebang. However, I don't like the solution for obvious reasons, and this also disrupts the size of the component.Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html
Here's a standard solution for a very common problem:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Gui extends JFrame {
private JScrollPane p2;
String text = "For anyone interested in reducing child poverty, there was"
+ " heartening bad news out of Britain last month. In 1999 the Blair"
+ " government introduced an initiative to end child poverty by 2020, with"
+ " an initial goal of cutting it by one-quarter by April of last year."
+ " Recently the government reported that it missed that target: The number"
+ " of children in poverty dropped by \"only\" about 17 percent -- some"
+ " 700,000 kids over the past five years.\n\nIf only we could have such"
+ " problems in this country.\n\nSince 2000 the number of American children"
+ " living in poverty has risen 12 percent -- to 13 million. The initial"
+ " growth was due to the economic downturn. But since then, despite the"
+ " ongoing expansion, the poverty rate for children on this side of the pond"
+ " keeps rising, largely because the benefits of the recovery have flowed"
+ " so disproportionately to families at the top of the income scale.\n\nBut"
+ " in the United Kingdom, the policy-driven focus on reducing child poverty"
+ " has helped to ensure that economic growth is reaching those at the bottom"
+ " of the income scale. Yes, they've missed an interim target, and some parts"
+ " of the plan need rethinking, but they're making progress while we're"
+ " backsliding.\n\nThis all started back in 1999, when Prime Minister Tony"
+ " Blair gave a speech in which he set the goal of eliminating child poverty"
+ " by 2020. As we learned on a recent trip there to see how things were"
+ " unfolding, the officials at the relevant agencies don't claim to know all"
+ " the answers. But with a directive to end poverty in 20 years, they rolled"
+ " up their sleeves and got to work.\n\nMembers of Parliament and the Blair"
+ " government built, and continue to build, a comprehensive system designed"
+ " to boost the incomes of working parents, mainly through subsidies to"
+ " low-wage earners. They raised the minimum wage and have continued to push"
+ " it up regularly.";
public Gui() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
buildGUI();
private void buildGUI() {
//initialize p2, add components in it
JPanel panel = new JPanel();
JButton button = new JButton("Do it");
panel.add(button);
JTextArea ta = new JTextArea(text);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
p2 = new JScrollPane(ta);
add(p2, BorderLayout.CENTER);
add(panel, BorderLayout.SOUTH);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
somemethod();
setSize(300, 300);
setVisible(true);
//due to an event, the following method is invoked
private void somemethod() {
Thread t = new Thread(){
public void run(){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
p2.setVisible(false);
//do whatever I need to do
try{
Thread.sleep(3000);
catch (InterruptedException ie){
ie.printStackTrace();
SwingUtilities.invokeLater(new Runnable(){
public void run(){
p2.setVisible(true);
t.start();
public static void main(String[] args){
new Gui();
} -
I'm currently using Director MX 2004, basically I'm wanting
the mouse pointer to click on an object, and when the object has
been clicked, for it to disappear. The problem comes when the
sprite doesnt return at the start of a new game. What code could I
use to make it re-appear at the start of a new game? I'm currently
using
on mouseUp
sprite(2).visible = FALSE
end
to get the objects to dissappear. Any help would be greatly
appreciated.When the new game starts, make it always set all of the
parts'
visibility back to true. If there are only a few things, then
it may be
easiest to put a script like this on the "reset button" (or
whatever is
used to start the game over)
sprite(2).visible=true
sprite(3).visible=true
..etc...
If there are a lot of them, then put a handler like this in
the script
for those objects
on resetVisibility me
sprite(me.spriteNum).visible=true
end
and on your rest button, put this command to do all of them
at once:
sendAllSprites(#resetVisibility) -
JFileChooser visibility problem
Hi,
I have a problem with JFileChooser-component. Every now and then the JFileChooser-component won't come visible and the application hangs.
For example:
import java.io.File;
import javax.swing.JFileChooser;
public class Main {
public static void main(String args[])
JFileChooser fcSaveAs = new JFileChooser();
fcSaveAs.setSelectedFile(new File(fcSaveAs.getCurrentDirectory() + File.separator + "test.pdf"));
int saveResp = fcSaveAs.showSaveDialog(null);
if(saveResp == JFileChooser.APPROVE_OPTION) {
System.out.println("true");
}So, I want to give the user a sample filename, which he/she can use to save a file.
But if I run that, every fifth or sixth time the dialog won't come visible and the application hangs. The user can't do anything but stop java.exe.
If i take that line 8 off, system works fine. But I want to give a sample filename to the user, which he/she can use to save the file.Hi,
Have you tried running on the Event Dispatch Thread (as you always should with Swing code)?
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
public class ChooserTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFileChooser fcSaveAs = new JFileChooser();
fcSaveAs.setSelectedFile(new File(fcSaveAs
.getCurrentDirectory()
+ File.separator + "test.pdf"));
int saveResp = fcSaveAs.showSaveDialog(null);
if (saveResp == JFileChooser.APPROVE_OPTION) {
System.out.println("true");
}Piet -
ActiveX container visibility problem
I am having problems with container visibility on a tab when the tab is made invisible. I have made a demo program to change tabs with and see how visibility behavior is affected based on which tab-page is visible at the time. I know there is a work around by programmatically changing to a different tab before setting visibility false.
Attachments:
ActiveX_Problem.vi 34 KBHi,
Actually, if you set the visibility of the ActiveX container to be the same as that of the Visibility boolean, the program seems to work correctly.
Go ahead and take a look at the modified example I've attached. Also, I slightly modified the way the stop button was being handled (I included it as a case in the event structure, which is generally the way NI recommends the use of the Stop button in event structures).
Hopefully this program will now work as expected. Thanks!
Kileen C.
Applications Engineer
National Instruments
NI Week 2004 is here!!
Attachments:
ActiveX_Problem.vi 48 KB -
Scrollbar visible / not visible problem
Hi everybody,
I am a newbie in java and i already stumbeled upon a problem. If anybody could give me some help it will be much appreciated. So... I have this schirpt on a website i am building:
<script language="JavaScript" type="text/javascript">
<!--
var zxcTO;
function Scroll(id,dis,pos){
var obj=document.getElementById(id)
obj.scrollTop=obj.scrollTop+dis;
if (pos){obj.scrollTop=pos; }
else {zxcTO=setTimeout( function(){ Scroll(id,dis); },10); }
//-->
</script>
Which it seems to create scrollbars on a div i have attached this code:
<div class="divElement3" style="display:inline;clear:left;float:left" >
<img style="display:inline" align="right" onMouseOver="Scroll('Tst1',-1);" onmouseout="clearTimeout(zxcTO);" src="<cms:link>../resources/upArrow.gif</cms:link>" border="0" />
<img style="display:inline" align="right" onMouseOver="Scroll('Tst1',1);" onmouseout="clearTimeout(zxcTO);" src="<cms:link>../resources/downArrow.gif</cms:link>" border="0"/>
</div>
Thing is i don't want the scrollbar to be seen but still to act like a scrollbar as i have 2 little arrows acting like a scrollbar up and down.
Hope is clear enough :)JavaScript != Java
They are two seperate languages. Find a JavaScript forum to answer your question.
Maybe you are looking for
-
HT3819 How do you transfer purchased music from one apple id to another?
I have a different Apple ID on my ipad than my macbook and macbook pro, I have most music on the macbooks but some on ipad how do I combine? This happend because when I was at the apple store buying my ipad I could not remember my other ID, so we mad
-
Can`t see the words on the browser neither connect...
sometimes it use to connect to the wifi but usually it dosent but when it use to connect to the internet either by sim card or wifi i cant see the words on the browser serious problem please helpppppppp
-
I can hear my ipad turns on and off but it shows a black screen?
-
Hello Illustrators. lately sometimes while im working in illustrator cs6,once i move some objects around im receiving the following error messages. i have more than enough memory on my machine.its the 1st time im coming across this message:
-
Flash builder Event metadata not recognized
Hello, Can someone explain me why my event isn't recognized in the code below (it is not proposed as a property for my TestButton and if I try to force it I get an error) Test application : <?xml version="1.0" encoding="utf-8"?><s:Application xmlns: