下面列出了javax.swing.JTextField#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void setup() {
this.setLayout(new MigLayout("ins 5,center"));
this.setBackground(Color.BLACK);
usernameField = new JTextField();
usernameField.setDocument(new LengthRestrictedDocument(12));
usernameField.setBackground(new Color(101, 101, 101));
usernameField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
xpDisplay = new JLabel();
rsnLabel = new JLabel("RSN:");
rsnLabel.setForeground(Color.white);
rsnLabel.setFont(new Font(rsnLabel.getFont().getFontName(), Font.BOLD, rsnLabel.getFont().getSize()));
levelsDisplayPanel = new LevelsPanel();
levelsDisplayPanel.setRolloverListener(this);
levelInfoPanel = new LevelInfoPanel();
searchButton = new JButton();
searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/searchiconsquare3.png")));
//searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/bwsearch2.png")));
searchButton.setBorderPainted(false);
searchButton.setFocusPainted(false);
searchButton.setContentAreaFilled(false);
add(rsnLabel, "cell 0 0, gap 0, align left");
add(usernameField, "width 60%, cell 1 0,align left, ");
add(searchButton, "cell 2 0,align right ");
add(levelsDisplayPanel, "width 100%, height 20%, cell 0 1, center,spanx");
add(levelInfoPanel, "width 100%, height 15%, cell 0 2, center, spanx");
}
public PCellEditor(boolean _useConFont, DictCore _core) {
core = _core;
useConFont = _useConFont;
double preSize = core.getPropertiesManager().getFontSize();
Font defFont = useConFont ? core.getPropertiesManager().getFontCon()
: core.getPropertiesManager().getFontLocal();
double fontSize = useConFont ?
preSize :
core.getOptionsManager().getMenuFontSize();
myFont = PGTUtil.addFontAttribute(TextAttribute.SIZE, (float)fontSize, defFont);
final JTextField setupText = (JTextField) component;
setupRightClickMenu(setupText);
setupText.setBorder(BorderFactory.createBevelBorder(1));
this.setupTextFieldListener(setupText);
}
public SingleEntryDialog(Component parent, String entryLabel,
String buttonLabel, ActionListener buttonListener)
{
super();
entry = new JTextField(entryLabel);
entry.setForeground(Color.WHITE);
entry.setBackground(Color.DARK_GRAY);
entry.setBorder(new LineBorder(Color.GRAY));
entry.setCaretColor(Color.WHITE);
entry.setFont(new Font("Tahoma", Font.PLAIN, 22));
entry.addFocusListener(new TextFieldFocusListener(entry));
contentPanel.add(entry, "cell 0 1, grow, gapx 2 2");
JButton btnConfirm = new ModernButton(buttonLabel);
btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18));
btnConfirm.addActionListener(buttonListener);
contentPanel.add(btnConfirm, "cell 0 3, alignx center");
JLabel spacer = new JLabel(" ");
contentPanel.add(spacer, "cell 0 4");
finalize(parent);
btnConfirm.requestFocus();
}
private JTextField getStatusBar() {
JTextField statusBar = new JTextField();
statusBar.setEditable(false);
statusBar.setBackground(null);
statusBar.setBorder(null);
return statusBar;
}
public PanInterval(){
setBackground(UI.BUTTON_PURPLE);
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
Component horizontalStrut = Box.createHorizontalStrut(8);
add(horizontalStrut);
JLabel lbljigtag = new JLabel("Interval = ");
add(lbljigtag);
lbljigtag.setFont(new Font("Dialog", Font.BOLD, 14));
Component horizontalStrut_3 = Box.createHorizontalStrut(8);
add(horizontalStrut_3);
txtinterval = new JTextField("1234",6);
txtinterval.setBackground(UI.BUTTON_YELLOW);
add(txtinterval);
txtinterval.setFont(new Font("DejaVu Sans Mono", Font.PLAIN, 18));
txtinterval.setBorder(null);
Component horizontalStrut_1 = Box.createHorizontalStrut(8);
add(horizontalStrut_1);
txtinterval.addKeyListener(new KeyAdapter(){
public void keyReleased(KeyEvent e){
GE.ge.editor_generator.setInterval(txtinterval.getText());}});
}
private void setup() {
setLayout(new MigLayout("ins 5, center"));
Border loweredbevel = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
Font f = new Font(new JLabel().getFont().getFontName(), Font.BOLD, new JLabel().getFont().getSize() + 2);
ImageIcon searchicon = new ImageIcon(
getClass().getClassLoader().getResource("resources/searchicon20.png"));
itemDetailPanel = new ItemDetailPanel();
itemInputField = new JTextField();
itemLabel = new JLabel("ITEM:");
searchButton = new JButton();
itemDisplayPanel = new ItemListPanel();
itemInputField.setBorder(loweredbevel);
itemInputField.setBackground(new Color(51, 51, 51));
itemLabel.setForeground(Color.white);
itemLabel.setFont(new Font(itemLabel.getFont().getFontName(), Font.BOLD, itemLabel.getFont().getSize()));
searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/searchiconsquare3.png")));
searchButton.setBorderPainted(false);
searchButton.setFocusPainted(false);
searchButton.setContentAreaFilled(false);
itemDisplayPanel.setRolloverListener(this);
add(itemLabel, "cell 0 0, gap 0, align left");
add(searchButton, "cell 2 0,align right ");
add(itemInputField, "width 60%, cell 1 0,align left,");
add(itemDisplayPanel, "width 100%, height 30%, cell 0 1, center,spanx");
//30% height on itemDetailPanel leaves ample room at the bottom
//for a future offer-watcher.
add(itemDetailPanel, "width 100%, height 50%, cell 0 2, center, spanx");
}
public PanMetagonTags(){
setBackground(UI.BUTTON_RED);
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
Component horizontalStrut = Box.createHorizontalStrut(4);
add(horizontalStrut);
JLabel lbljigtag = new JLabel("MetagonTags=");
add(lbljigtag);
lbljigtag.setFont(new Font("Dialog", Font.BOLD, 14));
Component horizontalStrut_3 = Box.createHorizontalStrut(4);
add(horizontalStrut_3);
txtmetagontags = new JTextField("foo",20);
txtmetagontags.setBackground(UI.BUTTON_YELLOW);
add(txtmetagontags);
txtmetagontags.setFont(new Font("DejaVu Sans Mono", Font.PLAIN, 18));
txtmetagontags.setBorder(null);
txtmetagontags.addKeyListener(new KeyAdapter(){
public void keyReleased(KeyEvent e){
GE.ge.editor_metagon.setMetagonTags(txtmetagontags.getText());}});
Component horizontalStrut_1 = Box.createHorizontalStrut(4);
add(horizontalStrut_1);
}
public JDateChooser(boolean allowEmptyDates) {
super(new DefaultDatePickerSettings(allowEmptyDates));
JTextField jTextField = getComponentDateTextField();
jTextField.setEditable(false);
jTextField.setBorder(null);
jTextField.setOpaque(false);
jTextField.setHorizontalAlignment(JTextField.CENTER);
JButton jButton = getComponentToggleCalendarButton();
jButton.setIcon(Images.EDIT_DATE.getIcon());
jButton.setText("");
}
/** Create a test field. */
private JTextField createTextField(int width) {
JTextField f = new JTextField(width);
f.setEditable(false);
f.setBorder(null);
return f;
}
public RecipeStepPanel(String title, ChangeListener changelistener) {
this.changeListener = changelistener;
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(300, 0));
// header
Box headerBox = Box.createHorizontalBox();
// add borders
Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
MatteBorder lineBorder = new MatteBorder(0, 0, 2, 0, Color.DARK_GRAY);
CompoundBorder border = new CompoundBorder(lineBorder, margin);
headerBox.setBorder(border);
JTextField contentTextField = new JTextField();
contentTextField.setBorder(null);
contentTextField.setBackground(new Color(0, 0, 0, 0));
contentTextField.setText(title);
headerBox.add(contentTextField);
this.add(headerBox, BorderLayout.NORTH);
// body
operationsLine = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridheight = GridBagConstraints.REMAINDER;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
JPanel dummyPanel = new JPanel();
operationsLine.add(dummyPanel, gbc);
this.addContraints = new GridBagConstraints();
this.addContraints.gridwidth = GridBagConstraints.REMAINDER;
this.addContraints.weightx = 1;
this.addContraints.fill = GridBagConstraints.HORIZONTAL;
JScrollPane scrollPane = new JScrollPane(operationsLine);
scrollPane.setBorder(new MatteBorder(0, 2, 0, 0, Color.DARK_GRAY));
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
this.add(scrollPane, BorderLayout.CENTER);
}
private void createTable() {
// create the table
model = new MyTableModel();
table = new JXTable(model) {
private Map<Integer, ComboBoxEditor> editors = new HashMap<Integer, ComboBoxEditor>();
public boolean getScrollableTracksViewportHeight() {
return getPreferredSize().height < getParent().getHeight();
}
public void changeSelection(int rowIndex, int columnIndex,
boolean toggle, boolean extend) {
if (!dndRecognizer.isDragged()) {
super.changeSelection(rowIndex, columnIndex, toggle, extend);
}
}
public TableCellEditor getCellEditor(int row, int column) {
if (column != 6) {
return super.getCellEditor(row, column);
}
ComboBoxEditor editor = editors.get(row);
if (editor == null) {
editor = new ComboBoxEditor(new String[]{"", GROUP_BY, SUM, AVG, MIN, MAX, COUNT});
editors.put(row, editor);
}
return editor;
}
};
tableRowHeader = TableUtil.setRowHeader(table);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableColumn col = table.getColumnModel().getColumn(3);
// col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
col.setCellRenderer(table.getDefaultRenderer(Boolean.class));
col.setCellEditor(table.getDefaultEditor(Boolean.class));
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
// no border
JTextField tf = new JTextField();
tf.setBorder(BorderFactory.createEmptyBorder());
table.setDefaultEditor(Object.class, new DefaultCellEditor(tf));
col = table.getColumnModel().getColumn(4);
// col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
JComboBox sortCombo = new JComboBox(new String[]{"", ASC, DESC});
sortCombo.setBorder(BorderFactory.createEmptyBorder());
col.setCellEditor(new ComboBoxEditor(sortCombo));
col = table.getColumnModel().getColumn(5);
sortOrderCombo = new JComboBox();
sortOrderCombo.setBorder(BorderFactory.createEmptyBorder());
col.setCellEditor(new ComboBoxEditor(sortOrderCombo));
col = table.getColumnModel().getColumn(6);
table.setSortable(false);
table.setColumnControlVisible(true);
table.getTableHeader().setReorderingAllowed(false);
table.setHorizontalScrollEnabled(true);
// highlight table
table.setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR));
table.getTableHeader().setReorderingAllowed(false);
table.setRolloverEnabled(true);
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));
}
private JPanel createHelperPanel() {
JPanel ret = new JPanel(new GridBagLayout());
GridBagConstraints labelConstraints = new GridBagConstraints();
labelConstraints.insets = new Insets(0, 0, 10, 0);
labelConstraints.gridx = 0;
labelConstraints.fill = GridBagConstraints.HORIZONTAL;
labelConstraints.gridwidth = 2;
ret.add(new JLabel("Available sample fields (click any button to copy the field to clipboard):"), labelConstraints);
GridBagConstraints buttonConstraints = new GridBagConstraints();
buttonConstraints.insets = new Insets(4, 0, 0, 0);
buttonConstraints.gridx = 0;
buttonConstraints.fill = GridBagConstraints.HORIZONTAL;
GridBagConstraints detailConstraints = new GridBagConstraints();
detailConstraints.insets = new Insets(4, 10, 0, 0);
detailConstraints.weightx = 1.0;
detailConstraints.fill = GridBagConstraints.HORIZONTAL;
detailConstraints.gridx = 1;
detailConstraints.anchor = GridBagConstraints.WEST;
int line = 1;
CopyAction copyAction = new CopyAction();
for (int i = 0; i < fields.length / 2; i++) {
JButton fieldButton = new JButton(fields[2 * i]);
fieldButton.addActionListener(copyAction);
JTextField fieldDescription = new JTextField(fields[2 * i + 1]);
fieldDescription.setEditable(false);
fieldDescription.setBorder(null);
fieldDescription.setOpaque(false);
GuiBuilderHelper.strechItemToComponent(fieldDescription, fieldButton);
buttonConstraints.gridy = line;
detailConstraints.gridy = line;
ret.add(fieldButton, buttonConstraints);
ret.add(fieldDescription, detailConstraints);
line++;
}
return ret;
}
public void init(String unitName, String unitType, String unitDescription) {
setOpaque(false);
setLayout(new BorderLayout(10, 20));
// this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373
JPanel mainPanel = new JPanel(new FlowLayout());// new BorderLayout());
mainPanel.setOpaque(false);
mainPanel.setBackground(new Color(0, 0, 0, 128));
// setMinimumSize()
this.add(mainPanel, BorderLayout.NORTH);
JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
westPanel.setOpaque(false);
westPanel.setBackground(new Color(0, 0, 0, 128));
// setMinimumSize()
this.add(westPanel, BorderLayout.WEST);
JPanel eastPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
eastPanel.setOpaque(false);
eastPanel.setBackground(new Color(0, 0, 0, 128));
// setMinimumSize()
this.add(eastPanel, BorderLayout.EAST);
// Creating the text Input
JTextField tf1 = new JTextField("", 15);
tf1.setHorizontalAlignment(JTextField.CENTER);
tf1.setOpaque(false);
tf1.setFocusable(false);
tf1.setBackground(new Color(92, 83, 55, 128));
tf1.setColumns(20);
Border border = BorderFactory.createLineBorder(Color.gray, 2);
tf1.setBorder(border);
tf1.setText(unitName);
tf1.setForeground(Color.BLACK);
tf1.setFont(new Font("Arial", Font.BOLD, 14));
mainPanel.add(tf1);
JTextArea ta = new JTextArea();
String type = "TYPE: ";
String description = "DESCRIPTION: ";
ta.setLineWrap(true);
ta.setFocusable(false);
ta.setWrapStyleWord(true);
ta.setText(type + "\n");
ta.append(unitType + "\n\n");
ta.append(description + "\n");
ta.append(unitDescription);
ta.setCaretPosition(0);
ta.setEditable(false);
ta.setForeground(Color.black);
ta.setFont(new Font("Dialog", Font.PLAIN, 14));
ta.setOpaque(false);
ta.setBackground(new Color(92, 83, 55, 128));
CustomScroll scr = new CustomScroll(ta);
scr.setSize(PopUpUnitMenu.D_WIDTH - 50 , PopUpUnitMenu.D_HEIGHT);
add(scr, BorderLayout.CENTER);
JPanel southPanel = new JPanel();
add(southPanel, BorderLayout.SOUTH);
southPanel.setOpaque(false);
southPanel.setBackground(new Color(0, 0, 0, 128));
setVisible(true);
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
jtf = (JTextField) c;
JTextField editor = jtf;
UIDefaults uidefaults = XToolkit.getUIDefaults();
String prefix = getPropertyPrefix();
Font f = editor.getFont();
if ((f == null) || (f instanceof UIResource)) {
editor.setFont(uidefaults.getFont(prefix + ".font"));
}
Color bg = editor.getBackground();
if ((bg == null) || (bg instanceof UIResource)) {
editor.setBackground(uidefaults.getColor(prefix + ".background"));
}
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
}
Color color = editor.getCaretColor();
if ((color == null) || (color instanceof UIResource)) {
editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
}
Color s = editor.getSelectionColor();
if ((s == null) || (s instanceof UIResource)) {
editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
}
Color sfg = editor.getSelectedTextColor();
if ((sfg == null) || (sfg instanceof UIResource)) {
editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
}
Color dfg = editor.getDisabledTextColor();
if ((dfg == null) || (dfg instanceof UIResource)) {
editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
}
Border b = editor.getBorder();
if ((b == null) || (b instanceof UIResource)) {
editor.setBorder(uidefaults.getBorder(prefix + ".border"));
}
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
}
}
public AccountSeparatorTableCell(final AccountManagerDialog accountManagerDialog, final ActionListener actionListener, final JTable jTable, final SeparatorList<OwnerType> separatorList) {
super(jTable, separatorList);
this.accountManagerDialog = accountManagerDialog;
defaultColor = jPanel.getBackground();
ListenerClass listener = new ListenerClass();
jSeparatorLabel = new JLabel();
jSeparatorLabel.setBackground(jTable.getBackground());
jSeparatorLabel.setOpaque(true);
jSeparatorLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, jTable.getGridColor()));
jAccountType = new JLabel();
jEdit = new JButton(DialoguesAccount.get().edit());
jEdit.setOpaque(false);
jEdit.setActionCommand(AccountCellAction.EDIT.name());
jEdit.addActionListener(actionListener);
jMigrate = new JButton(DialoguesAccount.get().migrate());
jMigrate.setOpaque(false);
jMigrate.setActionCommand(AccountCellAction.MIGRATE.name());
jMigrate.addActionListener(actionListener);
jDelete = new JButton(DialoguesAccount.get().delete());
jDelete.setOpaque(false);
jDelete.setActionCommand(AccountCellAction.DELETE.name());
jDelete.addActionListener(actionListener);
jAccountName = new JTextField();
jAccountName.addFocusListener(listener);
jAccountName.setBorder(null);
jAccountName.setOpaque(false);
jAccountName.setActionCommand(AccountCellAction.ACCOUNT_NAME.name());
jAccountName.addActionListener(listener);
jInvalidLabel = new JLabel(DialoguesAccount.get().accountInvalid());
jExpiredLabel = new JLabel(DialoguesAccount.get().accountExpired());
jMigratedLabel = new JLabel(DialoguesAccount.get().accountMigrated());
jCanMigrateLabel = new JLabel(DialoguesAccount.get().accountCanMigrate());
jSpaceLabel = new JLabel();
layout.setHorizontalGroup(
layout.createParallelGroup()
.addComponent(jSeparatorLabel, 0, 0, Integer.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jExpand)
.addGap(1)
.addComponent(jEdit, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
.addComponent(jMigrate, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
.addComponent(jDelete, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
.addGap(5)
.addComponent(jAccountType)
.addGap(5)
.addComponent(jAccountName, 20, 20, Integer.MAX_VALUE)
.addGap(10)
.addComponent(jExpiredLabel)
.addComponent(jInvalidLabel)
.addComponent(jMigratedLabel)
.addComponent(jCanMigrateLabel)
.addComponent(jSpaceLabel, 20, 20, Integer.MAX_VALUE)
)
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(jSeparatorLabel, jTable.getRowHeight(), jTable.getRowHeight(), jTable.getRowHeight())
.addGap(1)
.addGroup(layout.createParallelGroup()
.addComponent(jExpand, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jAccountType, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jEdit, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jMigrate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jDelete, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jAccountName, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jInvalidLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jExpiredLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jMigratedLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jCanMigrateLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jSpaceLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
)
.addGap(2)
);
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
jtf = (JTextField) c;
JTextField editor = jtf;
UIDefaults uidefaults = XToolkit.getUIDefaults();
String prefix = getPropertyPrefix();
Font f = editor.getFont();
if ((f == null) || (f instanceof UIResource)) {
editor.setFont(uidefaults.getFont(prefix + ".font"));
}
Color bg = editor.getBackground();
if ((bg == null) || (bg instanceof UIResource)) {
editor.setBackground(uidefaults.getColor(prefix + ".background"));
}
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
}
Color color = editor.getCaretColor();
if ((color == null) || (color instanceof UIResource)) {
editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
}
Color s = editor.getSelectionColor();
if ((s == null) || (s instanceof UIResource)) {
editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
}
Color sfg = editor.getSelectedTextColor();
if ((sfg == null) || (sfg instanceof UIResource)) {
editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
}
Color dfg = editor.getDisabledTextColor();
if ((dfg == null) || (dfg instanceof UIResource)) {
editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
}
Border b = editor.getBorder();
if ((b == null) || (b instanceof UIResource)) {
editor.setBorder(uidefaults.getBorder(prefix + ".border"));
}
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
}
}
private JPanel createPathsPanel()
{
final JPanel pnl = new JPanel();
// i18n[GeneralPreferencesPanel.paths=SQuirreL paths]
pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("GeneralPreferencesPanel.paths")));
pnl.setLayout(new GridBagLayout());
final GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(2, 4, 2, 4);
gbc.anchor = GridBagConstraints.NORTHWEST;
ApplicationFiles appFiles = new ApplicationFiles();
String userDir = appFiles.getUserSettingsDirectory().getPath();
String homeDir = appFiles.getSquirrelHomeDir().getPath();
gbc.gridx = 0;
gbc.gridy = 0;
// i18n[GeneralPreferencesPanel.squirrelHomePath=Home directory: -home {0}]
JTextField homePathField = new JTextField(s_stringMgr.getString("GeneralPreferencesPanel.squirrelHomePath", homeDir));
homePathField.setEditable(false);
homePathField.setBackground(pnl.getBackground());
homePathField.setBorder(null);
pnl.add(homePathField, gbc);
++gbc.gridy;
// i18n[GeneralPreferencesPanel.squirrelUserPath=User directory: -userdir {0}]
JTextField userPathField = new JTextField(s_stringMgr.getString("GeneralPreferencesPanel.squirrelUserPath", userDir));
userPathField.setEditable(false);
userPathField.setBackground(pnl.getBackground());
userPathField.setBorder(null);
pnl.add(userPathField, gbc);
gbc.weightx = 1.0;
gbc.gridy = 0;
++gbc.gridx;
pnl.add(new JPanel(), gbc);
++gbc.gridy;
pnl.add(new JPanel(), gbc);
return pnl;
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
jtf = (JTextField) c;
JTextField editor = jtf;
UIDefaults uidefaults = XToolkit.getUIDefaults();
String prefix = getPropertyPrefix();
Font f = editor.getFont();
if ((f == null) || (f instanceof UIResource)) {
editor.setFont(uidefaults.getFont(prefix + ".font"));
}
Color bg = editor.getBackground();
if ((bg == null) || (bg instanceof UIResource)) {
editor.setBackground(uidefaults.getColor(prefix + ".background"));
}
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
}
Color color = editor.getCaretColor();
if ((color == null) || (color instanceof UIResource)) {
editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
}
Color s = editor.getSelectionColor();
if ((s == null) || (s instanceof UIResource)) {
editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
}
Color sfg = editor.getSelectedTextColor();
if ((sfg == null) || (sfg instanceof UIResource)) {
editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
}
Color dfg = editor.getDisabledTextColor();
if ((dfg == null) || (dfg instanceof UIResource)) {
editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
}
Border b = editor.getBorder();
if ((b == null) || (b instanceof UIResource)) {
editor.setBorder(uidefaults.getBorder(prefix + ".border"));
}
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
}
}
/**
* Creates the internal editor component. Override this to provide
* a custom implementation.
*
* @return a new editor component
* @since 1.6
*/
protected JTextField createEditorComponent() {
JTextField editor = new BorderlessTextField("",9);
editor.setBorder(null);
return editor;
}
/**
* Creates the internal editor component. Override this to provide
* a custom implementation.
*
* @return a new editor component
* @since 1.6
*/
protected JTextField createEditorComponent() {
JTextField editor = new BorderlessTextField("",9);
editor.setBorder(null);
return editor;
}