I would like to capture a screenshot of a website including content that you can only see if you scrolled down.
Is that possible?
EDIT:
I already tried https://github.com/ui4j/ui4j/blob/master/ui4j-sample/src/main/java/com/ui4j/sample/ScreenCapture.java, but it did not capture the whole page, just the visible portion(inside my monitor's viewport).
page.show(true);
page.captureScreen(new FileOutputStream(file));
Yes, you could capture screenshot of the whole page with ui4j. Sample code:
package com.ui4j.sample;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.ui4j.api.browser.BrowserFactory;
import com.ui4j.api.browser.Page;
public class ScreenCapture {
public static void main(String[] args) throws FileNotFoundException {
Page page = BrowserFactory.getWebKit().navigate("https://www.google.com");
page.show(true);
page.captureScreen(new FileOutputStream(new File("google.png")));
}
}
Alternative solution:
I highly recommend to use cdp4j library for full page screen capture. Its a Java library which help to automate Chrome/Chromium based browser. Here is the sample code.
Related
How to disable screenshot in flutter? I have Kotlin file instead of MainActivity.java file. Please suggest full code with path where I need to change for disable screenshot in my app.
package com.quotster.untitled
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
If you want to do that in Android only you can use flutter_windowmanager and add FLAG_SECURE.
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
I am using Firebase Cloud Messaging for getting notifications. I was getting proper notifications when my app was running but when my app was in background, I used to get this exception on arrival of the notification :
After some digging I got a solution for this where they performed the following changes :
My MyActivity.java :
package ......; /* Package Name*/
import android.os.Bundle;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
Application.java :
GeneratedPluginRegistrant.java
And I changed the 'android:name' of tag form "io.flutter.app.FlutterApplication" to ".Application" accordingly :
Now as you can see in the screenshots provided above ..... I am getting errors saying cannot revolves symbol 'Firebasemesseging' etc. (Same 'Cannot resolve' everywhere). Can anyone please help me to fix this error. I am a bit new to Flutter hence I am not sure how to solve this.
Thanks a lot in advance for the help.
We are using file upload from the gwt but i want to upload the file by drag and drop in the browser. It is working fine with chrome browser but not working with Firefox because in Chrome it is showing choose File and Firefox it is showing Browse option. How can i upload the file in the Firefox browser by Drag and drop?
We are using GWT 2.5.1 and Smart Gwt 4.1.
We could do the drag and drop in any version of chrome but not in any version of firefox browser.
Code Snippet:
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FileItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestApp implements EntryPoint {
#Override
public void onModuleLoad() {
VLayout vTest=new VLayout();
vTest.setBackgroundColor("#D3D3D3");
VLayout fileVLayout = new VLayout(10);
fileVLayout.setAutoWidth();
fileVLayout.setAutoHeight();
fileVLayout.setPadding(10);
final DynamicForm form = new DynamicForm();
TextItem filename = new TextItem();
filename.setTitle("File Name");
TextItem uploader = new TextItem();
uploader.setTitle("uploader name");
uploader.setWrapTitle(false);
**// Smart GWT**
final FileItem uploadfile = new FileItem();
uploadfile.setTitle("File Item");
uploadfile.setAlign(Alignment.CENTER);
**// GWT**
final FileUpload fileTest = new FileUpload();
fileTest.setTitle("File Upload");
form.setItems(filename, uploader, uploadfile);
form.draw();
HLayout fileHLayout = new HLayout(10);
fileHLayout.setHeight(10);
Label fileNameStaticLabel = new Label();
fileNameStaticLabel.setContents("File Upload");
fileNameStaticLabel.setWrap(false);
fileNameStaticLabel.setHeight("25px");
fileNameStaticLabel.setAlign(Alignment.RIGHT);
fileVLayout.addMember(form);
fileHLayout.addMember(fileNameStaticLabel);
fileHLayout.addMember(fileTest);
vTest.addMember(fileVLayout);
vTest.addMember(fileHLayout);
RootPanel.get().add(vTest);
}
}
Thanks in advance.
You're on the right track, just replace the native GWT code with Smart GWT code.
You are mixing GWT with Smart GWT components. You should not do that, per http://forums.smartclient.com/showthread.php?t=8159#aMix. "The reason for this is that there are limits to the maximum degree that two Ajax widget kits
(including GWT) can interoperate..."
Smart GWT has its own file picker, see http://www.smartclient.com/smartgwtee/javadoc/index.html?overview-summary.html (FileItem). And also it's own Canvas system: Don't use GWT RootPanel, use Smart GWT Canvas or VLayout, etc.
Though Smart GWT has "GWT" in the name, and though it uses substantial portions of GWT (GWT Compiler, etc), Smart GWT really is a framework unto itself. Aside from rare cases (e.g., login page), it's not advisable to mix Smart GWT with native GWT.
I am trying to port my javafx2 application over to javafx8 but have noticed some issues on Linux with popup controls.
The screenshot shows how the popup have a white box around it, which normally should be transparent and drop shadow effect.
This only happens on my Slackware14 Linux, I have test on the Windows VM that runs on the same machine and it renders fine.
I think the issue is related to these issues
https://javafx-jira.kenai.com/browse/RT-33709
https://javafx-jira.kenai.com/browse/RT-33750
My question is are there any workaround until it will be fixed ?
What the Problem Is
The default JavaFX 8 (modena.css) does not take into account that the transparent window feature is optional on some platforms (specifically some Linux platforms).
It is unlikely that the default css will be changed until Java 9 comes out.
How to Fix It
This is a solution for Java 8+ only.
Supply your own css to override the default css so that you can support those platforms without displaying an ugly white border areas around some of your controls. The css you provide can assume that transparent windows are not a feature of the underlying platform and style the UI so that it still looks good on such platforms. As the transparent window feature is a ConditionalFeature, on application startup, check to see if the conditional feature is supported, and if it is not, apply your custom stylesheet via Application.setUserAgentStyleSheet().
Sample Application
I have only tested this on a Mac (which supports the transparent window feature), so I can't really verify it will work as expected on Linux, but I hope it will work fine :-)
import javafx.application.Application;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class SolidPick extends Application {
public static void main(String[] args) { launch(args); }
#Override public void start(Stage stage) throws Exception {
ColorPicker picker = new ColorPicker();
if (Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)) {
Application.setUserAgentStylesheet(
this.getClass().getResource(
"solid-pick.css"
).toExternalForm()
);
}
StackPane layout = new StackPane(picker);
layout.setPadding(new Insets(10));
stage.setScene(new Scene(layout));
stage.show();
}
}
Then the file solid-pick.css an exact copy of the entire modena.css with the following additional lines appended to the end:
.color-palette {
-fx-background-radius: 0, 0;
-fx-effect: null;
}
These lines:
Give the color picker popup a square background rather than a rounded one.
Remove the translucent drop shadow effect which normally surrounds the popup.
The combination of these things provide the popup with a shape and border which looks much better in an environment which does not provide transparent windows.
The solid-pick.css file should be placed in the same directory as the SolidPick application, so that it gets bundled into the application jar and will be available to the application classloader.
Sample Output
Here is some sample output of rendering on my Mac with and without the dropshadow border on the popup.
Standard rendering =>
Modified rendering, with square borders and no shadow =>
Suggested Approach
Go through your entire application (and possibly the entire modena.css stylesheet) and, using a similar approach to that done above for the color picker, fix up any rendering issues that arise in a transparent window incapable environment. Then use the resultant stylesheet in your application and (if licensing permits), contribute your custom stylesheet to the community by submitting it to a 3rd party project such as ControlsFX.
Hello i've just started today, so i am very new at this.
I'm following this toturial and i ran into a trouble when i was asked to import a picture as the background for this "game".
i've created a new source folder and placed the picture there
package com.scrollshooter.www;
public class Board {
Pig p;
Image img;
public board(){
}
}
Looks like this at the moment, and the person who created this toturial says that i have to import the picture and afterwards he hover the "image" and there he has the picture. i have no idea how to import the picture into the file
Please help!
make a new folder into your project name it "img", put the image in the folder .
import image using the path like : img/test.png