public void save() { for (String key : fields.keySet()) { JComponent comp = fields.get(key); if (comp instanceof JTextField) { JTextField c = (JTextField) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } else if (comp instanceof JTextArea) { JTextArea c = (JTextArea) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } } sketch.saveConfig(); }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
private void setBorder(boolean isEnabled) { JTextField txfTmp = new JTextField(); if (isEnabled) setBorder(txfTmp.getBorder()); else { String strStyle = getAttribute(DISABLE); if (strStyle != null && strStyle.equals(m_arrStrDisAbl[1])) { setBorder(null); setBackground(Util.getBgColor()); } else { setBorder(txfTmp.getBorder()); setBackground(Global.NPCOLOR); } } }
public void paint(Graphics g) { super.paint(g); if (!isEditing) return; Dimension psize = getPreferredSize(); if (isFocused) g.setColor(Color.yellow); else g.setColor(Color.green); g.drawLine(0, 0, psize.width, 0); g.drawLine(0, 0, 0, psize.height); g.drawLine(0, psize.height - 1, psize.width - 1, psize.height - 1); g.drawLine(psize.width - 1, 0, psize.width - 1, psize.height - 1); }
public void reshape(int x, int y, int w, int h) { if (inEditMode) { defLoc.x = x; defLoc.y = y; defDim.width = w; defDim.height = h; } curLoc.x = x; curLoc.y = y; curDim.width = w; curDim.height = h; if (!inEditMode) { if ((h != nHeight) || (h < rHeight)) { adjustFont(w, h); } } super.reshape(x, y, w, h); }
/** The constructor sets up the listeners to update values appropriately. */ Row() { hoursTF.addCaretListener(ReviewDialog.this); hoursTF.setHorizontalAlignment(SwingConstants.RIGHT); }