public void buildPopulationBox() { rebuilding = true; populationBox.removeAll(); peopleList = new ArrayList<Object>(); famList = new ArrayList<Family>(); peopleList.addAll(ctxt.individualCensus); String plur = (peopleList.size() == 1 ? "" : "s"); populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS)); populationBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Current Population")); populationBox.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(8, 0))); indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur); indivLabel.setAlignmentX(0.5f); populationBox.add(indivLabel); if (peopleList.size() > 0) { JPanel indivBtnBox = new JPanel(); indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] indMenu = genIndMenu(peopleList); indPick = new JComboBox(indMenu); indPick.addActionListener(listener); indPick.setActionCommand("view/edit person"); indPick.setMinimumSize(sizer2); indPick.setMaximumSize(sizer2); indPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Person")); indivBtnBox.add(indPick); populationBox.add(indivBtnBox); } // end of if-any-people-exist famList.addAll(ctxt.familyCensus); // end of filtering deleted records plur = (famList.size() == 1 ? "y" : "ies"); famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur); famLabel.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(0, 4))); populationBox.add(famLabel); if (famList.size() > 0) { JPanel famBtnBox = new JPanel(); famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] famMenu = genFamMenu(famList); famPick = new JComboBox(famMenu); famPick.addActionListener(listener); famPick.setActionCommand("view/edit family"); famPick.setMinimumSize(sizer2); famPick.setMaximumSize(sizer2); famPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Family")); famBtnBox.add(famPick); populationBox.add(famBtnBox); } // end of if-any-families-exist rebuilding = false; } // end of method buildPopulationBox
public BadKitPanel(KitAssemblyApp _app) { app = _app; setLayout(new GridBagLayout()); c = new GridBagConstraints(); label = new JLabel(); sendButton = new JButton("Send Kit Non-Norm"); sendButton.addActionListener(this); toggleDropParts = new JButton("Enable Parts Robot Drop Parts"); toggleDropParts.addActionListener(this); titleLabel = new JLabel("Kit Assembly Non-Normatives"); titleLabel.setFont(new Font("Verdana", Font.BOLD, 16)); titleLabel.setPreferredSize(new Dimension(300, 25)); titleLabel.setMaximumSize(new Dimension(300, 25)); titleLabel.setMinimumSize(new Dimension(300, 25)); titleLabel.setAlignmentX(CENTER_ALIGNMENT); Kit temp = new Kit(); temp.setID("Bad Kit to Make"); for (int j = 0; j < 8; j++) { temp.addPart(new Part(new PartInfo(null, "images/good.png"))); } badKit = new BadKit(temp); label = new JLabel(temp.getID()); sent = new JLabel(""); sent.setPreferredSize(new Dimension(230, 25)); sent.setMaximumSize(new Dimension(230, 25)); sent.setMinimumSize(new Dimension(230, 25)); sent.setAlignmentX(CENTER_ALIGNMENT); c.gridx = 0; c.gridy = 0; add(titleLabel, c); c.gridy = 1; add(badKit, c); c.gridy = 2; c.insets = new Insets(10, 0, 0, 0); add(sendButton, c); c.gridy = 3; add(toggleDropParts, c); c.gridy = 4; add(sent, c); }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
void addTextArea(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextArea field = new JTextArea(); field.setText(sketch.configFile.get(key)); field.setLineWrap(true); field.setWrapStyleWord(true); fields.put(key, field); JScrollPane scroll = new JScrollPane(field); scroll.setAlignmentX(0.0f); panel.add(scroll); }
public final void initUI() throws FileNotFoundException, IOException { String FileName = "config.txt"; String DirSeparator = System.getProperty("file.separator"); File currentDir = new File("."); String FilePath = currentDir.getCanonicalPath() + DirSeparator + FileName; myProperties = new Properties(); myProperties.load(new FileInputStream(FilePath)); setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); add(Box.createRigidArea(new Dimension(0, 10))); JLabel label = new JLabel(); label.setAlignmentX(0.5f); add(label); add(Box.createRigidArea(new Dimension(0, 10))); String result = myProperties.getProperty("1"); if (result == null) result = "0"; JLabel name = new JLabel("Level 1: " + result); name.setFont(new Font("Serif", Font.BOLD, 13)); name.setAlignmentX(0.5f); add(name); result = myProperties.getProperty("2"); if (result == null) result = "0"; name = new JLabel("Level 2: " + result); name.setFont(new Font("Serif", Font.BOLD, 13)); name.setAlignmentX(0.5f); add(name); result = myProperties.getProperty("3"); if (result == null) result = "0"; name = new JLabel("Level 3: " + result); name.setFont(new Font("Serif", Font.BOLD, 13)); name.setAlignmentX(0.5f); add(name); result = myProperties.getProperty("4"); if (result == null) result = "0"; name = new JLabel("Level 4: " + result); name.setFont(new Font("Serif", Font.BOLD, 13)); name.setAlignmentX(0.5f); add(name); result = myProperties.getProperty("5"); if (result == null) result = "0"; name = new JLabel("Level 5: " + result); name.setFont(new Font("Serif", Font.BOLD, 13)); name.setAlignmentX(0.5f); add(name); myProperties = null; add(Box.createRigidArea(new Dimension(0, 50))); JButton close = new JButton("Close"); close.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); close.setAlignmentX(0.5f); add(close); setModalityType(ModalityType.APPLICATION_MODAL); setTitle("Table of records"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLocationRelativeTo(null); setSize(300, 200); }
public DownloadPictures(ArrayList<CardDownloadData> cards) { this.cards = cards; bar = new JProgressBar(this); JPanel p0 = new JPanel(); p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS)); p0.add(Box.createVerticalStrut(5)); jLabel1 = new JLabel(); jLabel1.setText("Please select server:"); jLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); p0.add(jLabel1); p0.add(Box.createVerticalStrut(5)); ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { "magiccards.info", "wizards.com", "mtgimage.com (HQ)" /*, "mtgathering.ru HQ", "mtgathering.ru MQ", "mtgathering.ru LQ"*/ }); jComboBox1 = new JComboBox(); cardImageSource = MagicCardsImageSource.getInstance(); jComboBox1.setModel(jComboBox1Model); jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT); jComboBox1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); switch (cb.getSelectedIndex()) { case 0: cardImageSource = MagicCardsImageSource.getInstance(); break; case 1: cardImageSource = WizardCardsImageSource.getInstance(); break; case 2: cardImageSource = MtgImageSource.getInstance(); break; } int count = DownloadPictures.this.cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); p0.add(jComboBox1); p0.add(Box.createVerticalStrut(5)); // Start startDownloadButton = new JButton("Start download"); startDownloadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread(DownloadPictures.this).start(); startDownloadButton.setEnabled(false); checkBox.setEnabled(false); } }); p0.add(Box.createVerticalStrut(5)); // Progress p0.add(bar); bar.setStringPainted(true); int count = cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == cards.size() ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, cards.size(), mb)); Dimension d = bar.getPreferredSize(); d.width = 300; bar.setPreferredSize(d); p0.add(Box.createVerticalStrut(5)); checkBox = new JCheckBox("Download images for Standard (Type2) only"); p0.add(checkBox); p0.add(Box.createVerticalStrut(5)); checkBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<CardDownloadData> cardsToDownload = DownloadPictures.this.cards; if (checkBox.isSelected()) { DownloadPictures.this.type2cards = new ArrayList<>(); for (CardDownloadData data : DownloadPictures.this.cards) { if (data.isType2() || data.isToken()) { DownloadPictures.this.type2cards.add(data); } } cardsToDownload = DownloadPictures.this.type2cards; } int count = cardsToDownload.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); // JOptionPane Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")}; dlg = new JOptionPane( p0, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); }
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