@Override public int getBaseline() { FontMetrics fm = b.getFontMetrics(b.getFont()); int border = (b.getPreferredSize().height - fm.getHeight()) / 2; int bestGuess = border + fm.getAscent(); if (PlatformUtils.isMac()) bestGuess -= 1; return bestGuess; }
public void p(Object obj) throws Exception { JComboBox combo = (JComboBox) obj; combo.setFont(combo.getFont().deriveFont(Font.PLAIN)); combo.setBackground(Color.WHITE); if (color == null) color = DEFAULT_COLOR; if (font == null) font = DEFAULT_FONT; combo.setRenderer(new ListRenderer1(icon, color, font)); }
/** * This method is invoked when the user clicks away from the target selection dropdown menu. It * behaves as more of a feature than a necessary part of the system; canceling the selection * functions like a reset button for the current item. It removes the lock from the previously * selected target, allowing systems to be selected in other dropdowns which are not compatible * with the current system (thus leading to its replacement). */ @Override public void popupMenuCanceled(PopupMenuEvent e) { JComboBox changedSystem = (JComboBox) e.getSource(); String current = targets.get(changedSystem); // Get the category of the changed system if (current == null) return; userPicks.remove(current); // Clear the lock on this system changedSystem.setFont(changedSystem.getFont().deriveFont(Font.PLAIN)); // Unbold the box populateTargets(); // Re-populate our combo boxes to reflect that they no longer need to // fill this system's dependencies }
public SignDialog(JDialog parent) { super(parent, "Sign Message", Dialog.ModalityType.DOCUMENT_MODAL); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); String[] keyLabels = new String[BTCLoader.keys.size()]; int index = 0; for (ECKey key : BTCLoader.keys) { keyLabels[index++] = key.getLabel(); } nameField = new JComboBox<Object>(keyLabels); nameField.setPreferredSize(new Dimension(200, 25)); JPanel namePane = new JPanel(); namePane.add(new JLabel("Key ", JLabel.RIGHT)); namePane.add(nameField); messageField = new JTextArea(10, 70); messageField.setLineWrap(true); messageField.setWrapStyleWord(true); messageField.setFont(nameField.getFont()); scrollPane = new JScrollPane(messageField); JPanel messagePane = new JPanel(); messagePane.add(new JLabel("Message ", JLabel.RIGHT)); messagePane.add(scrollPane); signatureField = new JTextField("", 70); signatureField.setEditable(false); JPanel signaturePane = new JPanel(); signaturePane.add(new JLabel("Signature ", JLabel.RIGHT)); signaturePane.add(signatureField); JPanel buttonPane = new ButtonPane( this, 10, new String[] {"Sign", "sign"}, new String[] {"Copy", "copy"}, new String[] {"Done", "done"}); JPanel contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.setOpaque(true); contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); contentPane.add(namePane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(messagePane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(signaturePane); contentPane.add(Box.createVerticalStrut(15)); contentPane.add(buttonPane); setContentPane(contentPane); }
private static int getComboBoxBaseline(JComboBox combobox, int height) { Insets insets = combobox.getInsets(); int y = insets.top; height -= (insets.top + insets.bottom); if (combobox.isEditable()) { ComboBoxEditor editor = combobox.getEditor(); if (editor != null && (editor.getEditorComponent() instanceof JTextField)) { JTextField tf = (JTextField) editor.getEditorComponent(); return y + getSingleLineTextBaseline(tf, height); } } // Use the renderer to calculate baseline if (isMetal()) { if (isOceanTheme()) { y += 2; height -= 4; } } else if (isWindows()) { // This doesn't guarantee an XP style will be active, // but we don't offer public API to detect if XP is active. String osVersion = System.getProperty("os.version"); if (osVersion != null) { Float version = Float.valueOf(osVersion); if (version.floatValue() > 4.0) { y += 2; height -= 4; } } } ListCellRenderer renderer = combobox.getRenderer(); if (renderer instanceof JLabel) { int baseline = y + getLabelBaseline((JLabel) renderer, height); if (isAqua()) { return baseline - 1; } return baseline; } // Renderer isn't a label, use metrics directly. FontMetrics fm = combobox.getFontMetrics(combobox.getFont()); return y + fm.getAscent(); }
private Component rescaleComponent(Component comp) { // if (comp instanceof JButton) { // JButton jb = (JButton) comp; // comp.setBounds((int) (comp.getX() * scalingfactor), (int) (comp.getY() * // scalingfactor), (int) (comp.getWidth() * scalingfactor), (int) (comp.getHeight() * // scalingfactor)); // jb.setFont(new Font("Tahoma", Font.PLAIN, (int) (jb.getFont().getSize() * // scalingfactor))); // } // if (comp instanceof JLabel) { // JLabel jl = (JLabel) comp; // jl.setFont(new Font("Tahoma", Font.PLAIN, (int) (jl.getFont().getSize() * // scalingfactor))); // } if (comp instanceof JComboBox) { JComboBox jl = (JComboBox) comp; jl.setFont(new Font("Tahoma", Font.PLAIN, (int) (jl.getFont().getSize() * scalingfactor))); comp.setBounds( (int) (comp.getX() * scalingfactor), (int) (comp.getY() * scalingfactor), (int) (comp.getWidth() * scalingfactor), (int) (comp.getHeight() * scalingfactor)); } if (comp instanceof JTable) { JTable jT = (JTable) comp; jT.setFont(new Font("Tahoma", Font.PLAIN, (int) (jT.getFont().getSize() * scalingfactor))); for (int i = 0; i < jT.getColumnModel().getColumnCount(); i++) { // System.err.println("123123123132"); // System.out.println("widtbefore="+jT.getColumnModel().getColumn(i).getPreferredWidth()+" // AFTER="+(int) (jT.getColumnModel().getColumn(i).getPreferredWidth() * scalingfactor)); jT.getColumnModel() .getColumn(i) .setPreferredWidth( (int) (jT.getColumnModel().getColumn(i).getPreferredWidth() * scalingfactor)); jT.getColumnModel() .getColumn(i) .setWidth((int) (jT.getColumnModel().getColumn(i).getWidth() * scalingfactor)); comp.repaint(); comp.revalidate(); } comp.setBounds( (int) (comp.getX() * scalingfactor), (int) (comp.getY() * scalingfactor), (int) (comp.getWidth() * scalingfactor), (int) (comp.getHeight() * scalingfactor)); } if (comp instanceof JViewport) { JViewport jV = (JViewport) comp; for (Component lComp : jV.getComponents()) { // System.err.println("00001111"); // System.err.println(lComp.toString()); rescaleComponent(lComp); } jV.setFont(new Font("Tahoma", Font.PLAIN, (int) (jV.getFont().getSize() * scalingfactor))); comp.setBounds( (int) (comp.getX() * scalingfactor), (int) (comp.getY() * scalingfactor), (int) (comp.getWidth() * scalingfactor), (int) (comp.getHeight() * scalingfactor)); } return comp; }
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); Object s = e.getSource(); if (s == loadFile) { loadFromFile(); return; } if (s == saveFile) { saveToFile(); return; } if (s == bDef || s == bGlobLoc || s == bInit || s == bClean) { if (s == bDef) { if (cfDef == null) cfDef = newCodeFrame( sDef, Messages.getString("EnigmaSettingsFrame.CODE_TITLE_DEFINITIONS")); // $NON-NLS-1$ cfDef.toTop(); } if (s == bGlobLoc) { if (cfDef == null) cfGlobLoc = newCodeFrame( sGlobLoc, Messages.getString( "EnigmaSettingsFrame.CODE_TITLE_GLOBAL_LOCALS")); //$NON-NLS-1$ cfGlobLoc.toTop(); } if (s == bInit) { if (cfInit == null) cfInit = newCodeFrame( sInit, Messages.getString( "EnigmaSettingsFrame.CODE_TITLE_INITIALIZATION")); //$NON-NLS-1$ cfInit.toTop(); } if (s == bClean) { if (cfClean == null) cfClean = newCodeFrame( sClean, Messages.getString("EnigmaSettingsFrame.CODE_TITLE_CLEANUP")); // $NON-NLS-1$ cfClean.toTop(); } return; } String targSys = targets.get(s); if (targSys != null) { if (changing) return; JComboBox changedSystem = (JComboBox) s; TargetSelection changedSelection = (TargetSelection) changedSystem.getSelectedItem(); // Update author and description if (changedSystem.hasFocus()) { tfAuth.setText(changedSelection.auth); taDesc.setText(changedSelection.desc); } // repopulate the boxes userPicks.put(targSys, changedSelection); changedSystem.setFont(changedSystem.getFont().deriveFont(Font.BOLD)); populateTargets(); // now trample the other cancelled selections changing = true; for (Entry<JComboBox, String> systems : targets.entrySet()) if (systems.getKey() != changedSystem && userPicks.get(systems.getValue()) == null) systems.getKey().setSelectedIndex(0); changing = false; } }
public AnnotationSidePanel(final Browser br, final Fab4 f) { super(new BorderLayout(5, 3)); bro = br; fab = f; final PersonalAnnos bu = (PersonalAnnos) Fab4utils.getBe("Personal", br.getRoot().getLayers()); // JPanel icos = new JPanel(new FlowLayout(FlowLayout.CENTER,3,2)); setBorder(new LineBorder(AnnotationSidePanel.publicColor, 2)); JPanel topp = new JPanel(new BorderLayout(4, 1)); annotationPaneLabel = new JComboBox(new String[] {"Public notes", "Private notes"}); annotationPaneLabel.setToolTipText("Choose if public or private"); annotationPaneLabel.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) loadRemoteCombo(); } }); annotationPaneLabel.setFont(annotationPaneLabel.getFont().deriveFont(Font.BOLD)); topp.add(BorderLayout.NORTH, annotationPaneLabel); JPanel south = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1)); final JTextField tt = new JTextField("type search"); tt.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getButton() == java.awt.event.MouseEvent.BUTTON1) tt.selectAll(); } }); tt.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent arg0) { if (arg0.getKeyChar() == '\n') { String txt = ((JTextField) arg0.getSource()).getText(); search(txt); } } }); JButton lb = new JButton(FabIcons.getIcons().ICOLIGHT); lb.setToolTipText("Search in the annotations"); lb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { search(tt.getText()); } }); south.add(tt); south.add(lb); // TODO: do a better search, separate window JComboBox cb = new JComboBox(new String[] {"Date", "Author", "Trust", "Position"}); cb.setToolTipText("Sort notes by:"); cb.setEditable(false); JPanel t = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 1)); t.add(new JLabel("sort")); t.add(cb); topp.add(BorderLayout.SOUTH, t); // int wi = bHideAnno.getPreferredSize().width*3+20; // wi = Math.max(wi,annotationPaneLabel.getPreferredSize().width); int hei = annotationPaneLabel.getPreferredSize().height + /* * bHideAnno.getPreferredSize * ().height */ +10 + tt.getPreferredSize().height; Dimension dim = new Dimension(annotationPaneLabel.getPreferredSize().width, hei); topp.setPreferredSize(dim); topp.setMinimumSize(dim); topp.setMaximumSize(dim); annoUserList = new JList(); annoUserList.setAutoscrolls(true); annoUserList.setBackground(new Color(255, 255, 230)); annoUserList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); bdeleAnno = new JButton("Delete", FabIcons.getIcons().ICODEL); bdeleAnno.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i : annoUserList.getSelectedIndices()) br.eventq(PersonalAnnos.MSG_DELETE, bu.user.get(i)); } }); bdeleAnno.setToolTipText("Delete selected notes"); if (bu != null) { annoUserList.setModel(bu.user); Component[] t1 = new Component[1]; t1[0] = bdeleAnno; bu.addUIElementsToFab4List(annoUserList, t1, cb); } bdeleAnno.setEnabled(false); add(topp, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(annoUserList); add(scrollPane, BorderLayout.CENTER); annoUserList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { Object[] index = annoUserList.getSelectedValues(); if (index.length > 0) bCopy.setEnabled(true); else bCopy.setEnabled(false); nsel.setText("" + index.length); } }); JPanel ppp = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 1)); bCopy = new JButton("Copy ", FabIcons.getIcons().ICOPUB); Font nf = bCopy.getFont(); nf.deriveFont((float) (nf.getSize2D() * 0.8)); bCopy.setFont(nf); bCopy.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { br.eventq(PersonalAnnos.MSG_COPY, ""); } }); bCopy.setToolTipText("Copies the selected notes to the server or local database"); ppp.add(bCopy); bCopy.setEnabled(false); bdeleAnno.setFont(nf); ppp.add(bdeleAnno); ppp.setPreferredSize( new Dimension(ppp.getPreferredSize().width, bdeleAnno.getPreferredSize().height * 2 + 3)); nsel = new JLabel(" "); nsel.setFont(nf); ppp.add(nsel); add(ppp, BorderLayout.SOUTH); }
/** Initializes the user interface */ private void initGui() { Insets insets1 = new Insets(5, 5, 0, 5); Insets insets2 = new Insets(5, 25, 0, 5); Insets insets3 = new Insets(5, 5, 0, 0); Insets insets4 = new Insets(5, 0, 0, 5); Insets insets5 = new Insets(5, 5, 5, 5); Insets insets6 = new Insets(5, 25, 5, 5); Insets insets10 = new Insets(10, 10, 10, 10); JPanel content = new JPanel(new GridBagLayout()); getContentPane().add(content); // ******************************** // ** Route properties panel // ******************************** JPanel routeProps = new JPanel(new GridBagLayout()); routeProps.setBorder(new TitledBorder(new LineBorder(Color.black), "Route Properties")); content.add( routeProps, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets10, 0, 0)); // Auto-completion List<String> strings = new ArrayList<>(); strings.add("Copenhagen"); strings.add("Oslo"); AutoCompleteDecorator.decorate(originTxT, strings, false); AutoCompleteDecorator.decorate(destinationTxT, strings, false); // Column 1 widgets int gridY = 0; nameTxT.setEditable(!readOnlyRoute); nameTxT.getDocument().addDocumentListener(new TextFieldChangeListener(nameTxT)); routeProps.add( new JLabel("Name:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add( fixSize(nameTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); originTxT.setEditable(!readOnlyRoute); originTxT.getDocument().addDocumentListener(new TextFieldChangeListener(originTxT)); routeProps.add( new JLabel("Origin:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add( fixSize(originTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); destinationTxT.setEnabled(!readOnlyRoute); destinationTxT.getDocument().addDocumentListener(new TextFieldChangeListener(destinationTxT)); routeProps.add( new JLabel("Destination:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); routeProps.add( fixSize(destinationTxT, 120), new GridBagConstraints(1, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); distanceTxT.setEditable(false); routeProps.add( new JLabel("Total Distance:"), new GridBagConstraints(0, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); routeProps.add( fixSize(distanceTxT, 120), new GridBagConstraints(1, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); // Column 2 widgets gridY = 0; int h = (int) departurePicker.getPreferredSize().getHeight(); initDatePicker(departurePicker, departureSpinner); routeProps.add( new JLabel("Estimated Time of Departure:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add( fixSize(departurePicker, 120), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add( fixSize(departureSpinner, 60, h), new GridBagConstraints(4, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); initDatePicker(arrivalPicker, arrivalSpinner); routeProps.add( new JLabel("Estimated Time of Arrival:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add( fixSize(arrivalPicker, 120), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add( fixSize(arrivalSpinner, 60, h), new GridBagConstraints(4, gridY++, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); inrouteTxT.setEditable(false); routeProps.add( new JLabel("Estimated Time in-route:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add( fixSize(inrouteTxT, 180), new GridBagConstraints(3, gridY++, 2, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); etaCalculationTime.setEnabled(!readOnlyRoute); etaCalculationTime.addActionListener(this); routeProps.add( new JLabel("Calculate TTG/ETA using:"), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets6, 0, 0)); routeProps.add( fixSize(etaCalculationTime, 180), new GridBagConstraints(3, gridY++, 2, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); allSpeeds.setEnabled(!readOnlyRoute); allSpeedsBtn.setEnabled(!readOnlyRoute); routeProps.add( new JLabel("Speed all legs: "), new GridBagConstraints(2, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); routeProps.add( fixSize(allSpeeds, 60), new GridBagConstraints(3, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets3, 0, 0)); routeProps.add( fixSize(allSpeedsBtn, 60, h), new GridBagConstraints(4, gridY, 1, 1, 0.0, 0.0, WEST, NONE, insets4, 0, 0)); routeProps.add( new JLabel(""), new GridBagConstraints(5, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0)); // ******************************** // ** Route detail panel // ******************************** routeTableModel = createRouteTableModel(); routeDetailTable = new DeltaTable(routeTableModel, DELTA_START_COL_INDEX); routeDetailTable.setTableFont(routeDetailTable.getTableFont().deriveFont(10.0f)); routeDetailTable.setNonEditableBgColor( UIManager.getColor("Table.background").darker().darker()); routeDetailTable.addListSelectionListener(this); // Set the minimum column widths for (int x = 0; x < COL_MIN_WIDTHS.length; x++) { routeDetailTable.getColumn(x).setMinWidth(COL_MIN_WIDTHS[x]); } // Configure lock column routeDetailTable.fixColumnWidth(0, COL_MIN_WIDTHS[0]); routeDetailTable.getColumn(0).setCellRenderer(new LockTableCell.CustomBooleanCellRenderer()); routeDetailTable.getColumn(0).setCellEditor(new LockTableCell.CustomBooleanCellEditor()); // Configure ETA column routeDetailTable.getColumn(7).setCellEditor(new EtaEditor()); // Configure heading column JComboBox<Heading> headingCombo = new JComboBox<>(Heading.values()); headingCombo.setFont(headingCombo.getFont().deriveFont(10.0f)); routeDetailTable.getColumn(10).setCellEditor(new DefaultCellEditor(headingCombo)); JPanel routeTablePanel = new JPanel(new BorderLayout()); routeTablePanel.add(routeDetailTable, BorderLayout.CENTER); routeTablePanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Route Details")); content.add( routeTablePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, NORTHWEST, BOTH, insets10, 0, 0)); // ******************************** // ** Button panel // ******************************** JPanel btnPanel = new JPanel(new GridBagLayout()); content.add( btnPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, insets10, 0, 0)); btnZoomToRoute.addActionListener(this); btnZoomToWp.addActionListener(this); btnDelete.addActionListener(this); btnActivate.addActionListener(this); btnClose.addActionListener(this); cbVisible.addActionListener(this); allSpeedsBtn.addActionListener(this); getRootPane().setDefaultButton(btnClose); btnPanel.add( btnZoomToRoute, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add( btnZoomToWp, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add( btnDelete, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add( btnActivate, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add( cbVisible, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); btnPanel.add(btnClose, new GridBagConstraints(5, 0, 1, 1, 1.0, 0.0, EAST, NONE, insets5, 0, 0)); }
private void createContentPane() { if (contentPane != null) return; contentPane = new JPanel(new BorderLayout()); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (confirm()) { dialog.dispose(); cancel = false; } } }; JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT)); contentPane.add(p, BorderLayout.SOUTH); String s = Modeler.getInternationalText("OKButton"); okButton = new JButton(s != null ? s : "OK"); okButton.addActionListener(okListener); p.add(okButton); s = Modeler.getInternationalText("CancelButton"); JButton button = new JButton(s != null ? s : "Cancel"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); cancel = true; } }); p.add(button); s = Modeler.getInternationalText("Help"); button = new JButton(s != null ? s : "Help"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Modeler.openWithNewInstance( pageCheckBox.getPage().getNavigator().getHomeDirectory() + "tutorial/insertCheckBox.cml"); } }); p.add(button); p = new JPanel(new SpringLayout()); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.add(p, BorderLayout.NORTH); // row 1 s = Modeler.getInternationalText("SelectModelLabel"); p.add(new JLabel(s != null ? s : "Select a model", SwingConstants.LEFT)); modelComboBox = new JComboBox(); if (smallFont == null) smallFont = new Font(modelComboBox.getFont().getFamily(), modelComboBox.getFont().getStyle(), 10); modelComboBox.setFont(smallFont); modelComboBox.setRenderer(new LabelRenderer()); modelComboBox.setPreferredSize(new Dimension(200, 20)); modelComboBox.setToolTipText( "If there are multiple models on the page, select the one this check box will interact with."); p.add(modelComboBox); // row 2 s = Modeler.getInternationalText("SelectActionLabel"); p.add(new JLabel(s != null ? s : "Select an action", SwingConstants.LEFT)); actionComboBox = new JComboBox(); actionComboBox.setFont(smallFont); actionComboBox.setToolTipText("Select the switching action for this check box."); p.add(actionComboBox); // row 3 s = Modeler.getInternationalText("UniqueIdentifier"); p.add(new JLabel(s != null ? s : "Unique identifier", SwingConstants.LEFT)); uidField = new JTextField(); uidField.setToolTipText( "Type in a string to be used as the unique identifier of this check box."); uidField.addActionListener(okListener); p.add(uidField); // row 4 s = Modeler.getInternationalText("TextLabel"); p.add(new JLabel(s != null ? s : "Text", SwingConstants.LEFT)); nameField = new JTextField(); nameField.setToolTipText("Type in the text that will appear on this check box."); nameField.addActionListener(okListener); p.add(nameField); // row 5 s = Modeler.getInternationalText("ImageFileNameSelected"); p.add(new JLabel(s != null ? s : "Image to show while selected", SwingConstants.LEFT)); imageSelectedField = new JTextField(); imageSelectedField.setToolTipText( "Type in the file name of the image that will appear on this check box while it is selected."); imageSelectedField.addActionListener(okListener); p.add(imageSelectedField); // row 6 s = Modeler.getInternationalText("ImageFileNameDeselected"); p.add(new JLabel(s != null ? s : "Image to show while not selected", SwingConstants.LEFT)); imageDeselectedField = new JTextField(); imageDeselectedField.setToolTipText( "Type in the file name of the image that will appear on this check box while it is not selected."); imageDeselectedField.addActionListener(okListener); p.add(imageDeselectedField); // row 7 s = Modeler.getInternationalText("ToolTipLabel"); p.add(new JLabel(s != null ? s : "Tool tip", SwingConstants.LEFT)); toolTipField = new JTextField(); toolTipField.setToolTipText("Type in the text that will appear as the tool tip."); toolTipField.addActionListener(okListener); p.add(toolTipField); // row 8 s = Modeler.getInternationalText("WidthLabel"); p.add(new JLabel(s != null ? s : "Width", SwingConstants.LEFT)); widthField = new IntegerTextField(pageCheckBox.getWidth() <= 0 ? 100 : pageCheckBox.getWidth(), 10, 400); widthField.setEnabled(false); widthField.setToolTipText( "Type in an integer to set the width of this check box, if it will not be auto-sized."); widthField.addActionListener(okListener); p.add(widthField); // row 9 s = Modeler.getInternationalText("HeightLabel"); p.add(new JLabel(s != null ? s : "Height", SwingConstants.LEFT)); heightField = new IntegerTextField( pageCheckBox.getHeight() <= 0 ? 24 : pageCheckBox.getHeight(), 10, 400); heightField.setEnabled(false); heightField.setToolTipText( "Type in an integer to set the height of this check box, if it will not be auto-sized."); heightField.addActionListener(okListener); p.add(heightField); // row 10 s = Modeler.getInternationalText("BackgroundColorLabel"); p.add(new JLabel(s != null ? s : "Background color", SwingConstants.LEFT)); bgComboBox = new ColorComboBox(pageCheckBox); bgComboBox.setRequestFocusEnabled(false); bgComboBox.setToolTipText( "Select the background color for this check box, if it is not transparent."); p.add(bgComboBox); ModelerUtilities.makeCompactGrid(p, 10, 2, 5, 5, 10, 2); p = new JPanel(new BorderLayout(10, 10)); p.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10)); contentPane.add(p, BorderLayout.CENTER); JPanel p1 = new JPanel(new GridLayout(2, 2)); p1.setBorder(BorderFactory.createEtchedBorder()); p.add(p1, BorderLayout.NORTH); s = Modeler.getInternationalText("TransparencyCheckBox"); transparentCheckBox = new JCheckBox(s != null ? s : "Transparent"); // transparentCheckBox.setEnabled(!Page.isNativeLookAndFeelUsed()); transparentCheckBox.setSelected(false); transparentCheckBox.setToolTipText("Select to set this check box to be transparent."); p1.add(transparentCheckBox); s = Modeler.getInternationalText("AutosizeCheckBox"); autoSizeCheckBox = new JCheckBox(s != null ? s : "Size automatically"); autoSizeCheckBox.setSelected(pageCheckBox.autoSize); autoSizeCheckBox.setToolTipText( "<html>Select to make this check box auto-size itself according to the text and image on it.<br>Deselect to set a custom size.</html>"); autoSizeCheckBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { pageCheckBox.autoSize = autoSizeCheckBox.isSelected(); widthField.setEnabled(!pageCheckBox.autoSize); heightField.setEnabled(!pageCheckBox.autoSize); } }); p1.add(autoSizeCheckBox); s = Modeler.getInternationalText("DisabledAtRunCheckBox"); disabledAtRunCheckBox = new JCheckBox(s != null ? s : "Disabled while model is running"); disabledAtRunCheckBox.setSelected(false); disabledAtRunCheckBox.setToolTipText( "<html>Select if you wish this check box to be disabled while the model is running,<br>and to be enabled when the model stops.</html>"); p1.add(disabledAtRunCheckBox); s = Modeler.getInternationalText("DisabledAtScriptCheckBox"); disabledAtScriptCheckBox = new JCheckBox(s != null ? s : "Disabled while scripts are running"); disabledAtScriptCheckBox.setSelected(false); disabledAtScriptCheckBox.setToolTipText( "<html>Select if you wish this check box to be disabled while scripts are running,<br>and to be enabled when scripts end.</html>"); p1.add(disabledAtScriptCheckBox); p1 = new JPanel(new GridLayout(2, 1, 5, 5)); p.add(p1, BorderLayout.CENTER); JPanel p2 = new JPanel(new BorderLayout(5, 5)); s = Modeler.getInternationalText("EnterScriptWhenSelectedLabel"); scriptLabelSelected = new JLabel(s != null ? s : "Enter the script to be run when selected:"); scriptLabelSelected.setEnabled(false); p2.add(scriptLabelSelected, BorderLayout.NORTH); scriptAreaSelected = new PastableTextArea(5, 10); scriptAreaSelected.setEnabled(false); scriptAreaSelected.setBorder(BorderFactory.createLoweredBevelBorder()); p2.add(new JScrollPane(scriptAreaSelected), BorderLayout.CENTER); p1.add(p2); p2 = new JPanel(new BorderLayout(5, 5)); s = Modeler.getInternationalText("EnterScriptWhenDeselectedLabel"); scriptLabelDeselected = new JLabel(s != null ? s : "Enter the script to be run when deselected:"); scriptLabelDeselected.setEnabled(false); p2.add(scriptLabelDeselected, BorderLayout.NORTH); scriptAreaDeselected = new PastableTextArea(5, 10); scriptAreaDeselected.setEnabled(false); scriptAreaDeselected.setBorder(BorderFactory.createLoweredBevelBorder()); p2.add(new JScrollPane(scriptAreaDeselected), BorderLayout.CENTER); p1.add(p2); }
public CaixaDetalhesDialog() { setModal(true); setModalityType(ModalityType.APPLICATION_MODAL); setSize(new Dimension(530, 400)); setPreferredSize(new Dimension(530, 400)); setResizable(false); getContentPane().setLayout(new BorderLayout(0, 0)); final JPanel panelTopo = new JPanel(); getContentPane().add(panelTopo, BorderLayout.NORTH); panelTopo.setLayout(new GridLayout(0, 1, 0, 0)); final JPanel panelData = new JPanel(); panelTopo.add(panelData); tfDia = new IntegerTextField(false); tfDia.setHorizontalAlignment(SwingConstants.CENTER); tfDia.setFont(tfDia.getFont().deriveFont(tfDia.getFont().getSize() + 12f)); panelData.add(tfDia); tfDia.setColumns(2); tfDia.addChangeListener(this); cbMes = new JComboBox<String>(); cbMes.setFont(cbMes.getFont().deriveFont(cbMes.getFont().getSize() + 12f)); cbMes.setModel( new DefaultComboBoxModel<String>( new String[] { "Janeiro", "Fevereiro", "Mar\u00E7o", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" })); panelData.add(cbMes); cbMes.addItemListener(this); tfAno = new IntegerTextField(false); tfAno.setHorizontalAlignment(SwingConstants.CENTER); tfAno.setFont(tfAno.getFont().deriveFont(tfAno.getFont().getSize() + 12f)); panelData.add(tfAno); tfAno.setColumns(4); tfAno.addChangeListener(this); lblDiaSemana = new JLabel("[dia da semana]"); lblDiaSemana.setHorizontalAlignment(SwingConstants.CENTER); lblDiaSemana.setFont( lblDiaSemana .getFont() .deriveFont( lblDiaSemana.getFont().getStyle() | Font.BOLD, lblDiaSemana.getFont().getSize() + 10f)); panelTopo.add(lblDiaSemana); lblComputador = new JLabel("[computador]"); lblComputador.setHorizontalAlignment(SwingConstants.CENTER); lblComputador.setFont( lblComputador .getFont() .deriveFont( lblComputador.getFont().getStyle() | Font.ITALIC, lblComputador.getFont().getSize() + 10f)); panelTopo.add(lblComputador); final JPanel panelBotoes = new JPanel(); getContentPane().add(panelBotoes, BorderLayout.SOUTH); btnDia = new JButton(""); btnDia.setIcon(new ImageIcon(CaixaDetalhesDialog.class.getResource("/res/img/sol.png"))); btnDia.addActionListener(this); panelBotoes.add(btnDia); btnNoite = new JButton(""); btnNoite.setIcon(new ImageIcon(CaixaDetalhesDialog.class.getResource("/res/img/lua.png"))); btnNoite.addActionListener(this); panelBotoes.add(btnNoite); loadDefaults(); }
private void setNodeFilterPanel() { lWMap = tufts.vue.VUE.getActiveMap(); addButton.setToolTipText(VueResources.getString("nodefilter.addfilter.tooltip")); deleteButton.setToolTipText(VueResources.getString("nodefilter.deletefilter.tooltip")); elementsModel = new ElementComboBoxModel(); elementsModel.setElements(lWMap.getMapFilterModel().getKeyVector()); elements = new JComboBox(elementsModel); Font f = elements.getFont(); Font menuFont = new Font(f.getFontName(), f.getStyle(), f.getSize() - 2); elements.setFont(menuFont); // elements.setPreferredSize(new Dimension(150,20)); /// this is not user friendly may want to fix later. /** * elements.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { * if(e.getStateChange() == ItemEvent.SELECTED) { if(e.getItem().toString() == ADD_ELEMENT) { } * else if(e.getItem() instanceof Key) { Statement stmt = new Statement(); * stmt.setKey((Key)e.getItem()); nodeFilter.addStatement(stmt); * nodeFilter.fireTableDataChanged(); } else { System.out.println("Not Supported"); } } } }); */ nodeFilterTable = new JTable(nodeFilter); nodeFilterTable.addFocusListener( new FocusListener() { public void focusLost(FocusEvent e) { if (nodeFilterTable.isEditing()) { nodeFilterTable .getCellEditor( nodeFilterTable.getEditingRow(), nodeFilterTable.getEditingColumn()) .stopCellEditing(); } nodeFilterTable.removeEditor(); } public void focusGained(FocusEvent e) {} }); nodeFilterTable.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (nodeFilterTable.getSelectedRow() == (nodeFilterTable.getRowCount() - 1) && e.getKeyCode() == e.VK_ENTER) { addButtonListener.addStatement(); } } }); nodeFilterTable.setPreferredScrollableViewportSize(new Dimension(240, 100)); JScrollPane nodeFilterScrollPane = new JScrollPane(nodeFilterTable); nodeFilterScrollPane.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); JPanel nodeFilterPanel = new JPanel(); nodeFilterPanel.setLayout(new BorderLayout()); nodeFilterPanel.add(nodeFilterScrollPane, BorderLayout.CENTER); addButtonListener = new AddButtonListener(nodeFilter); addButton.addActionListener(addButtonListener); deleteButton.setEnabled(false); sListener = new NodeFilterSelectionListener(deleteButton, -1); nodeFilterTable.getSelectionModel().addListSelectionListener(sListener); deleteButtonListener = new DeleteButtonListener(nodeFilterTable, sListener); deleteButton.addActionListener(deleteButtonListener); // keyEditor = new KeyCellEditor(); // nodeFilterTable.getColumnModel().getColumn(NodeFilter.KEY_COL).setCellEditor(keyEditor); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0)); // bottomPanel.setBorder(BorderFactory.createEmptyBorder(3,6,3,6)); bottomPanel.add(elementLabel); bottomPanel.add(elements); bottomPanel.add(addButton); bottomPanel.add(deleteButton); bottomPanel.add(questionLabel); // innerPanel.add(labelPanel); innerPanel.add(bottomPanel); innerPanel.add(nodeFilterPanel); setLayout(new BorderLayout()); add(innerPanel, BorderLayout.CENTER); validate(); }
FilterPanel(final FilterGui<E> gui, final FilterControl<E> filterControl) { this.gui = gui; this.filterControl = filterControl; ListenerClass listener = new ListenerClass(); allColumns = new ArrayList<EnumTableColumn<E>>(); allColumns.add(new AllColumn<E>()); allColumns.addAll(filterControl.getColumns()); numericColumns = new ArrayList<EnumTableColumn<E>>(); for (EnumTableColumn<E> object : filterControl.getColumns()) { if (filterControl.isNumeric(object)) { numericColumns.add(object); } } dateColumns = new ArrayList<EnumTableColumn<E>>(); for (EnumTableColumn<E> object : filterControl.getColumns()) { if (filterControl.isDate(object)) { dateColumns.add(object); } } jEnabled = new JCheckBox(); jEnabled.setSelected(true); jEnabled.addActionListener(listener); jEnabled.setActionCommand(FilterPanelAction.FILTER.name()); jLogic = new JComboBox<LogicType>(LogicType.values()); jLogic.setPrototypeDisplayValue(LogicType.AND); jLogic.addActionListener(listener); jLogic.setActionCommand(FilterPanelAction.FILTER.name()); JComboBox<String> jComboBox = new JComboBox<String>(); FontMetrics fontMetrics = jComboBox.getFontMetrics(jComboBox.getFont()); EnumTableColumn<E> longestColumn = null; for (EnumTableColumn<E> column : allColumns) { if (longestColumn == null || fontMetrics.stringWidth(longestColumn.getColumnName()) < fontMetrics.stringWidth(column.getColumnName())) { longestColumn = column; } } jColumn = new JComboBox<EnumTableColumn<E>>(new ListComboBoxModel<EnumTableColumn<E>>(allColumns)); jColumn.setPrototypeDisplayValue(longestColumn); jColumn.addActionListener(listener); jColumn.setActionCommand(FilterPanelAction.FILTER.name()); jCompare = new JComboBox<CompareType>(); jCompare.setPrototypeDisplayValue(CompareType.CONTAINS_NOT_COLUMN); jCompare.addActionListener(listener); jCompare.setActionCommand(FilterPanelAction.FILTER.name()); jText = new JTextField(); jText.getDocument().addDocumentListener(listener); jText.addKeyListener(listener); jCompareColumn = new JComboBox<EnumTableColumn<E>>(); jCompareColumn.setPrototypeDisplayValue(longestColumn); jCompareColumn.addActionListener(listener); jCompareColumn.setActionCommand(FilterPanelAction.FILTER.name()); jDate = new JDateChooser(false); jDate.addDateChangeListener(listener); jSpacing = new JLabel(); jRemove = new JButton(); jRemove.setIcon(Images.EDIT_DELETE.getIcon()); jRemove.addActionListener(listener); jRemove.setActionCommand(FilterPanelAction.REMOVE.name()); timer = new Timer(500, listener); timer.setActionCommand(FilterPanelAction.FILTER_TIMER.name()); jPanel = new JPanel(); layout = new GroupLayout(jPanel); jPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(false); layout.setHorizontalGroup( layout .createSequentialGroup() .addComponent(jEnabled, 30, 30, 30) .addComponent( jLogic, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( jColumn, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( jCompare, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jText, 100, 100, Integer.MAX_VALUE) .addComponent( jCompareColumn, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( jDate, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jSpacing, 0, 0, Integer.MAX_VALUE) .addComponent(jRemove, 30, 30, 30)); layout.setVerticalGroup( layout .createParallelGroup() .addComponent( jEnabled, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jLogic, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jColumn, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jCompare, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jText, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jCompareColumn, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jDate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jSpacing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent( jRemove, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())); updateNumeric(false); }