您可以使用LoadAdapter進行標準的POST請求。請看下面的示例代碼:
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.events.FinishLoadingEvent;
import com.teamdev.jxbrowser.chromium.events.FrameLoadEvent;
import com.teamdev.jxbrowser.chromium.events.LoadAdapter;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
public class LoadListenerSample {
public static void main(String[] args) {
final Browser browser = new Browser();
BrowserView view = new BrowserView(browser);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
browser.addLoadListener(new LoadAdapter() {
@Override
public void onFinishLoadingFrame(FinishLoadingEvent event) {
System.out.println("LoadListenerSample.onFinishLoadingFrame");
}
@Override
public void onDocumentLoadedInFrame(FrameLoadEvent event) {
System.out.println("LoadListenerSample.onDocumentLoadedInFrame");
}
});
browser.loadURL("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit");
}
}