<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <text value="Placeholder text:"/>
+ <text value="Placeholder:"/>
</properties>
</component>
<grid id="cbc70" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
</component>
</children>
</grid>
- <component id="f86b4" class="javax.swing.JCheckBox" binding="myCreateHintCheckBox" default-binding="true">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <margin top="2" left="0" bottom="2" right="2"/>
- <text value="Create hint"/>
- <verticalAlignment value="0"/>
- </properties>
- </component>
<grid id="51a63" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
</component>
</children>
</grid>
+ <component id="61da7" class="javax.swing.JLabel">
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Hint:"/>
+ </properties>
+ </component>
</children>
</grid>
</form>
import javax.swing.*;
import java.awt.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
public class CCCreateAnswerPlaceholderPanel extends JPanel {
private JPanel myPanel;
private JTextArea myHintText;
- private JCheckBox myCreateHintCheckBox;
private JTextField myAnswerPlaceholderText;
public CCCreateAnswerPlaceholderPanel() {
super(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
- enableHint(false);
myHintText.setLineWrap(true);
myHintText.setWrapStyleWord(true);
- myCreateHintCheckBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- int state = e.getStateChange();
- // 1 for checked
- enableHint(state == 1);
- if (state == 2) {
- resetHint();
- }
- }
- });
-
myAnswerPlaceholderText.grabFocus();
}
- private void enableHint(boolean isEnable) {
- myHintText.setEnabled(isEnable);
- }
-
public void setAnswerPlaceholderText(String answerPlaceholderText) {
myAnswerPlaceholderText.setText(answerPlaceholderText);
}
return myHintText.getText();
}
- public void doClick() {
- myCreateHintCheckBox.doClick();
- }
-
- public void resetHint() {
- myHintText.setText("");
- }
-
public JComponent getPreferredFocusedComponent() {
return myAnswerPlaceholderText;
}