Windows 10 JFileChooser - runtime-error

I recently got windows 10 and I'm having problems using the JFileChooser. Whenever the line with it runs it gives me this error "Qt: Untested Windows version 6.3 detected!" I'm not sure if anyone asked this but I tried looking and found nothing. The error doesn't tell me where it occurs. I feel this may be because of windows 10.
public class Load {
public static JFrame f = new JFrame();
/**
* #wbp.parser.entryPoint
*/
public void frame(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Load Game");
fileChooser.setAcceptAllFileFilterUsed(false);
fileChooser.setApproveButtonText("Load");
fileChooser.setForeground(new Color(255, 255, 255));
fileChooser.setFont(new Font("Trebuchet MS", Font.PLAIN, 12));
f.getContentPane().add(fileChooser, BorderLayout.CENTER);}}

Possible reasons:
you are not using properly JFileChooser component. Try:
if( filechooser.showOpenDialog( frame ) == JFileChooser.APPROVE_OPTION ) {
...
}
A fresh Windows 10 does not have the proper UI params for JFileChooser class. Therefore try one (or both) of the following things:
a. download and install KBxxxx updates the windows 10
b. stop using UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
in case you are using it and switch to default Look&Feel.

Related

JavaFX format Math during input

Is there a way that a mathematical expression can be formatted in JavaFX during input? Something like a TextArea that behaves exactly as the mathquill editor, which is for web applications?
If not, would it be possible to create a custom TextField / TextArea to provide such functionality? I have not yet looked into this so any guidance or suggestions are welcome :)
The only workaround I came up with is to input the expression as a String and convert it to an image using jLaTeXmath, which is not preferred as the end result should be an editable equation.
Short example on embedding jLaTeXmath:
This is done by converting a TeX expression to a BufferedImage that can be placed on a Pane. See below the code for the conversion:
/**
* Converts LaTeX code to a BufferedImage
* #param latex
*/
public static BufferedImage latexToImage(String latex){
String start ="\\begin{array}{l}";
start += latex;
start += "\\end{array}";
TeXFormula formula = new TeXFormula(start);
// Note: Old interface for creating icons:
//TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
// Note: New interface using builder pattern (inner class):
TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY).setSize(65f).build();
icon.setInsets(new Insets(1, 1, 1, 1));
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
g2.setComposite(AlphaComposite.Clear);
// g2.setColor(Color.WHITE);
g2.fillRect(0,0,icon.getIconWidth(),icon.getIconHeight());
JLabel jl = new JLabel();
jl.setForeground(new Color(0, 0, 0));
g2.setComposite(AlphaComposite.Src);
icon.paintIcon(null, g2, 0, 0);
/*
File file = new File("Example2.png");
try {
ImageIO.write(image, "png", file.getAbsoluteFile());
} catch (IOException ex) {}
*/
return image;
}
The image can then be converted and set in a ImageView in JavaFX as folllows:
BufferedImage bimage = latexToImage("a = 2 \cdot x");
Image image = SwingFXUtils.toFXImage(bimage , null);
// have an ImageView in your scene and set the image
imgView.setImage(image );
The next coming versions of JavaFX support MathML by using a HTMLEditor Control :
JavaFX 8 Update 192 included in Java 8 Update 192
JavaFX 11.
Follow this link Java Early Access Download to reach the early access to these versions.
I'm afraid that what you are looking for doesn't exist yet.
There is a project in the JavaFX GitHub Reprository, but it's long term project.
About MathQuill, it seems that it is a JavaScript code. Or HTMLEditor uses an implementation of WebKit and can execute JavaScript code. It could be a short term solution.

JavaFX (OpenJFX) not letting me print

