|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi,
I have 2 java questions, and because i'm a bit of a newbie programmer i'd like it if gave examples with any explanations! ![]() 1) In an applet, how do i set it so that after an event (like a button click) the GUI gets replaced by a different GUI? so all the previous buttons/textfields/prompts etc are replaced by different buttons and textfields 2) I have an array of objects. This object has 19 arguments (!). Do you think this is too disorganized? and if so, how could i organize it? It's part of a university assignment so readability of code is certainly important. |
|
#2
|
|||
|
|||
|
1) You might try having a function that does getContentPane().removeAll(), the adding your new components. Either one function for each layout or one function that lets you choose layouts.
You could also a Container object for each layout you want then use setContentPane() to switch between them. 2) Yes, that sounds rather disorganized. Any way you can break that down into multiple classes? If not, well, make sure you document it well ![]() |
|
#3
|
|||
|
|||
|
Quote:
hmm...care to give an example? ![]() |
|
#4
|
|||
|
|||
|
Code:
public layout2() {
JLabel label = new JLabel("Dude!");
label.setHorizontalAlignment(JLabel.CENTER);
label.setBorder(BorderFactory.createMatteBorder(1,1,2,2,Color.black));
getContentPane().removeAll();
getContentPane().add(label, BorderLayout.CENTER);
}
|
|
#5
|
|||
|
|||
|
sank yuu
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > newbie java questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|