I keep getting this error:
Illegal modifier for the local class myWebClient; only abstract or final is permitted.
and this error:
void is an invalid type for the variable backButtonClicked
Heres the code where the error occurs.
public class myWebClient extends WebViewClient
{
}
public void backButtonClicked(View view)
{
if (ourBrow.canGoBack())
ourBrow.goBack();
}
public void forwardButtonClicked(View view)
{
if (ourBrow.canGoForward())
ourBrow.goForward();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
Remove the public modifier of the class and put all methods inside the body of the class:
class myWebClient extends WebViewClient
{
public void backButtonClicked(View view)
{
if (ourBrow.canGoBack())
ourBrow.goBack();
}
public void forwardButtonClicked(View view)
{
if (ourBrow.canGoForward())
ourBrow.goForward();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
}
Related
I tried to write a udf function to calculate my data. In the trino's docs, I knew I should to write a function plugin and I succeed to execute my udf aggregate function sql.
But when I write sql with aggregate function and window function, the sql executed failed.
The error log is com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/example/ListState.
I think I may implement the interface about the window function.
The ListState.java file code
#AccumulatorStateMetadata(stateSerializerClass = ListStateSerializer.class, stateFactoryClass = ListStateFactory.class)
public interface ListState extends AccumulatorState {
List<String> getList();
void setList(List<String> value);
}
The ListStateSerializer file code
public class ListStateSerializer implements AccumulatorStateSerializer<ListState>
{
#Override
public Type getSerializedType() {
return VARCHAR;
}
#Override
public void serialize(ListState state, BlockBuilder out) {
if (state.getList() == null) {
out.appendNull();
return;
}
String value = String.join(",", state.getList());
VARCHAR.writeSlice(out, Slices.utf8Slice(value));
}
#Override
public void deserialize(Block block, int index, ListState state) {
String value = VARCHAR.getSlice(block, index).toStringUtf8();
List<String> list = Arrays.asList(value.split(","));
state.setList(list);
}
}
The ListStateFactory file code
public class ListStateFactory implements AccumulatorStateFactory<ListState> {
public static final class SingleListState implements ListState {
private List<String> list = new ArrayList<>();
#Override
public List<String> getList() {
return list;
}
#Override
public void setList(List<String> value) {
list = value;
}
#Override
public long getEstimatedSize() {
if (list == null) {
return 0;
}
return list.size();
}
}
public static class GroupedListState implements GroupedAccumulatorState, ListState {
private final ObjectBigArray<List<String>> container = new ObjectBigArray<>();
private long groupId;
#Override
public List<String> getList() {
return container.get(groupId);
}
#Override
public void setList(List<String> value) {
container.set(groupId, value);
}
#Override
public void setGroupId(long groupId) {
this.groupId = groupId;
if (this.getList() == null) {
this.setList(new ArrayList<String>());
}
}
#Override
public void ensureCapacity(long size) {
container.ensureCapacity(size);
}
#Override
public long getEstimatedSize() {
return container.sizeOf();
}
}
#Override
public ListState createSingleState() {
return new SingleListState();
}
#Override
public ListState createGroupedState() {
return new GroupedListState();
}
}
Thanks for help!!!!
And I found the WindowAccumulator class in the trino source code. But I don't know how to use it.
How to create a aggregate function for window function?
public class i_dont_even1 : MonoBehaviour
{
public Rigidbody2D rb2D;
public bool bananawel;
void Update()
{
void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("work");
}
I tried everything pls help
my viewpager is different (with multy xml and java file.means page1 java and xml file,page2 java and xml file,page3 java and xml files are seprate).
and want to sate cubeout effect in my viewpager.
**this is my coad **
public class MercuryActivity extends FragmentActivity implements OnPageListener {
List fragments = new Vector();
private ViewPager mPager;
private PagerAdapter mPagerAdapter;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.fragments.add(Fragment.instantiate(this, Page1Fragment.class.getName()));
this.fragments.add(Fragment.instantiate(this, Page2Fragment.class.getName()));
this.fragments.add(Fragment.instantiate(this, Page3Fragment.class.getName()));
this.fragments.add(Fragment.instantiate(this, Page4Fragment.class.getName()));
this.mPagerAdapter = new PagerAdapter(super.getSupportFragmentManager(), this.fragments);
this.mPager = (ViewPager) super.findViewById(R.id.pager);
this.mPager.setAdapter(this.mPagerAdapter);
}
public void onPage1(String s) {
((Page2Fragment) this.fragments.get(1)).getView();
((Page3Fragment) this.fragments.get(2)).getView();
((Page4Fragment) this.fragments.get(3)).getView();
}
public void onBackPressed() {
new Builder(this).setIcon(17301543).setTitle("Exit").setMessage("Are you sure you want to exit?").setPositiveButton("Yes", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MercuryActivity.this.moveTaskToBack(true);
MercuryActivity.this.finish();
}
}).setNegativeButton("No", null).show();
}
}
and this is my page adapter
public class PagerAdapter extends FragmentPagerAdapter {
private List fragments;
public PagerAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
}
public Fragment getItem(int position) {
return (Fragment) this.fragments.get(position);
}
public int getCount() {
return this.fragments.size();
}
}
for the life of me I can't figure out what is wrong with this code, please help. I have three classes, GeometricObject, Octagon which extends GeometricObject and TestOctagon which is being used to test the Octagon class. When I run the TestOctagon class I get this error:
The method clone() from the type Object is not visible
Here is my code:
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
protected GeometricObject() {
}
protected GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public abstract double getArea();
public abstract double getPerimeter();
}
import java.lang.Comparable;
import java.lang.Cloneable;
public class Octagon extends GeometricObject implements Comparable<Octagon>, Cloneable{
double side;
public Octagon() {
}
public Octagon(double side) {
this.side = side;
}
public Octagon(double side, String color, boolean filled) {
this.side = side;
setColor(color);
setFilled(filled);
}
public double getSide() {
return side;
}
public void setSide(double side) {
this.side = side;
}
public double getArea() {
return (2+4/Math.sqrt(2))*side*side;
}
public double getPerimeter() {
return 8*side;
}
#Override
public int compareTo(Octagon o) {
if (getArea() > o.getArea())
return 1;
else if (getArea() < o.getArea())
return -1;
else
return 0;
}
#Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
public class TestOctagon {
public static void main(String[] args) {
// TODO Auto-generated method stub
GeometricObject oc1 = new Octagon(5);
System.out.println(oc1.getArea());
System.out.println(oc1.getPerimeter());
GeometricObject oc2 = (GeometricObject)oc1.clone();
}
}
Don,
Please note that the access specifier for method Object::clone() is protected. It is not accessible from your TestOctagon class as you are invoking this method on object of type GeometriObject (oc1) where the clone method is still protected as neither it or its super classes have overridden it. Try moving the clone method from Octagon class to GeometriObject class. Please retain the public access specifier. Refer this sample on how to do it http://www.javatpoint.com/object-cloning
I want to add a custom action in my new component.
How to do this?
Example code:
Component
public class MyCustomComponent extends Region {
public MyCustomComponent(){
super();
this.setOnMouseClicked(new EventHandler<MouseEvent>(){
#Override
public void handle(MouseEvent event) {
/* throw my custom event here and handle it in my FXML controller - but how? :-( */
}
});
}
}
Controller
public class MyController {
#FXML protected void myCustomAction(ActionEvent event) {
// do something
}
}
FXML:
<BorderPane fx:controller="fxmlexample.MyController"
xmlns:fx="http://javafx.com/fxml">
<top>
<MyCustomComponent onAction="#myCustomAction">
</MyCustomComponent>
</top>
</BorderPane>
Thx for help
You need to implement property in your custom component, which will store your action.
public class MyCustomComponent extends Region {
public MyCustomComponent(){
super();
// just to find out where to click
setStyle("-fx-border-color:red;");
setPrefSize(100, 100);
this.setOnMouseClicked(new EventHandler<MouseEvent>(){
#Override
public void handle(MouseEvent event) {
onActionProperty().get().handle(event);
}
});
}
// notice we use MouseEvent here only because you call from onMouseEvent, you can substitute any type you need
private ObjectProperty<EventHandler<MouseEvent>> propertyOnAction = new SimpleObjectProperty<EventHandler<MouseEvent>>();
public final ObjectProperty<EventHandler<MouseEvent>> onActionProperty() {
return propertyOnAction;
}
public final void setOnAction(EventHandler<MouseEvent> handler) {
propertyOnAction.set(handler);
}
public final EventHandler<MouseEvent> getOnAction() {
return propertyOnAction.get();
}
}
and don't forget to add import in your fxml file:
<?import my.package.MyCustomComponent?>