public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof LGString) { lgs = (LGString) value; switch (lgs.isTranslated()) { case LGString.TRANSLATED: cell.setBackground(Color.white); break; case LGString.NEWLY_TRANSLATED: cell.setBackground(Color.orange); break; case LGString.NOT_IN_BASE_FILE: cell.setBackground(Color.red); break; case LGString.NOT_TRANSLATED: cell.setBackground(Color.yellow); break; default: cell.setBackground(Color.white); } } else { cell.setFocusable(false); cell.setBackground(Color.lightGray); } return cell; }
@Override protected void createPanel() { evjpanel = new EuclidianViewJPanelD(this); canvas = (Component) ((RendererD) renderer).canvas; getJPanel().setLayout(new BorderLayout()); getJPanel().add(BorderLayout.CENTER, canvas); // register Listener ((EuclidianControllerListeners) getEuclidianController()).addListenersTo(canvas); canvas.setFocusable(true); }
/** Prepare the window that shall show the openGL content. */ private void initWindow() { IllarionLookAndFeel.setupLookAndFeel(); // create canvas that shall show the openGL content display = Graphics.getInstance().getRenderDisplay(); display.getRenderArea().setBackground(Color.red); configChanged(IllaClient.getCfg(), CFG_RESOLUTION); final Component displayParent = display.getRenderArea(); displayParent.setBackground(Color.green); displayParent.setVisible(true); // set up the window settings displayFrame = new Frame(); displayFrame.setLayout(new BorderLayout(0, 0)); displayFrame.setTitle(IllaClient.getVersionText()); displayFrame.setBackground(Color.black); setIcon(displayFrame); displayFrame.addWindowListener(new ClientWindowListener()); displayFrame.setResizable(false); displayFrame.setFocusable(false); displayFrame.setFocusableWindowState(true); displayFrame.setFocusTraversalKeysEnabled(false); displayParent.setFocusable(true); displayParent.setFocusTraversalKeysEnabled(false); // add the canvas to the window and make the canvas the openGL render // target. displayFrame.add(displayParent, BorderLayout.CENTER); displayFrame.pack(); displayFrame.setLocationRelativeTo(null); displayFrame.setVisible(true); displayParent.requestFocusInWindow(); final RenderDisplay usedDisplay = display; Graphics.getInstance() .getRenderManager() .addTask( new RenderTask() { @Override public boolean render(final int delta) { usedDisplay.startRendering(); return false; } }); }
/** * Initializes the creation of the window GUI by adding the instruction label, the text field that * the user will enter text into, and the buttons that will be used to confirm or cancel the input */ private void initialize() { setTitle("New Object Definition"); setDefaultCloseOperation(HIDE_ON_CLOSE); JPanel newShell = new JPanel(); newShell.setLayout(new BoxLayout(newShell, BoxLayout.Y_AXIS)); newShell.add(createInfoLabel()); Component input = createUserInput(); newShell.add(input); newShell.add(createButtons(input)); add(newShell); setVisible(true); pack(); setLocationRelativeTo(null); input.setFocusable(true); }
private void addAction(Action act) { if (m_appuser.hasPermission((String) act.getValue(AppUserView.ACTION_TASKNAME))) { // add the action Component c = taskGroup.add(act); c.setFocusable(false); // c.setRequestFocusEnabled(false); taskGroup.setVisible(true); if (m_actionfirst == null) { m_actionfirst = act; } } }
public void actionPerformed(ActionEvent e) { text.setBackground(Color.WHITE); // if (e.getSource() == butParent) { // ParentAction parentAction = new ParentAction(); // parentAction.actionPerformed(new ActionEvent(e, 0, "")); // return; // } // if (e.getSource() == butNF) { // NewFolderAction nfAction = new NewFolderAction(); // newFolderAction.actionPerformed(new ActionEvent(e, 0, "")); // return; // } if (e.getSource() == cBox) { int i = cBox.getSelectedIndex(); driver.allFiles = (i == 1); // fullNodeName = (new File(fullNodeName)).getParent(); // driver.properties // .put("allFiles", Boolean.toString(driver.allFiles)); // driver.propertiesChanged = true; // panel.remove(listView); showList(); // selComp = cBox; cBox.requestFocusInWindow(); cBox.setBackground(vLightBlue); // Component c = cBox.getComponent(1); // c.setBackground(vLightBlue); selComp.setFocusable(true); cBox.setEnabled(true); } // repaint(); }
@Override public Component add(Component comp) { comp.setFocusable(false); return super.add(comp); }
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (selComp == text || selComp == text2) { selComp.setBackground(Color.WHITE); ((JTextField) selComp).setEditable(false); ((JTextField) selComp).getCaret().setVisible(false); } text2.setBackground(Color.WHITE); // list.setSelectedIndex(-1); cBox.repaint(); // if (saveAs) // text2.setBackground(Color.WHITE); if (selComp == cBox) cBox.setRequestFocusEnabled(false); if (selComp instanceof MyButton) { ((MyButton) selComp).setSelected(false); } // selComp.setRequestFocusEnabled(false); selComp.setFocusable(false); // list.setSelectedIndex(-1); if (!shift) selComp = (JComponent) mtp.getComponentAfter(dialog, selComp); else selComp = (JComponent) mtp.getComponentBefore(dialog, selComp); if (selComp == butCopy && !saveAs) if (!shift) selComp = (JComponent) mtp.getComponentAfter(dialog, selComp); else selComp = (JComponent) mtp.getComponentBefore(dialog, selComp); if (selComp == text || selComp == text2) { selComp.setBackground(vLightBlue); ((JTextField) selComp).getCaret().setVisible(true); ((JTextField) selComp).setEditable(true); } if (selComp == null) { selComp = list; } else if (selComp instanceof MyButton) ((MyButton) selComp).setSelected(true); if (selComp instanceof MyComboBox) { cBox.setBackground(vLightBlue); } selComp.setFocusable(true); selComp.requestFocusInWindow(); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { shift = true; } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { // if (selComp instanceof JList || selComp == text || selComp == // text2) { enterAction.actionPerformed(new ActionEvent(e, 0, "")); // } } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { // if (selComp instanceof JList) { cancelAction.actionPerformed(new ActionEvent(e, 0, "")); // } } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { if (selComp instanceof JList) { deleteAction.actionPerformed(new ActionEvent(e, 0, "")); } } else if (selComp == cBox && ((e.getKeyCode() == KeyEvent.VK_UP) && driver.allFiles || (e.getKeyCode() == KeyEvent.VK_DOWN) && !driver.allFiles)) { driver.allFiles = !driver.allFiles; cBox.setSelectedIndex(driver.allFiles ? 1 : 0); return; } // else if (selComp == text || selComp == text2) { // selComp = (Component) e.getSource(); // } // repaint(); // String u = list.getSelectedValue(); // force selection // list.setSelectedValue(u, false); paintList(); list.repaint(); repaint(); }
public void mouseClicked(MouseEvent e) { list.setSelectedIndex(-1); list.setRequestFocusEnabled(false); // changedField = null; if (selComp == text || selComp == text2) { selComp.setBackground(Color.WHITE); ((JTextField) selComp).setEditable(false); ((JTextField) selComp).getCaret().setVisible(false); } text2.setBackground(Color.WHITE); // cBox.repaint(); if (selComp instanceof MyButton) { ((MyButton) selComp).setSelected(false); ((MyButton) selComp).setFocusable(false); } selComp = (Component) e.getSource(); if (selComp == text || selComp == text2) { ((JTextField) selComp).setRequestFocusEnabled(true); selComp.setBackground(vLightBlue); ((JTextField) selComp).getCaret().setVisible(true); ((JTextField) selComp).setEditable(true); // ((JTextField) selComp).requestFocusInWindow(); } if (e.getSource() instanceof JList) { selComp = list; int rowNo = list.locationToIndex(e.getPoint()); if (rowNo == -1) return; list.setRequestFocusEnabled(true); list.setSelectedIndex(rowNo); text.setBackground(Color.WHITE); // text2.setBackground(textBackground); // http://stackoverflow.com/questions/16392212/unable-to-type-or-delete-text-in-jtextfield // http://stackoverflow.com/questions/13415150/java-swing-form-and-cannot-type-text-in-newly-added-jtextfield // (this says don't use keylistener!) // http://stackoverflow.com/questions/22642401/jtextfield-and-keylistener-java-swing?rq=1 // textField.getDocument().addDocumentListener(...); // new code // text2.requestFocusInWindow(); // text2.setBackground(vLightBlue); // text2.getCaret().setVisible(true); // String fn = listHead + File.separator + nodeNames[rowNo]; if (e.getClickCount() == 1) { mLoc = e.getLocationOnScreen(); if (nodeNames[rowNo].equals("(empty folder")) return; } else if (e.getClickCount() == 2) { Point p = e.getLocationOnScreen(); if (mLoc != null && Math.abs(p.x - mLoc.x) < 6 && Math.abs(p.y - mLoc.y) < 6) { enterAction.actionPerformed(new ActionEvent(e, 0, "")); } } } if (selComp == cBox) { selComp.setFocusable(true); cBox.requestFocusInWindow(); cBox.setEnabled(true); cBox.setBackground(vLightBlue); } if (selComp instanceof MyButton) { ((MyButton) selComp).setSelected(false); } paintList(); list.repaint(); }