ApplicationFrame() { super("Ecuatii Neliniare"); setSize(frameWidth, frameHeight); setDefaultCloseOperation(this.EXIT_ON_CLOSE); panel.setOpaque(true); getContentPane().add(panel); addComponentListener(this); for (int i = 0; i < Methods.length; i++) ChooseMethod.addItem(Methods[i]); buttonPanel.add(ChooseMethod); buttonPanel.setOpaque(true); JButton buttonAdd = new JButton("Aplica..."); buttonAdd.setPreferredSize(new Dimension(125, 25)); buttonAdd.addActionListener(this); buttonPanel.add(buttonAdd); unitXSlider.setMinorTickSpacing(5); unitXSlider.setPaintTicks(true); unitXSlider.addChangeListener(this); unitYSlider.setMinorTickSpacing(5); unitYSlider.setPaintTicks(true); unitYSlider.addChangeListener(this); buttonPanel.add(unitXSlider); buttonPanel.add(unitYSlider); Border padding = BorderFactory.createEmptyBorder(0, 20, 20, 20); panel.setBorder(padding); panel.add(buttonPanel, BorderLayout.NORTH); panel.add(graph, BorderLayout.CENTER); pack(); setVisible(true); }
private void refresh(int index) { GridBagConstraints c = new GridBagConstraints(); // No connector ................ if (acs.size() == 0) { add(new JLabel(bundle.getString("CTL_No_Connector")), c); return; } // Connector switch ................ if (acs.size() > 1) { c.insets = new Insets(0, 0, 3, 3); add(new JLabel(bundle.getString("CTL_Connector")), c); cbConnectors = new JComboBox(); int i, k = acs.size(); for (i = 0; i < k; i++) { AttachingConnector ac = (AttachingConnector) acs.get(i); int jj = ac.name().lastIndexOf('.'); String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1); cbConnectors.addItem(s + " (" + ac.description() + ")"); } c = new GridBagConstraints(); c.insets = new Insets(0, 3, 3, 0); c.weightx = 1.0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.gridwidth = 0; cbConnectors.setSelectedIndex(index); cbConnectors.setActionCommand("SwitchMe!"); cbConnectors.addActionListener(this); add(cbConnectors, c); } ac = (AttachingConnector) acs.get(index); // Transport ................ c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); add(new JLabel(bundle.getString("CTL_Transport")), c); JTextField tfTransport = new JTextField(ac.transport().name()); tfTransport.setEnabled(false); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(3, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfTransport, c); // Other params ................ args = ac.defaultArguments(); tfParams = new JTextField[args.size()]; Iterator it = args.keySet().iterator(); int i = 0; while (it.hasNext()) { String name = (String) it.next(); Argument a = (Argument) args.get(name); c = new GridBagConstraints(); c.insets = new Insets(6, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(a.label() + ": "), c); JTextField tfParam = new JTextField(a.value()); tfParams[i++] = tfParam; tfParam.setName(name); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(6, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfParam, c); } c = new GridBagConstraints(); c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }
/** Create the UI for this editor */ void makeUI() { JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(new LineBorder(Color.blue)); getContentPane().add(mainPanel, BorderLayout.CENTER); // the map and associated toolbar npEditControl = new NPController(); mapEditPanel = npEditControl.getNavigatedPanel(); // here's where the map will be drawn mapEditPanel.setPreferredSize(new Dimension(250, 250)); mapEditPanel.setSelectRegionMode(true); JToolBar navToolbar = mapEditPanel.getNavToolBar(); navToolbar.setFloatable(false); JToolBar moveToolbar = mapEditPanel.getMoveToolBar(); moveToolbar.setFloatable(false); // toolbar.remove("setReference"); JPanel toolbar = new JPanel(); List localMaps = maps; if (localMaps == null) { localMaps = getDefaultMaps(); } JMenu mapMenu = new JMenu("Maps"); JMenuBar menuHolder = new JMenuBar(); menuHolder.setBorder(null); menuHolder.add(mapMenu); toolbar.add(menuHolder); for (int mapIdx = 0; mapIdx < localMaps.size(); mapIdx++) { final MapData mapData = (MapData) localMaps.get(mapIdx); final JCheckBoxMenuItem cbx = new JCheckBoxMenuItem(mapData.getDescription(), mapData.getVisible()); if (mapData.getVisible()) { toggleMap(mapData, true); } mapMenu.add(cbx); cbx.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { toggleMap(mapData, cbx.isSelected()); } }); } GuiUtils.limitMenuSize(mapMenu, "Maps ", 20); toolbar.add(navToolbar); toolbar.add(moveToolbar); JPanel mapSide = new JPanel(); mapSide.setLayout(new BorderLayout()); TitledBorder mapBorder = new TitledBorder( standardBorder, "Edit Projection", TitledBorder.ABOVE_TOP, TitledBorder.CENTER); mapSide.setBorder(mapBorder); mapSide.add(toolbar, BorderLayout.NORTH); mapSide.add(mapEditPanel, BorderLayout.CENTER); mainPanel.add(mapSide, BorderLayout.WEST); // the projection parameters // the Projection name JLabel nameLabel = GuiUtils.rLabel("Name: "); nameTF = new JTextField(20); // the list of Projection classes is kept in a comboBox typeLabel = GuiUtils.rLabel("Type: "); projClassCB = new JComboBox(); // standard list of projection classes List classNames = getDefaultProjections(); for (int i = 0; i < classNames.size(); i++) { String className = (String) classNames.get(i); try { projClassCB.addItem(new ProjectionClass(className)); } catch (ClassNotFoundException ee) { System.err.println("ProjectionManager failed on " + className + " " + ee); } catch (IntrospectionException ee) { System.err.println("ProjectionManager failed on " + className + " " + ee); } } GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); JPanel topPanel = GuiUtils.doLayout( new Component[] {nameLabel, nameTF, typeLabel, projClassCB}, 2, GuiUtils.WT_N, GuiUtils.WT_N); // the Projection parameter area paramPanel = new JPanel(); paramPanel.setLayout(new BorderLayout()); paramPanel.setBorder( new TitledBorder( standardBorder, "Projection Parameters", TitledBorder.ABOVE_TOP, TitledBorder.CENTER)); // the bottom button panel JPanel buttPanel = new JPanel(); JButton acceptButton = new JButton("Save"); JButton previewButton = new JButton("Preview"); JButton cancelButton = new JButton("Cancel"); buttPanel.add(acceptButton, null); buttPanel.add(previewButton, null); buttPanel.add(cancelButton, null); JPanel mainBox = GuiUtils.topCenterBottom(topPanel, paramPanel, buttPanel); mainPanel.add(mainBox, BorderLayout.CENTER); pack(); // enable event listeners when we're done constructing the UI projClassCB.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ProjectionClass selectClass = (ProjectionClass) projClassCB.getSelectedItem(); setProjection(selectClass.makeDefaultProjection()); } }); acceptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { accept(); } }); previewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { ProjectionClass projClass = findProjectionClass(editProjection); if (null != projClass) { setProjFromDialog(projClass, editProjection); setProjection(editProjection); } } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { NewProjectionDialog.this.setVisible(false); } }); }