My JavaFX program prepares and prints out a set of VBoxes.
This is ModPrintCycle. It is the Window that gives the options to print
public PrintCycle data;
//PrintCycle is a HashMap of VBoxes containing all the details
PrinterJob pj;
ChoiceBox<String> cbxPrinters = new ChoiceBox<String>();
ArrayList<Printer> arrPrinters = new ArrayList<Printer>();
//util.say just pops out a messagebox attached to ModPrintCycle.
public void printAll(ArrayList<String> pageList){
if(cbxPrinters.getSelectionModel().getSelectedIndex() >=0){
if (data.tables.size() > 0){
Printer curP = Printer.getDefaultPrinter();
if(arrPrinters.size() > 0 ){
curP = arrPrinters.get(cbxPrinters.getSelectionModel().getSelectedIndex());
}
try{
pj = PrinterJob.createPrinterJob(curP);
PageLayout pp = curP.createPageLayout(Paper.LEGAL, PageOrientation.PORTRAIT, MarginType.DEFAULT);
PageLayout pl = curP.createPageLayout(Paper.LEGAL, PageOrientation.LANDSCAPE, MarginType.DEFAULT);
for(String p : pageList){
Printable pt = data.tables.get(p);
pt.scaleToFit();
if(pt.isLandscape()){
pj.printPage(pl,pt);
}
else{
pj.printPage(pp,pt);
}
}
pj.endJob();
}catch(Exception e){
util.say(ModPrintCycle.this, "Error on Print");
}
}else{
util.say(ModPrintCycle.this, "Nothing to print");
}
}
else{
util.say(ModPrintCycle.this, "No Printer Selected");
}
}
Printer is installed and set as default, and my program detects it. But when I print, no errors pop out, and the printer receives no jobs.
I'm sure my program worked before (A Lubuntu 15.10, 32-bit.). But now, I transfered it to a different computer. A Lubuntu 15.10, 64-bit. I have openjfx and openjdk version "1.8.0_66-internal" installed.
What can I do to find out why it's not printing?
Tried to make a smaller print job, but to the same effect.
Button testPrint = new Button("Test Print");
testPrint.setOnAction(new EventHandler<ActionEvent>(){
#Override
public void handle(ActionEvent arg0) {
try{
Printer p = Printer.getDefaultPrinter();
PrinterJob pj = PrinterJob.createPrinterJob(p);
//util.say(ModShortcuts.this, "Print: " + pj.getJobStatus());
Boolean k = pj.printPage(p.createPageLayout(Paper.LEGAL,PageOrientation.PORTRAIT,MarginType.DEFAULT), new Text("Hey"));
//util.password(); //reused for a showAndWait() dialog
//util.say(ModShortcuts.this, "Print: " + pj.getJobStatus());
//util.say(ModShortcuts.this, "attempted Print using: " + pj.getPrinter().getName());
if(k){
//util.say(ModShortcuts.this, "Print: " + pj.getJobStatus());
pj.endJob();
//util.say(ModShortcuts.this, "Print: " + pj.getJobStatus());
}
}catch(Exception e){
e.printStackTrace();
}
}
});
vbox.getChildren().add(testPrint);
Uncommented, the output is
Print: Not Printing
Print: Printing
attempted Print using: AstinePrinter
Print: Printing
Print: Done
AstinePrinter is the name of my printer.
Edit: Using
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
I installed Oracle Java 8, and still the same problem.
Edit: Also Oracle Java 7.
Edit:
Tried disabling the firewall, in case it was a port problem
sudo ufw disable
Still nothing.
I've found something called CUPS4J, and it allows me to bypass the problem it had concerning Java trying to access CUPS in a 64 bit Ubuntu. It prints out using Byte arrays, and luckily, JavaFX has a way to snapshot the chosen node.
It's a little blurry, but it's good enough. NOTE: I am no expert, and I don't know why this is needed. But doing this allowed me to use CUPS4J with no errors, so it must have been correct.
So, first of all, download the [ECLIPSE PROJECT] for cups4j,
because there are dependencies that have to be fixed. Import it into your project.
EDIT: The reason why the following is needed is that somehow, my package doesn't come with org.slf4j. If your class path says you have it, skip these steps.
Next, for each class there, all instances of Logger (cAsE
sEnSiTiVe) should be replaced with Log, and fix your imports (Ctrl+Shift+O). This will suggest a version of the Log, and LogFactory will be automatically detected. My import path says org.apache.commons.logging.*
Finally, remove the library dependency for org.slf4j in your build path under Libraries.
(I'm sure using the Runnable Jar is fine, but this is what I did because using the Runnable Jar gave me errors)
This is a simplification of what I did for my print function.
private void print(Region node){
//Make the image with the proper sizes
WritableImage wi = new WritableImage(
(int) Math.round(Math.ceil(node.getWidth())),
(int) Math.round(Math.ceil(node.getHeight())));
//shoot the image
wi = node.snapshot(new SnapshotParameters(), wi);
//write the image into a readable context
ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
ImageIO.write(SwingFXUtils.fromFXImage(wi, null), "png", out);
}catch(Exception e){
System.out.println("Error with SnapShot function");
}
//Get your printer
CupsClient cc = new CupsClient();
CupsPrinter cp = cc.getDefaultPrinter();
//print the readable context
cp.print(new PrintJob.Builder(out.toByteArray()).build());
//unlike PrinterJob, you do not need to end it.
}
I'm not sure, but I've seen bug reports in the CUPS4J forum saying there's a problem with multiple pages, but I have yet to encounter that.
If someone has a better answer, feel free to add. But so far, this worked for me.

URl not passing while running IE with web driver

