How to clear the JFrame or JPanel? - jframe

I am planing to develop a quiz program in a JFrame , so after the first question i want to display the second question , so I should clear the first question to display the second question, in C I know it is clrscr(); but in Java I don' know any one can help me ?

You should call
getContentPane().removeAll();
removeAll() has not been overridden as add() or remove() to forward to the contentPane as necessary.

Use it like this
getContentPane().removeAll();

Related

how to allow multi select on gwt combobox

I have combo-box and i want to allow multiple selection on it
how to do that??
newEmployee = new ComboBox<NctrUserDTO>();
newEmployee.setFieldLabel("Employee");
newEmployee.setDisplayField(NctrUserDTO.NAME);
newEmployee.setTriggerAction(TriggerAction.ALL);
newEmployee.setEditable(true);
newEmployee.setStore(employeeList);
newEmployee.setMaxHeight(200);
I don't know which API's ComboBox you're using since vanilla GWT doesn't have a ComboBox, but I'd guess it's not possible to do this unless you change the ComboBox class itself/write an actual MultiSelectComboBox class. Unless your version happens to have an "enableMultiSelect" method already in-built, but you probably wouldn't be asking here then.
If it helps, I found this thread which seems similar to what you're describing.

How can I take something in then out in Eclipse?

I have been looking for a way to pull something out of my main method into a outer method then plop the output of the outer method back into the main method (this is in Eclipse).
I have been looking for a strangely long time for a answer for this but everything seems way more advanced than what I am looking for. If anyone can help it would be a great help.
You want the extract method refactoring. Select the code block that you want move into a different method and press Shift-Ctrl-M. Or is it Ctrl-Alt-M? Can't remember right now.
And here I go giving refactorings to someone that doesn't even know what a method is....

Get size of JFrame from inside JPanel

I am making a small library that lets me make some graphs for a different project I'm working on (I don't want to download another library), and I set it up so each type of graph (pie, bar, line) extends JPanel, and everything inside those graphs (Points, lines, grids) are extensions of JComponent. But in some times, like when making the grid, I need to know how much space the JPanel takes up on the JFrame.
Is there any way to find out how big a JPanel (has to be resizable) will be on a JFrame from a JComponent?
while it is easy to find information from top down, A JFrame can get from a JPanel which can get from a JComponent, but I cant do the opposite, have a JComponent get from a JPanel which would get from a JFrame.
thanks in advanced!!
EDIT: figured it out, look at my answer to see it.
Are u talking about how to set size on JPanel?
JPanel f=new JPanel();
f.setSize(500,500);
If you want to resize,u may use action listener
To do what I was asking in the OP, all you need to do is put at the size of the frame itself as an argument in the methods that do the drawing, it was much simpler than I was making it out to be... I was originally trying to access the information without it being an argument, but I don't think that is possible, so if you have the same problem as I did then just pass it through the methods as an arguement.

Where to Update a JFrame

Hi I have a JFrame class that I update based on information I recieve from another class. I have created an update method within the JFrame which I use to update the different objects on the page. But my Question is is that the correct thing to do?
You can make it however you want, there is no "right" way. It's all a matter of preference. Personally, I like that way of doing it. In almost all of my GUI's I have a method called "update()" or something similar.
its depends on how updates are being triggered, but using event-listeners and actionCommands might be helpful. I don't necessarily like this methods but it is convenient.

how to close a method/function on iPhone xCode?

when your project is getting bigger and bigger we have to look for ways to make it more easy to read.
The point is, I want to close all my functions using any key short code in my Xcode, let see the picture attached to understand what I mean:
(I cannot set any picture becuase I need more reputation...)
Well I mean:
> - (void) process1 {
}
If we press on the row on top left, the process will get closed. How can I use a key short code to close all my functions/methods on my class (.m)?
Thank you!
Check the View→Code Folding menu for options and hot-keys.
I'm pretty sure it's here. You'll also find other cool stuff
Hidden Features of Xcode