下面列出了javax.swing.JTextField#setToolTipText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JTextField createEntry(String labelText, int cols, String text,
String toolTipText, JComponent labels,
JComponent values)
{
Box boxLabel = Box.createHorizontalBox();
boxLabel.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n(labelText));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
boxLabel.add(label);
labels.add(boxLabel);
JPanel fieldPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JTextField field = new JTextField(cols);
field.setHorizontalAlignment(JTextField.CENTER);
field.setToolTipText(i18n(toolTipText));
field.setText(text);
fieldPanel.add(field);
values.add(fieldPanel);
return field;
}
/**
* Adds another row at the end of the Business Transactions.
*/
private void addBizTransactionRow() {
JTextField bizTransID = new JTextField();
bizTransID.setToolTipText(CaptureClientHelper.toolTipBizTransID);
JTextField bizTransType = new JTextField();
bizTransType.setToolTipText(CaptureClientHelper.toolTipBizTransType);
ImageIcon tempDelIcon = CaptureClientHelper.getImageIcon("delete10.gif");
JButton minus = new JButton(tempDelIcon);
minus.setMargin(new Insets(0, 0, 0, 0));
minus.addActionListener(this);
mwBizTransTypeFields.add(bizTransType);
mwBizTransIDFields.add(bizTransID);
mwBizTransButtons.add(minus);
drawBizTransaction();
}
@SuppressWarnings("unchecked")
public TimeField(int cols, String toolTipText)
{
super(BoxLayout.Y_AXIS);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
add(Box.createVerticalGlue());
add(panel);
add(Box.createVerticalGlue());
m_textField = new JTextField(cols);
m_textField.setHorizontalAlignment(JTextField.RIGHT);
m_textField.setToolTipText(i18n(toolTipText));
panel.add(m_textField);
panel.add(GuiUtil.createSmallFiller());
String[] units = { i18n("LB_GAMEINFO_MIN"),
i18n("LB_GAMEINFO_SEC") };
m_comboBox = new JComboBox(units);
panel.add(m_comboBox);
}
private Box getDomainPanel(JTextField f){
JLabel l01 = new JLabel("Input structures:");
Box hBox = Box.createHorizontalBox();
hBox.add(Box.createGlue());
hBox.add(l01);
f.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
f.setToolTipText("Provide structure identifiers space separated.");
hBox.add(Box.createVerticalGlue());
hBox.add(f, BorderLayout.CENTER);
hBox.add(Box.createGlue());
return hBox;
}
private JTextField createTextField(String tooltip, String value) {
JTextField field = new JTextField(value);
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.getDocument().addDocumentListener(this);
Dimension size = field.getPreferredSize();
Dimension maxSize = field.getMaximumSize();
maxSize.height = size.height;
field.setMaximumSize(maxSize);
add(field);
return field;
}
private JTextField createCorrectableField(Container parent, String title, String text, String tooltip) {
JTextField field = new JTextField(text);
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.setEnabled(mIsEditable);
field.getDocument().addDocumentListener(this);
field.addFocusListener(this);
LinkedLabel label = new LinkedLabel(title);
label.setLink(field);
parent.add(label);
parent.add(field);
return field;
}
private JTextField createCorrectableField(Container parent, String title, String text, String tooltip) {
JTextField field = new JTextField(text);
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.setEnabled(mIsEditable);
field.getDocument().addDocumentListener(this);
LinkedLabel label = new LinkedLabel(title);
label.setLink(field);
parent.add(label);
parent.add(field);
return field;
}
private ColorFields createColorEntry(String labelText, int cols,
String toolTipBlack,
String toolTipWhite,
JComponent labels,
JComponent values)
{
labels.add(createEntryLabel(labelText));
ColorFields colorFields = new ColorFields();
JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
panel.add(new JLabel(ICON_BLACK));
panel.add(GuiUtil.createSmallFiller());
JTextField black = new JTextField(cols);
black.setHorizontalAlignment(JTextField.CENTER);
colorFields.m_black = black;
GuiUtil.setEditableFalse(black);
if (toolTipBlack != null)
black.setToolTipText(i18n(toolTipBlack));
panel.add(black);
panel.add(GuiUtil.createFiller());
panel.add(new JLabel(ICON_WHITE));
panel.add(GuiUtil.createSmallFiller());
JTextField white = new JTextField(cols);
white.setHorizontalAlignment(JTextField.CENTER);
colorFields.m_white = white;
GuiUtil.setEditableFalse(white);
if (toolTipWhite != null)
white.setToolTipText(i18n(toolTipWhite));
panel.add(white);
values.add(panel);
return colorFields;
}
private void createWeightAdjustmentField(Container labelParent, Container fieldParent) {
mWeightAmountField = new JTextField("-999,999,999.00");
UIUtilities.setToPreferredSizeOnly(mWeightAmountField);
mWeightAmountField.setText(mRow.getWeightAdjType().format(mRow.getWeightAdjAmount(), mRow.getDataFile().defaultWeightUnits(), true));
mWeightAmountField.setToolTipText(I18n.Text("The weight modifier"));
mWeightAmountField.setEnabled(mIsEditable);
mWeightAmountField.addActionListener(this);
mWeightAmountField.addFocusListener(this);
labelParent.add(new LinkedLabel("", mWeightAmountField));
fieldParent.add(mWeightAmountField);
}
private JTextField createField(Container labelParent, Container fieldParent, String title, String text, String tooltip, int maxChars) {
JTextField field = new JTextField(maxChars > 0 ? Text.makeFiller(maxChars, 'M') : text);
if (maxChars > 0) {
UIUtilities.setToPreferredSizeOnly(field);
field.setText(text);
}
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.setEnabled(mIsEditable);
field.addFocusListener(this);
labelParent.add(new LinkedLabel(title, field));
fieldParent.add(field);
return field;
}
private void initInstantiate()
{
mShowInput = new JCheckBox("Inputs");
mShowIntent = new JCheckBox("Intents");
mShowOutput = new JCheckBox("Outputs");
mShowError = new JCheckBox("Errors");
mShowCards = new JCheckBox("Cards");
mShowReprompt = new JCheckBox("Reprompt");
mShowVerbose = new JCheckBox("Misc");
mSend = new JButton("Send");
mSend.setToolTipText("Send an IntentReqeust to the app");
mClear = new JButton("Clear");
mClear.setToolTipText("Clear history");
mStartSession = new JButton("\u25b6");
mStartSession.setToolTipText("Send a LaunchReqeust to the app");
mEndSession = new JButton("\u25a0");
mEndSession.setToolTipText("Send a SessionEndedReqeust to the app");
mSave = new JButton("Save");
mSave.setToolTipText("Save history");
mLoad = new JButton("Load");
mLoad.setToolTipText("Load history");
mInput = new JTextField(40);
mIntent = new JTextField(40);
mIntent.setEditable(false);
mIntent.setToolTipText("This is the intent your text will be translated into");
mTranscript = new JList<TransactionBean>(new HistoryModel(mRuntime));
mTranscript.setCellRenderer(new HistoryCellRenderer(mRuntime));
}
@SuppressWarnings("unused")
private JTextField createValueField(Container labelParent, Container fieldParent, String title, Fixed6 value, String tooltip, int maxDigits) {
JTextField field = new JTextField(Text.makeFiller(maxDigits, '9') + Text.makeFiller(maxDigits / 3, ',') + ".");
UIUtilities.setToPreferredSizeOnly(field);
field.setText(value.toLocalizedString());
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.setEnabled(mIsEditable);
new NumberFilter(field, true, false, true, maxDigits);
field.addActionListener(this);
field.addFocusListener(this);
labelParent.add(new LinkedLabel(title, field));
fieldParent.add(field);
return field;
}
private void addProcedureSeparatorTextField(JPanel panel, int col, int row)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = col;
c.gridy = row;
c.ipadx = 40; // Increases component width by 20 pixels
c.insets = new Insets(5, 5, 0, 0);
c.anchor = GridBagConstraints.WEST;
procedureSeparatorTextField = new JTextField(10);
procedureSeparatorTextField.setHorizontalAlignment(JTextField.RIGHT);
procedureSeparatorTextField.setToolTipText(i18n.PROC_SEP_LABEL_TT);
panel.add(procedureSeparatorTextField, c);
}
private void createFilterField() {
mFilterField = new JTextField(10);
mFilterField.getDocument().addDocumentListener(this);
mFilterField.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("Enter text here to narrow the list to only those rows containing matching items")));
// This client property is specific to Mac OS X
mFilterField.putClientProperty("JTextField.variant", "search");
mFilterField.setMinimumSize(new Dimension(60, mFilterField.getPreferredSize().height));
mToolbar.add(mFilterField, Toolbar.LAYOUT_FILL);
}
private JTextField createField(Container labelParent, Container fieldParent, String title, String text, String tooltip, int maxChars) {
JTextField field = new JTextField(maxChars > 0 ? Text.makeFiller(maxChars, 'M') : text);
if (maxChars > 0) {
UIUtilities.setToPreferredSizeOnly(field);
field.setText(text);
}
field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
field.setEnabled(mIsEditable);
labelParent.add(new LinkedLabel(title, field));
fieldParent.add(field);
field.addActionListener(this);
field.addFocusListener(this);
return field;
}
/**
* Creates a new FullPlayerSearchField.
*/
public FullPlayerSearchField() {
super( Id.FULL_PLAYER );
textComboBox = GuiUtils.createPredefinedListComboBox( PredefinedList.REP_SEARCH_FULL_PLAYER_NAME, true );
textField = (JTextField) textComboBox.getEditor().getEditorComponent();
textField.setToolTipText( Language.getText( "module.repSearch.tab.filters.name.playerNameToolTip" ) );
uiComponent.add( textComboBox );
uiComponent.add( includeAliases );
}
private void addLineCommentTextField(JPanel panel, int col, int row)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = col;
c.gridy = row;
c.ipadx = 40; // Increases component width by 40 pixels
c.insets = new Insets(5, 5, 0, 0);
c.anchor = GridBagConstraints.WEST;
lineCommentTextField = new JTextField(10);
lineCommentTextField.setName("lineCommentTextField");
lineCommentTextField.setHorizontalAlignment(JTextField.RIGHT);
lineCommentTextField.setToolTipText(i18n.LINE_COMMENT_LABEL_TT);
panel.add(lineCommentTextField, c);
}
public void TesteComponente(){
janela.setVisible(true);
janela.setSize(DIMENSOES);
janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane teste1 = new JScrollPane(painel);
teste1.setBounds(1, 2, 150, 200);
JButton teste2 = new JButton("Aperte");
teste2.setBounds(210, 2, 100, 100);
JToggleButton teste3 = new JToggleButton("Toggle");
teste3.setBounds(320, 2, 100, 100);
JCheckBox teste4 = new JCheckBox("Teste");
teste4.setBounds(430, 2, 100, 100);
JRadioButton teste5 = new JRadioButton("Teste2");
teste5.setBounds(540, 2, 100, 100);
JTextField teste6 = new JTextField();
teste6.setToolTipText("Seu Nome");
teste6.setBounds(1, 205, 200, 50);
String[] numeros = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
JList teste7 = new JList(numeros);
JScrollPane teste7_2 = new JScrollPane(teste7);
teste7_2.setBounds(210, 205, 100, 100);
String[] numeros2 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
JComboBox teste8 = new JComboBox(numeros2);
teste8.setBounds(320, 205, 50, 50);
JLabel teste9 = new JLabel();
teste9.setText("Biografia: ");
teste9.setBounds(1, 290, 200, 100);
JTextArea teste10 = new JTextArea();
teste10.setToolTipText("Biografia");
teste10.setBounds(1, 350, 100, 100);
teste2.addActionListener(this);
teste3.addActionListener(this);
teste4.addActionListener(this);
teste5.addActionListener(this);
janela.add(teste1);
janela.add(teste2);
janela.add(teste3);
janela.add(teste4);
janela.add(teste5);
janela.add(teste6);
janela.add(teste7);
janela.add(teste8);
janela.add(teste9);
janela.add(teste10);
}
private void fillUi(JPanel canvas) {
JLabel projectDataDirLabel = new JBLabel("Project data directory:");
canvas.setPreferredSize(ProjectViewUi.getContainerSize());
projectDataDirField = new TextFieldWithBrowseButton();
projectDataDirField.setName("project-data-dir-field");
projectDataDirField.addBrowseFolderListener(
"",
buildSystemName + " project data directory",
null,
PROJECT_FOLDER_DESCRIPTOR,
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
false);
final String dataDirToolTipText = "Directory in which to store the project's metadata.";
projectDataDirField.setToolTipText(dataDirToolTipText);
projectDataDirLabel.setToolTipText(dataDirToolTipText);
canvas.add(projectDataDirLabel, UiUtil.getLabelConstraints(0));
canvas.add(projectDataDirField, UiUtil.getFillLineConstraints(0));
JLabel projectNameLabel = new JLabel("Project name:");
projectNameField = new JTextField();
final String projectNameToolTipText = "Project display name.";
projectNameField.setToolTipText(projectNameToolTipText);
projectNameField.setName("project-name-field");
projectNameLabel.setToolTipText(projectNameToolTipText);
canvas.add(projectNameLabel, UiUtil.getLabelConstraints(0));
canvas.add(projectNameField, UiUtil.getFillLineConstraints(0));
JLabel defaultNameLabel = new JLabel("Infer name from:");
workspaceDefaultNameOption = new JRadioButton("Workspace");
branchDefaultNameOption = new JRadioButton("Branch");
importDirectoryDefaultNameOption = new JRadioButton("Import Directory");
workspaceDefaultNameOption.setToolTipText("Infer default name from the workspace name");
branchDefaultNameOption.setToolTipText(
"Infer default name from the current branch of your workspace");
importDirectoryDefaultNameOption.setToolTipText(
"Infer default name from the directory used to import your project view");
workspaceDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
branchDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
importDirectoryDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(workspaceDefaultNameOption);
buttonGroup.add(branchDefaultNameOption);
buttonGroup.add(importDirectoryDefaultNameOption);
canvas.add(defaultNameLabel, UiUtil.getLabelConstraints(0));
canvas.add(workspaceDefaultNameOption, UiUtil.getLabelConstraints(0));
canvas.add(branchDefaultNameOption, UiUtil.getLabelConstraints(0));
canvas.add(importDirectoryDefaultNameOption, UiUtil.getLabelConstraints(0));
canvas.add(new JPanel(), UiUtil.getFillLineConstraints(0));
projectViewUi.fillUi(canvas);
}
public ReplaceStringsOptions() {
this.setIconImages(Resources.iconList);
setSize(new Dimension(250, 176));
setResizable(false);
setTitle("Replace Strings");
getContentPane().setLayout(null);
JButton btnNewButton = new JButton("Start Replacing");
btnNewButton.setBounds(6, 115, 232, 23);
getContentPane().add(btnNewButton);
JLabel lblNewLabel = new JLabel("Original LDC:");
lblNewLabel.setBounds(6, 40, 67, 14);
getContentPane().add(lblNewLabel);
textField = new JTextField();
textField.setBounds(80, 37, 158, 20);
getContentPane().add(textField);
textField.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("New LDC:");
lblNewLabel_1.setBounds(6, 65, 77, 14);
getContentPane().add(lblNewLabel_1);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(80, 62, 158, 20);
getContentPane().add(textField_1);
JLabel lblNewLabel_2 = new JLabel("Class:");
lblNewLabel_2.setBounds(6, 90, 46, 14);
getContentPane().add(lblNewLabel_2);
textField_2 = new JTextField();
textField_2.setToolTipText("* will search all classes");
textField_2.setText("*");
textField_2.setBounds(80, 87, 158, 20);
getContentPane().add(textField_2);
textField_2.setColumns(10);
final JCheckBox chckbxNewCheckBox = new JCheckBox(
"Replace All Contains");
chckbxNewCheckBox
.setToolTipText("If it's unticked, it will check if the string equals, if its ticked it will check if it contains, then replace the original LDC part of the string.");
chckbxNewCheckBox.setBounds(6, 7, 232, 23);
getContentPane().add(chckbxNewCheckBox);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
PluginManager.runPlugin(new ReplaceStrings(textField.getText(),
textField_1.getText(), textField_2.getText(),
chckbxNewCheckBox.isSelected()));
dispose();
}
});
this.setLocationRelativeTo(null);
}