/** * The GPropertiesDialog class constructor. * * @param gui the GUI class */ public GPropertiesDialog(GUI gui) { // superclass constructor super(gui, "Properties", false); objects = new ObjectContainer(); // gui this.gui = gui; // set the fixed size setSize(260, 350); setResizable(false); setLayout(null); // set up panels for stuff pane = new JTabbedPane(); // add the tabbed panel tabbedPanePanel = new JPanel(); tabbedPanePanel.add(pane); tabbedPanePanel.setLayout(null); this.getContentPane().add(tabbedPanePanel); tabbedPanePanel.setBounds(0, 0, this.getWidth(), 280); pane.setBounds(0, 0, tabbedPanePanel.getWidth(), tabbedPanePanel.getHeight()); // set up buttons apply = new JButton("Apply"); apply.setBounds(150, 290, 80, 26); this.getContentPane().add(apply); close = new JButton("Close"); close.setBounds(50, 290, 80, 26); this.getContentPane().add(close); addPanel(new GPropertiesPanelCustomObject(gui.getGMap()), "Object"); // add listeners addMouseListener(this); apply.addItemListener(this); apply.addActionListener(this); close.addItemListener(this); close.addActionListener(this); }
/** Method for removing all current Panels */ public void removeAllPanels() { pane.removeAll(); objects.removeAll(); }
/** * Method for removing a Panel by object reference * * @param object The object to remove */ public void removePanel(GPropertiesPanel object) { pane.remove(object); objects.remove(object); }
/** * Method for removing a Panel by index reference * * @param index The index of the object to remove */ public void removePanel(int index) { pane.remove((GPropertiesPanel) objects.get(index)); objects.remove(index); }
/** * Method for adding a new Panel * * @param object The new Panel */ public void addPanel(GPropertiesPanel object, String title) { pane.add(object, title); objects.add(object); }
public SketchProperties(Editor e, Sketch s) { super(); editor = e; sketch = s; fields = new HashMap<String, JComponent>(); this.setPreferredSize(new Dimension(500, 400)); this.setMinimumSize(new Dimension(500, 400)); this.setMaximumSize(new Dimension(500, 400)); this.setSize(new Dimension(500, 400)); Point eLoc = editor.getLocation(); int x = eLoc.x; int y = eLoc.y; Dimension eSize = editor.getSize(); int w = eSize.width; int h = eSize.height; int cx = x + (w / 2); int cy = y + (h / 2); this.setLocation(new Point(cx - 250, cy - 200)); this.setModal(true); outer = new JPanel(new BorderLayout()); outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(outer); win = new JPanel(); win.setLayout(new BorderLayout()); outer.add(win, BorderLayout.CENTER); buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); saveButton = new JButton("OK"); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); SketchProperties.this.dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SketchProperties.this.dispose(); } }); buttonBar.add(saveButton); buttonBar.add(cancelButton); win.add(buttonBar, BorderLayout.SOUTH); tabs = new JTabbedPane(); overviewPane = new JPanel(); overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS)); overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(overviewPane, "author", "Sketch author:"); addTextArea(overviewPane, "summary", "Summary:"); addTextArea(overviewPane, "license", "Copyright / License:"); tabs.add("Overview", overviewPane); objectsPane = new JPanel(); objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS)); objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(objectsPane, "board", "Board:"); addTextField(objectsPane, "core", "Core:"); addTextField(objectsPane, "compiler", "Compiler:"); addTextField(objectsPane, "port", "Serial port:"); addTextField(objectsPane, "programmer", "Programmer:"); JButton setDef = new JButton("Set to current IDE values"); setDef.setMaximumSize(setDef.getPreferredSize()); setDef.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setObjectValues(); } }); objectsPane.add(Box.createVerticalGlue()); objectsPane.add(setDef); tabs.add("Objects", objectsPane); win.add(tabs, BorderLayout.CENTER); this.setTitle("Sketch Properties"); this.pack(); this.setVisible(true); }