I have created a new DesktopApplication in Netbeans. When I start it, it shows the gui directly on the screen. How to hide it after startup?
Something like this:
DesktopApplication1.getApplication().getMainFrame().setVisible(false);
after the initComponents(); method doesn't work.
Is there a way to hide this window after starting up? (I only want to show it after clicking the tray-Icon of this application. Not after startup.)
Thanks.
This problem is reproduceable when you create a new DesktopApplication in Netbeans. I haven't changed the code (only added the line mentioned above.)
If you look at the source code for DesktopApplication1App, it says something like
//DesktopApplication1App.java
#Action public void startup(){
show(new DesktopApplication1View(this));
}
To fix this, just comment out the show() call, and replacing it with a dummy. For example:
//DesktopApplication1App.java
#Action public void startup(){
Object o = new DesktopApplication1View(this);
}
Later, if you want to set it to be visible, you can call this:
//DesktopApplication1View.java
DesktopApplication1App.getApplication().show(this);
// ----- OR -----
this.getFrame().setVisible(true);
whichever works for you.
Related
I'm using sliding panels with my android app, but i need to get an event when the panel is up, is there a way listen to when it happens?
im using a sothree Sliding panel library
Looks like you are talking about umano/AndroidSlidingUpPanel. After briefly looking at the documentation/code you should be able to set a PanelSlideListener to your SlidingUpPanelLayout. They also provide a SimplePanelSlideListener which inserts no-ops for any functions you choose not to implement, which is probably what you will want to use.
For example inside of your Activity's onCreate you could do something like:
SlidingUpPanelLayout slidingPanel = (SlidingUpPanelLayout)findViewById(R.id.your_sliding_layout);
slidingPanel.setPanelSlideListener(new SimplePanelSlideListener() {
#Override
public void onPanelExpanded(View panel) {
// Insert your code here
}
});
I'm new at vaadin and I want to display some infologs in a textarea. Currently I have set the pushmode in my CustomComponent to PushMode.AUTOMATIC ( #Push(PushMode.AUTOMATIC) ). But this works only the first time. To refresh the text I have to resize the window manual or click a button.
I found something called ICEPush but I do not understand this stuff :( and do not found good tutorials...
Has anybody a hint for me?
Thanks for help!
have you made sure you changed the TextArea value using the ui.access method, and called the ui.push() method?
Kind of like this:
ui.access(new Runnable() {
#Override
public void run() {
textArea.setValue(newValue);
ui.push();
}
});
Before I start, Hi. This is is my first question here. I am not good with Java so have been trying and improve that and here it goes.
I am trying to create an email client and server application using sockets in Java. However I have been running into a problem. I have created a jFrame which is basically the Welcome window. The code is too huge to post so I'll post the relevant portions. There is a preferences jDialog. When the OK button on the dialog, an action handler comes in to play. The code:
private void okActionPerformed(java.awt.event.ActionEvent evt) {
Welcome wel = new Welcome();
wel.setStatusBar("Pressed OK");
dispose();
}
Obviously, the setStatusBar() sets the text of the statusLabel. The code for setStatusBar():
public void setStatusBar(String s)
{
statusLabel.setText(s);
}
Also, the preferences dialog is opened through menu item with this code:
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
settings pref=new settings(null,true);
pref.show();
}
The problem is if I set the status label from any other class, for instance settings class, it does not reflect but if I do so from the Welcome class ( the class where the statusLabel is present), it works fine. This problem is not only limited to this setStatus() but virtually pops up whenever I try to use a method of a different class.
If you guys need more of the code, I could post it. I would be grateful if could help a Java beginner out.
Thanks.
private void okActionPerformed(java.awt.event.ActionEvent evt) {
Welcome wel = new Welcome();
wel.setStatusBar("Pressed OK");
dispose();
}
You're creating a new (hence the keyword new) object of type Welcome. This new object is different from the already existing object of type Welcome, that you have created earlier. It thus has its own label, and you're setting the text of this different label, which is not displayed anywhere in the screen.
Java objects work like regular object. Let's say you would like a cool logo on one of your blue t-shirts. You go to a T-shirt vendor and ask him to print a cool logo. The vendor doesn't have your blue t-shirt. If the vendor gets another red t-shirt from his shop and prints the logo on this red t-shirt, your blue t-shirt will still have no logo at all.
For the vendor to be able to print a logo on your blue t-shirt, you need to give him this blue t-shirt. Same in Java: you need to pass the existing Welcome object to the preferences dialog, and the actionPerformed method must set the label on this Welcome object. Not on a new Welcome object.
I have developed a custom component consist of a layout and two labels within it. This layout is draggable. The code is similar to this :
DragAndDropWrapper boxWrap= new DragAndDropWrapper(layout);
mainLayout.addComponent(boxWrap);
After that I have a RichTextArea that allows the layout to be dropped in it. With this code.
RichTextArea richText= new RichTextArea;
DragAndDropWrapper dndWrapper = new DragAndDropWrapper(richText);
dndWrapper.setDropHandler(new DropHandler() {
public void drop(DragAndDropEvent event) {
//Do whatever you want when something is dropped
}
//Criterio de aceptacion
public AcceptCriterion getAcceptCriterion() {
return AcceptAll.get();
}
});
The code works fine. But when I drop the layout within the RichTextArea y want to get the Text written in this area and add some text but the method richText.getValue() is not updated unless I change the focus to another component or tab out. I guess there is not being communication with the server side so the value is not updated. Is there any way to force a a focus change when mousedown on the layout? I tried with JavaScript but i dont know how to add a onmousedown="function()" attribute to the layout component. I also tried extending RichTextArea and implementing the MouseListener or something or a TextChangeListener, but nothing works.
Any clue? Thank you.
PS: The component cannot be different from a RichTextArea.
Have you set richText.setImmediate(true); ?
we have the following problem:
In our Eclipse RCP 4 application there are multiple parts and the parts are closable. When the user is closing a part there should be a custom pop-up (depending on some internal part state) which is asking the user if he really wants to close the part or not.
It seems to be not that easy to implement in Eclipse RCP 4 or we have just totally overseen something.
I'll just give you a short brieifing about the things we tried:
Use dirtable with a #persist method in the part. Though the problem is, we don't want this standard eclipse save dialog. So is there a way to override this?
public int promptToSaveOnClose(): This seemed to be promising but not for Eclipse 4 or is there a way to integrate it that way? Compare: http://e-rcp.blogspot.de/2007/09/prevent-that-rcp-editor-is-closed.html
Our last try was to integrate a custom part listener, simple example shown in the following:
partService.addPartListener(new IPartListener() {
public void partVisible(MPart part) {
}
public void partHidden(MPart part) {
partService.showPart(part, PartState.ACTIVATE);
}
public void partDeactivated(MPart part) {
}
public void partBroughtToTop(MPart part) {
}
public void partActivated(MPart part) {
}
});
The problem with this was we are running into a continuous loop. Something similar is posted over here in the last comment: Detect tab close in Eclipse editor
So I could write some more about this problem, but I think that's enough for the moment. If you need some more input just give me a hint.
Thanks for helping.
The save prompt is generated by the ISaveHandler registered in the context of the MWindow containing the MPart. You can write your own ISaveHandler and set it in the window context to replace the default.
You might also want to look at the IWindowCloseHandler also in the window context.
Thanks greg, this has helped and I was able to achieve changing the pop-up when the user closes a part. Here's a short description of what I've done:
Use the MDirtyable for marking the part as dirty whenever it's needed.
Create a custom save handler which implements ISaveHandler (when a part got closed the save method is called). Add the additional logic to this handler (e.g. a custom message dialog)
Register this handler at application start-up (I just chose a method which is called at the start-up):
#Inject
private MWindow window;
...
ISaveHandler saveHandler = new CustomSaveHandler(shell);
window.getContext().set(ISaveHandler.class, saveHandler);
Note that the registration via a model processor was sadly not that easy because the model processor is called too early. (Take a look at: http://www.eclipse.org/forums/index.php/t/369989/)
The IWindowCloseHandler is just needed when the complete window is closed, though this was not an requirement for us :).