本文整理汇总了Java中org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior类的典型用法代码示例。如果您正苦于以下问题:Java FocusBehavior类的具体用法?Java FocusBehavior怎么用?Java FocusBehavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FocusBehavior类属于org.jdesktop.swingx.prompt.PromptSupport包,在下文中一共展示了FocusBehavior类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
protected void initialize() {
setPreferred(true, "prompt", "promptForeground", "promptBackground", "focusBehavior",
"promptFontStyle");
setEnumerationValues(new EnumerationValue[] {
new EnumerationValue("Default", null, "null"),
new EnumerationValue("Plain", Font.PLAIN, "java.awt.Font.PLAIN"),
new EnumerationValue("Bold", Font.BOLD, "java.awt.Font.BOLD"),
new EnumerationValue("Italic", Font.ITALIC, "java.awt.Font.ITALIC"),
new EnumerationValue("Bold & Italic", Font.BOLD | Font.ITALIC,
"java.awt.Font.BOLD | java.awt.Font.ITALIC") }, "promptFontStyle");
setEnumerationValues(new EnumerationValue[] {
new EnumerationValue("Show", FocusBehavior.SHOW_PROMPT,
"org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior.SHOW_PROMPT"),
new EnumerationValue("Hide", FocusBehavior.HIDE_PROMPT,
"org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior.HIDE_PROMPT"),
new EnumerationValue("Highlight", FocusBehavior.HIGHLIGHT_PROMPT,
"org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT"), }, "focusBehavior");
}
示例2: setEnable
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
public void setEnable(boolean val) {
this.editor.setEnabled(val);
if (val) {
PromptSupport.setForeground(Color.LIGHT_GRAY, textField);
PromptSupport.setPrompt(PROMPT, textField);
PromptSupport.setFontStyle(Font.ITALIC, textField);
PromptSupport.setFocusBehavior(FocusBehavior.SHOW_PROMPT, textField);
} else {
PromptSupport.setPrompt("", textField);
}
}
示例3: LicenseEnteringDialog
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
public LicenseEnteringDialog(Window owner, String key, Object... arguments) {
super(owner, key, ModalityType.APPLICATION_MODAL, arguments);
this.textArea = new JTextArea();
this.statusLabel = new JLabel();
this.startDateLabel = new JLabel();
this.expirationDateLabel = new JLabel();
this.registeredToLabel = new JLabel();
this.productLabel = new JLabel();
this.editionLabel = new JLabel();
this.parseError = true;
if(arguments.length > 0) {
this.productName = String.valueOf(arguments[0]);
}
this.mainPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = 1;
c.gridx = 0;
c.gridy = 0;
this.detailsPanel = this.makeDetailsPanel();
this.mainPanel.add(this.detailsPanel, c);
this.textPane = this.makeTextPane("");
c.gridy = 1;
c.insets = new Insets(10, 0, 0, 0);
this.mainPanel.add(this.textPane, c);
this.installButton = this.makeInstallButton();
PromptSupport.setForeground(Color.GRAY, this.textArea);
PromptSupport.setPrompt(I18N.getGUILabel("license.paste_here", new Object[0]), this.textArea);
PromptSupport.setFontStyle(Integer.valueOf(2), this.textArea);
PromptSupport.setFocusBehavior(FocusBehavior.SHOW_PROMPT, this.textArea);
this.textArea.setText(this.getLicenseKeyFromClipboard());
this.setValuesForDetailsPanel();
this.layoutDefault(this.mainPanel, this.makeButtonPanel());
this.setResizable(false);
}
示例4: testSetFocusBehavior
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
@Test
public void testSetFocusBehavior() throws Exception {
PromptSupport.setFocusBehavior(FocusBehavior.HIGHLIGHT_PROMPT, txt);
assertEquals(FocusBehavior.HIGHLIGHT_PROMPT, PromptSupport.getFocusBehavior(txt));
assertEquals(FocusBehavior.HIGHLIGHT_PROMPT, txt.getClientProperty(PromptSupport.FOCUS_BEHAVIOR));
}
示例5: createTextField
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
public static JXTextField createTextField(final String promptText, final int columns) {
final JXTextField tf = new JXTextField(promptText);
tf.setColumns(columns);
if (promptText != null) {
tf.setFocusBehavior(FocusBehavior.SHOW_PROMPT);
tf.setToolTipText(promptText);
}
return tf;
}
示例6: CellTypeTextFieldDefaultImpl
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
/**
* Creates a {@link JFormattedTextField} for the specified cell. If a formatter is given, will
* apply it to the field. Does not validate the model, so make sure this call works!
*
* @param model
* @param rowIndex
* @param columnIndex
* @param cellClass
* @param formatter
* the formatter or <code>null</code> if none is required
* @param hideUnavailableContentAssist
* @return
*/
public CellTypeTextFieldDefaultImpl(final TablePanelModel model, final int rowIndex, final int columnIndex,
final Class<? extends CellType> cellClass, AbstractFormatter formatter, boolean hideUnavailableContentAssist) {
super();
final JFormattedTextField field = CellTypeImplHelper.createFormattedTextField(model, rowIndex, columnIndex);
setLayout(new BorderLayout());
add(field, BorderLayout.CENTER);
// otherwise 'null' would be restored
Object value = model.getValueAt(rowIndex, columnIndex);
String text = value != null ? String.valueOf(value) : "";
// specical handling when formatter is given
if (formatter != null) {
field.setFormatterFactory(new DefaultFormatterFactory(formatter));
}
field.setText(text);
// set syntax assist if available
String syntaxHelp = model.getSyntaxHelpAt(rowIndex, columnIndex);
if (syntaxHelp != null && !"".equals(syntaxHelp.trim())) {
PromptSupport.setForeground(Color.LIGHT_GRAY, field);
PromptSupport.setPrompt(syntaxHelp, field);
PromptSupport.setFontStyle(Font.ITALIC, field);
PromptSupport.setFocusBehavior(FocusBehavior.SHOW_PROMPT, field);
}
// see if content assist is possible for this field, if so add it
ImageIcon icon = SwingTools.createIcon("16/"
+ I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.action.content_assist.icon"));
JButton contentAssistButton = new JButton();
contentAssistButton.setIcon(icon);
if (field.isEnabled() && model.isContentAssistPossibleForCell(rowIndex, columnIndex)) {
contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(),
"gui.action.content_assist_enabled.tip"));
CellTypeImplHelper.addContentAssist(model, rowIndex, columnIndex, field, contentAssistButton, cellClass);
} else {
contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(),
"gui.action.content_assist_disabled.tip"));
contentAssistButton.setEnabled(false);
}
if (contentAssistButton.isEnabled() || (!contentAssistButton.isEnabled() && !hideUnavailableContentAssist)) {
add(contentAssistButton, BorderLayout.EAST);
}
// set size so panels don't grow larger when they get the chance
setPreferredSize(new Dimension(300, 20));
setMinimumSize(new Dimension(100, 15));
setMaximumSize(new Dimension(1600, 30));
}
示例7: getFocusBehavior
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
/**
* @see PromptSupport#getFocusBehavior(javax.swing.text.JTextComponent)
*/
public FocusBehavior getFocusBehavior() {
return PromptSupport.getFocusBehavior(this);
}
示例8: setFocusBehavior
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
/**
* @see PromptSupport#getFocusBehavior(javax.swing.text.JTextComponent)
*/
public void setFocusBehavior(FocusBehavior focusBehavior) {
PromptSupport.setFocusBehavior(focusBehavior, this);
}
示例9: getPromptComponent
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
/**
* Creates a label component, if none has already been created. Sets the
* prompt components properties to reflect the given {@link JTextComponent}s
* properties and returns it.
*
* @param txt
* @return the adjusted prompt component
*/
public JTextComponent getPromptComponent(JTextComponent txt) {
if (promptComponent == null) {
promptComponent = createPromptComponent();
}
if (txt.isFocusOwner()
&& PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
promptComponent.setText(null);
} else {
promptComponent.setText(PromptSupport.getPrompt(txt));
}
promptComponent.getHighlighter().removeAllHighlights();
if (txt.isFocusOwner()
&& PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
promptComponent.setForeground(txt.getSelectedTextColor());
try {
promptComponent.getHighlighter().addHighlight(0,
promptComponent.getText().length(),
new DefaultHighlightPainter(txt.getSelectionColor()));
} catch (BadLocationException e) {
e.printStackTrace();
}
} else {
promptComponent.setForeground(PromptSupport.getForeground(txt));
}
if (PromptSupport.getFontStyle(txt) == null) {
promptComponent.setFont(txt.getFont());
} else {
promptComponent.setFont(txt.getFont().deriveFont(
PromptSupport.getFontStyle(txt)));
}
promptComponent.setBackground(PromptSupport.getBackground(txt));
promptComponent.setHighlighter(new PainterHighlighter(PromptSupport
.getBackgroundPainter(txt)));
promptComponent.setEnabled(txt.isEnabled());
promptComponent.setOpaque(txt.isOpaque());
promptComponent.setBounds(txt.getBounds());
Border b = txt.getBorder();
if (b == null) {
promptComponent.setBorder(txt.getBorder());
} else {
Insets insets = b.getBorderInsets(txt);
promptComponent.setBorder(
createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
}
promptComponent.setSelectedTextColor(txt.getSelectedTextColor());
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
return promptComponent;
}
示例10: testGetFocusBehavior
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
@Test
public void testGetFocusBehavior() throws Exception {
assertEquals(FocusBehavior.HIDE_PROMPT, PromptSupport.getFocusBehavior(txt));
}
示例11: init
import org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior; //导入依赖的package包/类
private void init() {
setLayout(new GridBagLayout());
workspace = new JXTextField();
workspace.setPromptForeground(Color.LIGHT_GRAY);
workspace.setFocusBehavior(FocusBehavior.SHOW_PROMPT);
timestamp = new JFormattedTextField(new SimpleDateFormat("dd.MM.yyyy"));
timestamp.setFocusLostBehavior(JFormattedTextField.COMMIT);
timestamp.setColumns(10);
workspaceLabel = new JLabel();
timestampLabel = new JLabel();
add(workspaceLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.BOTH,0,0,5,5));
add(workspace, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));
add(timestampLabel, GuiUtil.setConstraints(2,0,0.0,0.0,GridBagConstraints.NONE,0,10,5,5));
add(timestamp, GuiUtil.setConstraints(3,0,0.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,0));
timestamp.setMinimumSize(timestamp.getPreferredSize());
operationsTab = new JTabbedPane();
GridBagConstraints c = GuiUtil.setConstraints(0,2,1.0,1.0,GridBagConstraints.BOTH,5,0,0,0);
c.gridwidth = 4;
add(operationsTab, c);
operations = new DatabaseOperationView[3];
operations[0] = new ReportOperation(this);
operations[1] = new BoundingBoxOperation(this, config);
operations[2] = new IndexOperation(this, config);
for (int i = 0; i < operations.length; ++i)
operationsTab.insertTab(null, operations[i].getIcon(), null, operations[i].getToolTip(), i);
operationsTab.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int index = operationsTab.getSelectedIndex();
for (int i = 0; i < operationsTab.getTabCount(); ++i)
operationsTab.setComponentAt(i, index == i ? operations[index].getViewComponent() : null);
}
});
PopupMenuDecorator.getInstance().decorate(workspace, timestamp);
}