@Override public JPopupMenu getComponentPopupMenu() { if (popupMenu == null) { popupMenu = new JPopupMenu(Messages.CHART_COLON); timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU); timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU)); popupMenu.add(timeRangeMenu); menuRBs = new JRadioButtonMenuItem[rangeNames.length]; ButtonGroup rbGroup = new ButtonGroup(); for (int i = 0; i < rangeNames.length; i++) { menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]); rbGroup.add(menuRBs[i]); menuRBs[i].addActionListener(this); if (viewRange == rangeValues[i]) { menuRBs[i].setSelected(true); } timeRangeMenu.add(menuRBs[i]); } popupMenu.addSeparator(); saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM); saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM)); saveAsMI.addActionListener(this); popupMenu.add(saveAsMI); } return popupMenu; }
/** TabbedPaneDemo Constructor */ public TabbedPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "TabbedPaneDemo", "toolbar/JTabbedPane.gif"); // create tab position controls JPanel tabControls = new JPanel(); tabControls.add(new JLabel(getString("TabbedPaneDemo.label"))); top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top"))); left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left"))); bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom"))); right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right"))); getDemoPanel().add(tabControls, BorderLayout.NORTH); group = new ButtonGroup(); group.add(top); group.add(bottom); group.add(left); group.add(right); top.setSelected(true); top.addActionListener(this); bottom.addActionListener(this); left.addActionListener(this); right.addActionListener(this); // create tab tabbedpane = new JTabbedPane(); getDemoPanel().add(tabbedpane, BorderLayout.CENTER); String name = getString("TabbedPaneDemo.laine"); JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.ewan"); pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.hania"); pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.bounce"); spin = new HeadSpin(); tabbedpane.add(name, spin); tabbedpane .getModel() .addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) { spin.go(); } } }); }
protected JMenu buildSpeedMenu() { JMenu speed = new JMenu("Drag"); JRadioButtonMenuItem live = new JRadioButtonMenuItem("Live"); JRadioButtonMenuItem outline = new JRadioButtonMenuItem("Outline"); JRadioButtonMenuItem slow = new JRadioButtonMenuItem("Old and Slow"); ButtonGroup group = new ButtonGroup(); group.add(live); group.add(outline); group.add(slow); live.setSelected(true); slow.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // for right now I'm saying if you set the mode // to something other than a specified mode // it will revert to the old way // This is mostly for comparison's sake desktop.setDragMode(-1); } }); live.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE); } }); outline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); } }); speed.add(live); speed.add(outline); speed.add(slow); return speed; }
private void jbInit() throws Exception { //////////////////////////////////////////////////////// // Init LAF //////////////////////////////////////////////////////// ButtonGroup grpLAF = new ButtonGroup(); ActionListener lsnLAF = new ActionListener() { public void actionPerformed(ActionEvent evt) { int iIndex = mvtLAFItem.indexOf(evt.getSource()); if (iIndex >= 0) changeLAF(iIndex); } }; //////////////////////////////////////////////////////// UIManager.LookAndFeelInfo laf = new UIManager.LookAndFeelInfo( "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel"); marrLaf = UIManager.getInstalledLookAndFeels(); int iIndex = 0; while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++; if (iIndex >= marrLaf.length) { UIManager.installLookAndFeel(laf); marrLaf = UIManager.getInstalledLookAndFeels(); } for (iIndex = 0; iIndex < marrLaf.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName()); mnu.addActionListener(lsnLAF); mvtLAFItem.addElement(mnu); mnuUI.add(mnu); grpLAF.add(mnu); } mnuUI.addSeparator(); //////////////////////////////////////////////////////// // Init language //////////////////////////////////////////////////////// ButtonGroup grpLanguage = new ButtonGroup(); ActionListener lsnLanguage = new ActionListener() { public void actionPerformed(ActionEvent e) { int iIndex = mvtLanguageItem.indexOf(e.getSource()); if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex)); } }; //////////////////////////////////////////////////////// String[] str = MonitorDictionary.getSupportedLanguage(); for (iIndex = 0; iIndex < str.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage()); mnu.addActionListener(lsnLanguage); mvtLanguage.addElement(str[iIndex]); mvtLanguageItem.addElement(mnu); mnuUI.add(mnu); grpLanguage.add(mnu); } //////////////////////////////////////////////////////// // Add to main menu //////////////////////////////////////////////////////// mnuMain.removeAll(); mnuMain.add(mnuSystem); mnuSystem.add(mnuSystem_Login); mnuSystem.add(mnuSystem_ChangePassword); mnuSystem.addSeparator(); mnuSystem.add(mnuSystem_StopServer); mnuSystem.add(mnuSystem_EnableThreads); mnuMain.add(mnuUI); mnuMain.add(mnuHelp); mnuHelp.add(mnuHelp_About); //////////////////////////////////////////////////////// mnuMain.add(chkVietnamese); mnuMain.add(lblStatus); //////////////////////////////////////////////////////// pnlThread.setTabPlacement(JTabbedPane.LEFT); pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); //////////////////////////////////////////////////////// tblUser.addColumn("", 1, false); tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME); tblUser.addColumn("", 3, false); //////////////////////////////////////////////////////// JPanel pnlMessage = new JPanel(); pnlMessage.setLayout(new GridBagLayout()); pnlMessage.add( new JScrollPane(txtBoard), new GridBagConstraints( 0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( txtMessage, new GridBagConstraints( 0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( btnSend, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); txtBoard.setEditable(false); txtBoard.setAutoscrolls(true); txtBoard.setContentType("text/html"); clearAll(txtBoard); //////////////////////////////////////////////////////// JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4)); pnlUserButton.add(btnKick); pnlUserButton.add(btnRefresh); //////////////////////////////////////////////////////// JPanel pnlManager = new JPanel(new GridBagLayout()); pnlManager.add( new JScrollPane(tblUser), new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlManager.add( pnlUserButton, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 2, 4, 2), 0, 0)); //////////////////////////////////////////////////////// pnlUser.setDividerLocation(320); pnlUser.setLeftComponent(pnlManager); pnlUser.setRightComponent(pnlMessage); pnlUser.setOneTouchExpandable(true); //////////////////////////////////////////////////////// setOrientation(JSplitPane.VERTICAL_SPLIT); setOneTouchExpandable(true); pnlThread.setVisible(false); pnlUser.setVisible(false); setTopComponent(pnlThread); setBottomComponent(pnlUser); //////////////////////////////////////////////////////// pmn.add(mnuSelectAll); pmn.addSeparator(); pmn.add(mnuClearSelected); pmn.add(mnuClearAll); //////////////////////////////////////////////////////// setBorder(BorderFactory.createEmptyBorder()); pnlUser.setBorder(BorderFactory.createEmptyBorder()); pnlManager.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); pnlMessage.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); //////////////////////////////////////////////////////// Skin.applySkin(mnuMain); Skin.applySkin(tblUser); Skin.applySkin(pmn); Skin.applySkin(this); //////////////////////////////////////////////////////// // Default setting //////////////////////////////////////////////////////// Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0"))); changeDictionary(StringUtil.nvl(prt.get("Language"), "VN")); Skin.LANGUAGE_CHANGE_LISTENER = this; MonitorProcessor.setRootObject(this); updateKeyboardUI(); //////////////////////////////////////////////////////// // Event handler //////////////////////////////////////////////////////// tblUser.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) btnKick.doClick(); } }); //////////////////////////////////////////////////////// btnRefresh.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { try { DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request); if (response != null) { tblUser.setData((Vector) response.getReturn()); if (mstrChannel != null) removeUser(mstrChannel); } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// btnKick.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { int iSelected = tblUser.getSelectedRow(); if (iSelected < 0) return; int iResult = MessageBox.showConfirmDialog( pnlThread, mdic.getString("ConfirmKick"), Global.APP_NAME, MessageBox.YES_NO_OPTION); if (iResult == MessageBox.NO_OPTION) return; try { String strChannel = (String) tblUser.getRow(iSelected).elementAt(0); DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); request.setString("strChannel", strChannel); DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// txtMessage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { btnSend.doClick(); } }); //////////////////////////////////////////////////////// btnSend.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { if (txtMessage.getText().length() == 0) return; try { DDTP request = new DDTP(); request.setString("strMessage", txtMessage.getText()); channel.sendRequest("ThreadProcessor", "sendMessage", request); txtMessage.setText(""); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// mnuClearAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { clearAll(txtBoard); } }); //////////////////////////////////////////////////////// mnuClearSelected.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.setEditable(true); txtBoard.replaceSelection(""); txtBoard.setEditable(false); } }); //////////////////////////////////////////////////////// mnuSelectAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.requestFocus(); txtBoard.selectAll(); } }); //////////////////////////////////////////////////////// txtBoard.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY()); } }); //////////////////////////////////////////////////////// mnuSystem_Login.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { login(); } }); //////////////////////////////////////////////////////// mnuSystem_ChangePassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changePassword(); } }); //////////////////////////////////////////////////////// mnuSystem_StopServer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopServer(); } }); //////////////////////////////////////////////////////// mnuSystem_EnableThreads.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { manageThreads(); } }); //////////////////////////////////////////////////////// mnuHelp_About.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this)); } }); //////////////////////////////////////////////////////// chkVietnamese.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { switchKeyboard(); } }); }
public ContextEditor(Context cntxt) { super("Edit User Context: " + localFileName(cntxt)); ctxt = cntxt; windowNum = ctxt.languageName + " Context Editor"; setDefaultCloseOperation(DISPOSE_ON_CLOSE); listener = new CEListener(this); JPanel nameBox = new JPanel(); nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS)); name = new JTextField(ctxt.languageName, 28); name.setMaximumSize(new Dimension(225, 22)); name.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { nameFocusLost(evt); } }); JLabel nameLabel = new JLabel("Language Name: "); nameBox.add(nameLabel); nameBox.add(name); JPanel folderBox = new JPanel(); folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS)); folder = new JTextField(ctxt.editDirectory); folder.setMaximumSize(new Dimension(225, 22)); // folder.addActionListener(listener); // folder.setActionCommand("folder edit"); folder.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { folderFocusLost(evt); } }); JLabel folderLabel = new JLabel("SILK file folder: "); folderBox.add(folderLabel); folderBox.add(folder); JPanel nameFolderBox = new JPanel(); nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS)); nameBox.setAlignmentX(0.5f); nameFolderBox.add(nameBox); nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4))); nameFolderBox.add(folderBox); nameFolderBox.setAlignmentX(0.5f); buildPopulationBox(); JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel(); btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS)); subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS)); int numUDPs = 0; if (ctxt.userDefinedProperties != null) { numUDPs = ctxt.userDefinedProperties.size(); } String plur = "ies"; if (numUDPs == 1) { plur = "y"; } JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur); subBoxUDP.add(udpLabel); JButton addUDP = new JButton("Add UDP"); addUDP.setActionCommand("add UDP"); addUDP.addActionListener(listener); subBoxUDP.add(addUDP); btnBoxUDPs.add(subBoxUDP); if (numUDPs > 0) { Dimension sizer = new Dimension(250, 50); String[] udpMenu = genUDPMenu(); UDPick = new JComboBox(udpMenu); UDPick.addActionListener(listener); UDPick.setActionCommand("view/edit UDP"); UDPick.setMinimumSize(sizer); UDPick.setMaximumSize(sizer); UDPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit UDPs")); btnBoxUDPs.add(UDPick); } // end of if-any-UDPs-exist JPanel domThs = new JPanel(); domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS)); domThs.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Kinship System Domain Theories")); domThs.setAlignmentX(0.5f); JPanel dtRefBtnBox = new JPanel(); dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS)); dtRefBtnBox.setAlignmentX(0.0f); JLabel dtRefLabel = new JLabel("Terms of Reference "); dtRefBtnBox.add(dtRefLabel); if (ctxt.domTheoryRefExists()) { JButton dtRefEdit = new JButton("Edit Theory"); dtRefEdit.setActionCommand("edit dtRef"); dtRefEdit.addActionListener(listener); dtRefBtnBox.add(dtRefEdit); // JButton dtRefDelete = new JButton("Delete Theory"); // dtRefDelete.setActionCommand("dtRef delete"); // dtRefDelete.addActionListener(listener); // dtRefBtnBox.add(dtRefDelete); } // end of if-dt-exists else { // if does not exist JLabel dtRefNone = new JLabel("< None >"); dtRefBtnBox.add(dtRefNone); // JButton dtRefAdd = new JButton("Add Theory"); // dtRefAdd.setActionCommand("dtRef add"); // dtRefAdd.addActionListener(listener); // dtRefBtnBox.add(dtRefAdd); } // end of does-not-exist domThs.add(dtRefBtnBox); JPanel dtAddrBtnBox = new JPanel(); dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS)); dtAddrBtnBox.setAlignmentX(0.0f); JLabel dtAddrLabel = new JLabel("Terms of Address "); dtAddrBtnBox.add(dtAddrLabel); if (ctxt.domTheoryAdrExists()) { JButton dtAddrEdit = new JButton("Edit Theory"); dtAddrEdit.setActionCommand("edit dtAddr"); dtAddrEdit.addActionListener(listener); dtAddrBtnBox.add(dtAddrEdit); // JButton dtAddrViewList = new JButton("Delete Theory"); // dtAddrViewList.setActionCommand("dtAddr delete"); // dtAddrViewList.addActionListener(listener); // dtAddrBtnBox.add(dtAddrViewList); } // end of if-dt-exists else { // if does not exist JLabel dtAddrNone = new JLabel("< None >"); dtAddrBtnBox.add(dtAddrNone); // JButton dtAddrAdd = new JButton("Add Theory"); // dtAddrAdd.setActionCommand("dtAddr add"); // dtAddrAdd.addActionListener(listener); // dtAddrBtnBox.add(dtAddrAdd); } // end of does-not-exist domThs.add(dtAddrBtnBox); // End of the left hand portion // Right hand portion follows. it is narrower. JPanel polyBox = new JPanel(); polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS)); polyBox.setAlignmentX(0.5f); JLabel polyLabelA = new JLabel("Polygamy"); JLabel polyLabelB = new JLabel("Permitted?"); JRadioButton yesPoly = new JRadioButton("Yes"); yesPoly.setActionCommand("polygamy yes"); yesPoly.addActionListener(listener); JRadioButton noPoly = new JRadioButton("No"); noPoly.setActionCommand("polygamy no"); noPoly.addActionListener(listener); if (cntxt.polygamyPermit) { yesPoly.setSelected(true); } else { noPoly.setSelected(true); } ButtonGroup polyBtns = new ButtonGroup(); polyBtns.add(yesPoly); polyBtns.add(noPoly); polyBox.add(polyLabelA); polyBox.add(polyLabelB); polyBox.add(yesPoly); polyBox.add(noPoly); JPanel matrixBox = new JPanel(); matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS)); matrixBox.setAlignmentX(0.5f); JLabel matrixLabelA = new JLabel("Kin Term Matrix"); JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows"); JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms"); matrixLabelA.setAlignmentX(0.5f); matrixLabelC.setAlignmentX(0.5f); matrixLabelD.setAlignmentX(0.5f); JButton matrixEditBtn = new JButton("Edit Matrix"); matrixEditBtn.setEnabled(false); matrixEditBtn.setActionCommand("edit matrix"); matrixEditBtn.addActionListener(listener); matrixEditBtn.setAlignmentX(0.5f); matrixBox.add(matrixLabelA); matrixBox.add(matrixLabelC); matrixBox.add(matrixLabelD); matrixBox.add(matrixEditBtn); JPanel distinctBox = new JPanel(); distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS)); distinctBox.setAlignmentX(0.5f); JLabel distinctLabelA = new JLabel("Distinct Terms"); JLabel distinctLabelB = new JLabel("of Address"); distinctLabelA.setAlignmentX(0.5f); distinctLabelB.setAlignmentX(0.5f); JRadioButton yesDistinct = new JRadioButton("Yes"); yesDistinct.setActionCommand("distinct yes"); yesDistinct.addActionListener(listener); JRadioButton noDistinct = new JRadioButton("No"); noDistinct.setActionCommand("distinct no"); noDistinct.addActionListener(listener); yesDistinct.setAlignmentX(0.5f); noDistinct.setAlignmentX(0.5f); if (ctxt.distinctAdrTerms) { yesDistinct.setSelected(true); } else { noDistinct.setSelected(true); } ButtonGroup distinctBtns = new ButtonGroup(); distinctBtns.add(yesDistinct); distinctBtns.add(noDistinct); distinctBox.add(distinctLabelA); distinctBox.add(distinctLabelB); distinctBox.add(yesDistinct); distinctBox.add(noDistinct); /* * NOTE: It should be possible to put all these elements directly into * the ContentPane. But that doesn't work; the layout is truly ugly and * stuff gets stacked on top of other stuff. What works is to put * everything into a JPanel with BoxLayout. Then put the JPanel into * ContentPane. */ JPanel leftCol = new JPanel(); leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS)); leftCol.add(nameFolderBox); leftCol.add(Box.createRigidArea(new Dimension(0, 4))); leftCol.add(populationBox); leftCol.add(Box.createRigidArea(new Dimension(0, 8))); leftCol.add(btnBoxUDPs); leftCol.add(Box.createRigidArea(new Dimension(0, 8))); leftCol.add(domThs); leftCol.add(new JLabel(" ")); JPanel rightCol = new JPanel(); rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS)); rightCol.setBorder( BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "Options")); rightCol.add(Box.createRigidArea(new Dimension(0, 20))); rightCol.add(polyBox); rightCol.add(Box.createRigidArea(new Dimension(0, 20))); rightCol.add(matrixBox); int high = (numUDPs > 0 ? 120 : 20); rightCol.add(Box.createRigidArea(new Dimension(0, high))); rightCol.add(distinctBox); JPanel commentBox = new JPanel(); commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS)); commentBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Notes on this culture:")); JScrollPane commentsPane = new JScrollPane(); comments = new JTextArea(); comments.setColumns(20); comments.setEditable(true); comments.setRows(3); comments.setText(PersonPanel.restoreLineBreaks(ctxt.comments)); comments.getDocument().addDocumentListener(new CommentListener()); commentsPane.setViewportView(comments); commentBox.add(commentsPane); JPanel guts = new JPanel(); // Holds the guts of this window guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS)); guts.add(leftCol); guts.add(Box.createRigidArea(new Dimension(10, 4))); guts.add(rightCol); JPanel wholeThing = new JPanel(); wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS)); wholeThing.add(Box.createRigidArea(new Dimension(0, 4))); wholeThing.add(guts); wholeThing.add(Box.createRigidArea(new Dimension(0, 8))); wholeThing.add(commentBox); wholeThing.add(Box.createRigidArea(new Dimension(0, 4))); getContentPane().add(wholeThing); addInternalFrameListener(this); setSize(600, 620); setVisible(true); } // end of ContextEditor constructor