/** Displays the labels and the values for the panel. */ protected void displayPnlFields(HashMap hmPnl) { if (hmPnl == null || hmPnl.isEmpty()) return; Iterator keySetItr = hmPnl.keySet().iterator(); String strLabel = ""; String strValue = ""; // if the file is empty, then create an empty set of textfields. if (hmPnl == null || hmPnl.isEmpty()) { displayNewTxf("", ""); return; } Container container = getParent(); if (container != null) container.setVisible(false); try { // Get each set of label and value, and display them. while (keySetItr.hasNext()) { strLabel = (String) keySetItr.next(); strValue = (String) hmPnl.get(strLabel); displayNewTxf(strLabel, strValue); } if (container != null) container.setVisible(true); revalidate(); repaint(); } catch (Exception e) { Messages.writeStackTrace(e); // e.printStackTrace(); Messages.postDebug(e.toString()); } }
public void doAction(ActionEvent e) { String cmd = e.getActionCommand(); // the new button creates a new set of texfields if (cmd.equals("new")) { Container container = getParent(); if (container != null) container.setVisible(false); displayNewTxf("", ""); if (container != null) container.setVisible(true); } }
/** * Adds a component to the contentpane. * * @comp component to be added. */ protected void addComp(JComponent comp) { Container contentPane = getContentPane(); contentPane.add(comp, BorderLayout.CENTER); }
private void initUi() { String history; String undo; String close; String abandon; String help; String string; char helpMnemonic; char historyMnemonic; char undoMnemonic; char closeMnemonic; char abandonMnemonic; DisplayOptions.addChangeListener(this); // setAlwaysOnTop(true); // Get text for buttons from properties/resource file history = Util.getLabel("blHistory", "Edit..."); undo = Util.getLabel("blUndo", "Undo"); close = Util.getLabel("blClose", "Close"); abandon = Util.getLabel("blAbandon", "Abandon"); help = Util.getLabel("blHelp", "Help"); // buttons undoButton = new JButton(undo); closeButton = new JButton(close); abandonButton = new JButton(abandon); helpButton = new JButton(help); // Create an ArrayList of menu items from properties file ArrayList<String> historyList = new ArrayList<String>(); historyList.add(Util.getLabel("mlHistReturnInitState", "Return to initial state")); historyList.add(Util.getLabel("mlHistMakeSnapshot", "Make a snapshot")); historyList.add(Util.getLabel("mlHistReturnToSnapshot", "Return to snapshot")); historyList.add(Util.getLabel("mlHistReturnToDefault", "Return to system defaults")); // Pop Button for history menu historyButton = new MPopButton(historyList); historyButton.setText(history); // Only set mnemonics if found. if (Util.labelExists("blmHelp")) { string = Util.getLabel("blmHelp"); helpMnemonic = string.charAt(0); helpButton.setMnemonic(helpMnemonic); } if (Util.labelExists("blmUndo")) { string = Util.getLabel("blmUndo"); undoMnemonic = string.charAt(0); undoButton.setMnemonic(undoMnemonic); } if (Util.labelExists("blmAbandon")) { string = Util.getLabel("blmAbandon"); abandonMnemonic = string.charAt(0); abandonButton.setMnemonic(abandonMnemonic); } if (Util.labelExists("blmClose")) { string = Util.getLabel("blmClose"); closeMnemonic = string.charAt(0); closeButton.setMnemonic(closeMnemonic); } if (Util.labelExists("blmHistory")) { string = Util.getLabel("blmHistory"); historyMnemonic = string.charAt(0); historyButton.setMnemonic(historyMnemonic); } helpButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Display Help if help file exists CSH_Util.displayCSHelp(dialogTitle); } }); // Make a panel to hold the buttons buttonPane = new JPanel(); // Put an empty border around the inside of the panel. buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 5)); buttonPane.setLayout(new SimpleH2Layout(SimpleH2Layout.CENTER)); // Add the buttons to the panel with space between buttons. buttonPane.add(historyButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(undoButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(closeButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(abandonButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(helpButton); // Put everything together, using the content pane's BorderLayout. Container contentPane = getContentPane(); contentPane.add(buttonPane, BorderLayout.SOUTH); setHistoryEnabled(false); // setCloseEnabled(false); setAbandonEnabled(false); setUndoEnabled(false); if (!CSH_Util.haveTopic(dialogTitle)) setHelpEnabled(false); // buttonPane.setVisible(false); // Add key listener to the whole dialog addKeyListener(this); // Make the frame fit its contents. // pack(); // nothing to pack. }