Wrong display of components. [message #907172] |
Mon, 03 September 2012 12:57 |
kol kol Messages: 5 Registered: September 2012 |
Junior Member |
|
|
Hello.
Please tell me if this is a bug or intentional.
Structure of my GUI:
JPanel called "main" is added to JFrame called "application".
To JPanel "main" i've added JPanels "A" and "B".
I have such classes that describe JPanel "A" and some specific text field:
public class A extends JPanel
{
private JTextField jtf;
public A()
{
jtf = new JTextField();
...setting size and positions...
add(jtf);
}
class VerySpecificJTF extends SpecificJTF
{
public VerySpecificJTF (){}
}
}
=========class in another file===============
abstract public class SpecificJTF extends JTextField
{
...some code...
}
}
As you see, there is an inner class VerySpecificJTF .
But now I just added standard JTextField to JPanel "A". All is ok. Text field is visible both when i use Design view directly on JPanel "A" and JForm "application".
BUT when i will use this code:
public class A extends JPanel
{
private VerySpecificJTF jtf;
public A()
{
jtf = new VerySpecificJTF();
...setting size and positions...
add(jtf);
}
class VerySpecificJTF extends SpecificJTF
{
public VerySpecificJTF (){}
}
}
i dont see any VerySpecificJTF on JPanel "A" but i see it in Design view of JFrame "application". Is this proper behaviour?
[Updated on: Mon, 03 September 2012 12:58] Report message to a moderator
|
|
|
|
Re: Wrong display of components. [message #907511 is a reply to message #907207] |
Tue, 04 September 2012 06:42 |
kol kol Messages: 5 Registered: September 2012 |
Junior Member |
|
|
Do you think that this is proper way of handling components?
Inner class has this advantage that indicates that its used only in range of enclosing one.
Besides it can use methods of its container.
When i will export customized button to separate class i have to pass parent to this component and make some methods of this parent public. This is not "pretty" programming.
I have impression that WindowBuilder makes easier proccess of creation GUI but makes difficult to use some basic advantages of Java.
Is any way to change this default way of parsing code in WB?
Can you explain me why there are different visibilities on different levels?
[Updated on: Tue, 04 September 2012 06:50] Report message to a moderator
|
|
|
|
Re: Wrong display of components. [message #908361 is a reply to message #907995] |
Wed, 05 September 2012 08:34 |
kol kol Messages: 5 Registered: September 2012 |
Junior Member |
|
|
Thank you for information. This clarifies a situation.
Can you give me a hint how to solve this situation using WindowBuilder:
I want to create a pattern to prevent (eg accidentally) omiting some important components on JPanel. Simply speaking i want to have some checkBox that indicates if this panel should be available in particular situation or not.
I ensure this by using abstract class:
public abstract class PatternPanel extends JPanel
{
public JCheckBox isActive;
abstract void someMethod();
...
}
Because of all restrictions mentioned in previous posts application will be working, but design view will omit isActive element when i extend my new JPanel using SomePanel.
[Updated on: Wed, 05 September 2012 08:36] Report message to a moderator
|
|
|
|
Re: Wrong display of components. [message #908863 is a reply to message #908750] |
Thu, 06 September 2012 06:16 |
kol kol Messages: 5 Registered: September 2012 |
Junior Member |
|
|
I would like to create JPanel pattern for enforce of using some components with every panel created by his extension.
Can you give me a hint how to solve this situation using WindowBuilder? "solve" means to do it in this way which will make possible components to be displayed by WindowBuilder.
I don't need a specific code but if you have any example how to do it, it would be great.
===== PatternPanel.java ================
public abstract class PatternPanel extends JPanel
{
public JCheckBox isActive; //should be this panel active or not
abstract void someMethod();
}
===== SpecificPanel.java ================
public SpecificPanel extends PatternPanel
{
//JCheckBox isActive = new JCheckBox(); //isActive will be showed but for me this is useless
public SpecificPanel()
{isActive = new JCheckBox(); //isActive will not be showed on SpecifecPanel in design view. How to do that design wiev will show this component?
isActive.setEnabled(true);
}
void someMethod(){};
[Updated on: Thu, 06 September 2012 06:17] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06482 seconds