I am trying to run my scrip using web driver in IE. It is bringing up the browser but not passing the URL. While opening the browser it giving one message " This is the initial start page for the WebDriver server". I am using IE 9. Anybody has any idea what is happening here?
driver = new driver InternetExplorerDriver();
driver.manage().window().implicitlyWait(30, TimeUnit, SECONDS);
driver.navigate().to("URL")
Here is how I do it but I dont use Selenium RC... instead I use "pure" webdriver without the Selenium server:
public static void initializeBrowser( String type ) {
if ( type.equalsIgnoreCase( "firefox" ) ) {
driver = new FirefoxDriver();
} else if ( type.equalsIgnoreCase( "ie" ) ) {
driver = new InternetExplorerDriver();
}
driver.manage().timeouts().implicitlyWait( 10000, TimeUnit.MILLISECONDS );
driver.manage().window().setPosition(new Point(200, 10));
driver.manage().window().setSize(new Dimension(1200, 800));
}
And I call it like this:
#Test
public void testWithPageObject() {
driver.get("http://www.google.com");
GoogleSearchPage gs = new GoogleSearchPage();
gs.setSearchString( searchString );
selectInGoogleDropdown( ddMatch );
gs.clickSearchButton();
waitTimer(3, 1000);
clickElementWithJSE( "gbqlt" ); //click Google logo
System.out.println("Done with test.");
}
One thing you will notice about this method is that the method that you call to goto the URL is different than when using the Selenium RC server. See the link (above) to see my whole source code.

Visual Studio Express 2010 References Issue

I accidentally removed the references from one of my projects and then carefully put them back in. However now I am throwing errors in code the was functioning perfectly so I think I must still be missing a reference unless something else was broken in the process. Here is the current error:
The variable 'button1' is either undeclared or was never assigned.
But here is the code in Form1.Designer.cs:
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
...
//
// button1
//
this.button1.Location = new System.Drawing.Point(235, 382);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(125, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Generate Report";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
...
this.Controls.Add(this.button1);
...
private System.Windows.Forms.Button button1;
The last seven lines are all throwing this error. Any advice is appreciated.
Regards.
EDIT: Here is code relevant to the comments:
public partial class Severity3RetailNetworkTrackingLog : Form
{
public Severity3RetailNetworkTrackingLog()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
Where Form1 has been changed to Severity3RetailNetworkTrackingLog.
I suspect you are missing the member variable definition
class Form1 {
/* lots of windows form designer code */
/* some other member variables */
System.Windows.Forms.Button button1;
}
Within your class definition.
Turns out that VS Express 2010 was just misbehaving. I commented out all of the offending code and still got the same errors with the same line numbers. So I closed and opened VS and everything is back to normal.

Javascript permission denied error when using Atalasoft DotImage

Have a real puzzler here. I'm using Atalasoft DotImage to allow the user to add some annotations to an image. When I add two annotations of the same type that contain text that have the same name, I get a javascript permission denied error in the Atalasoft's compressed js. The error is accessing the style member of a rule:
In the debugger (Visual Studio 2010 .Net 4.0) I can access
h._rule
but not
h._rule.style
What in javascript would cause permission denied when accessing a membere of an object?
Just wondering if anyone else has encountered this. I see several people using Atalasoft on SO and I even saw a response from someone with Atalasoft. And yes, I'm talking to them, but it never hurts to throw it out to the crowd. This only happens in IE8, not FireFox.
Thanks, Brian
Updates: Yes, using latest version: 9.0.2.43666
By same name (see comment below) I mean, I created default annotations and they are named so they can be added with javascript later.
// create a default annotation
TextData text = new TextData();
text.Name = "DefaultTextAnnotation";
text.Text = "Default Text Annotation:\n double-click to edit";
//text.Font = new AnnotationFont("Arial", 12f);
text.Font = new AnnotationFont(_strAnnotationFontName, _fltAnnotationFontSize);
text.Font.Bold = true;
text.FontBrush = new AnnotationBrush(Color.Black);
text.Fill = new AnnotationBrush(Color.Ivory);
text.Outline = new AnnotationPen(new AnnotationBrush(Color.White), 2);
WebAnnotationViewer1.Annotations.DefaultAnnotations.Add(text);
In javascript:
CreateAnnotation('TextData', 'DefaultTextAnnotation');
function CreateAnnotation(type, name) {
SetAnnotationModified(true);
WebAnnotationViewer1.DeselectAll();
var ann = WebAnnotationViewer1.CreateAnnotation(type, name);
WebThumbnailViewer1.Update();
}
There was a bug in an earlier version that allowed annotations to be saved with the same unique id's. This generally doesn't cause problems for any annotations except for TextAnnotations, since they use the unique id to create a CSS class for the text editor. CSS doesn't like having two or more classes defined by the same name, this is what causes the "Permission denied" error.
You can remove the unique id's from the annotations without it causing problems. I have provided a few code snippets below that demonstrate how this can be done. Calling ResetUniques() after you load the annotation data (on the server side) should make everything run smoothly.
-Dave C. from Atalasoft
protected void ResetUniques()
{
foreach (LayerAnnotation layerAnn in WebAnnotationViewer1.Annotations.Layers)
{
ResetLayer(layerAnn.Data as LayerData);
}
}
protected void ResetLayer(LayerData layer)
{
ResetUniqueID(layer);
foreach (AnnotationData data in layer.Items)
{
LayerData group = data as LayerData;
if (group != null)
{
ResetLayer(data as LayerData);
}
else
{
ResetUniqueID(data);
}
}
}
protected void ResetUniqueID(AnnotationData data)
{
data.SetExtraProperty("_atalaUniqueIndex", null);
}

Resources