private void CreateAndDisplayGUI() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); // buildOptionsMenu() needs to come first because it initializes // currTileImg which buildDisplay uses. JPanel buttonArea = buildOptionsMenu(); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS)); JPanel palette = loadTileset(); JComponent display = buildDisplay(); topHalf.add(display); topHalf.add(palette); topHalf.add(new JPanel()); content.add(topHalf); content.add(buttonArea); this.add(content); parentPanel = content; this.pack(); this.setVisible(true); }
/** OptionPaneDemo Constructor */ public OptionPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif"); JPanel demo = getDemoPanel(); demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS)); JPanel bp = new JPanel() { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, super.getMaximumSize().height); } }; bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS)); bp.add(Box.createRigidArea(VGAP30)); bp.add(Box.createRigidArea(VGAP30)); bp.add(createInputDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createWarningDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createMessageDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createComponentDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createConfirmDialogButton()); bp.add(Box.createVerticalGlue()); demo.add(Box.createHorizontalGlue()); demo.add(bp); demo.add(Box.createHorizontalGlue()); }
/** Used to find the global attributes that another inspector has set so I can share it. */ ChartGenerator chartToUse(final String sName, Frame parent, final GUIState simulation) { Bag charts = new Bag(); if (simulation.guiObjects != null) for (int i = 0; i < simulation.guiObjects.numObjs; i++) if (simulation.guiObjects.objs[i] instanceof ChartGenerator && validChartGenerator((ChartGenerator) (simulation.guiObjects.objs[i]))) charts.add(simulation.guiObjects.objs[i]); if (charts.numObjs == 0) return createNewChart(simulation); // init the dialog panel JPanel p = new JPanel(); p.setLayout(new BorderLayout()); String[] chartNames = new String[charts.numObjs + 1]; chartNames[0] = "[Create a New Chart]"; for (int i = 0; i < charts.numObjs; i++) chartNames[i + 1] = ((ChartGenerator) (charts.objs[i])).getTitle(); // add widgets JPanel panel2 = new JPanel(); panel2.setLayout(new BorderLayout()); panel2.setBorder(new javax.swing.border.TitledBorder("Plot on Chart...")); JComboBox encoding = new JComboBox(chartNames); panel2.add(encoding, BorderLayout.CENTER); p.add(panel2, BorderLayout.SOUTH); // ask if (JOptionPane.showConfirmDialog( parent, p, "Create a New Chart...", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) return null; if (encoding.getSelectedIndex() == 0) return createNewChart(simulation); else return (ChartGenerator) (charts.objs[encoding.getSelectedIndex() - 1]); }
private void initUI() { JPanel infoPanel = new JPanel(); infoPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); infoPanel.setBackground(Color.WHITE); infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); infoPanel.add( new JLabel( new ImageIcon( Thread.currentThread().getContextClassLoader().getResource("siw-logo3_2.gif")))); JLabel textLabel = new JLabel("<html>Confirmation</html>"); infoPanel.add(textLabel); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(0, 1)); buttonPanel.add(reportLabel); this.setLayout(new BorderLayout()); this.add(infoPanel, BorderLayout.NORTH); this.add(buttonPanel, BorderLayout.CENTER); }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
public UserPasswordDialog(String title) { super(new JFrame(), title); getContentPane().setLayout(new BorderLayout()); JPanel userPanel = new JPanel(); userPanel.setLayout(new BorderLayout()); userPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); userPanel.add("West", userLabel); userPanel.add("Center", userField); JPanel passwordPanel = new JPanel(); passwordPanel.setLayout(new BorderLayout()); passwordPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); passwordPanel.add("West", passwordLabel); passwordPanel.add("Center", passwordField); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); buttonPanel.add("West", okButton); buttonPanel.add("East", cancelButton); okButton.addActionListener(this); cancelButton.addActionListener(this); getContentPane().add("North", userPanel); getContentPane().add("Center", passwordPanel); getContentPane().add("South", buttonPanel); pack(); }
public CombatViewer() { super("Combat Tracker"); setLookAndFeel(); setSize(500, 400); FlowLayout layout = new FlowLayout(FlowLayout.CENTER, 10, 10); setLayout(layout); String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; Object[][] data = { {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)}, {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)}, {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)}, {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)}, {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)} }; JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); panel1.setLayout(new BorderLayout()); panel1.add(table.getTableHeader(), BorderLayout.PAGE_START); panel1.add(table, BorderLayout.CENTER); add(panel1); panel2.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); panel2.add(testBox); add(panel2); setVisible(true); }
/** * Sets the panel in which the GUI should be implemented Any standard swing components can be used * * @param panel The GUI panel */ public void setPanel(JPanel panel) { this.panel = panel; panel.setLayout(new BorderLayout()); JLabel label = new JLabel("Produces an effect similar to thermal erosion", (int) JLabel.CENTER_ALIGNMENT); panel.add(label, BorderLayout.PAGE_START); JPanel iterations = new JPanel(); iterations.setLayout(new FlowLayout()); label = new JLabel("Iterations "); iterations.add(label); sldIterations = new JSlider(1, 100, 1); sldIterations.addChangeListener(this); iterations.add(sldIterations); txtIterations = new JTextField(Integer.toString((int) sldIterations.getValue())); txtIterations.setEditable(false); txtIterations.setPreferredSize(new Dimension(35, 25)); iterations.add(txtIterations); panel.add(iterations, BorderLayout.CENTER); btnApply = new JButton("Apply Thermal Erosion"); btnApply.addActionListener(this); panel.add(btnApply, BorderLayout.PAGE_END); if (preview) parent.refreshMiniView(apply(preview)); }
private static void badFetch() { final JFrame frame = new JFrame("TestFetchWebGui"); final JPanel outerPanel = new JPanel(), buttonPanel = new JPanel(); final JButton fetchButton = new JButton("Fetch"), cancelButton = new JButton("Cancel"); frame.add(outerPanel); outerPanel.setLayout(new BorderLayout()); buttonPanel.setLayout(new GridLayout(2, 1)); buttonPanel.add(fetchButton); buttonPanel.add(cancelButton); outerPanel.add(buttonPanel, BorderLayout.EAST); final TextArea textArea = new TextArea(25, 80); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); outerPanel.add(textArea, BorderLayout.WEST); fetchButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { for (String url : urls) { System.out.println("Fetching " + url); String page = getPage(url, 200); textArea.append(String.format("%-40s%7d%n", url, page.length())); } } }); frame.pack(); frame.setVisible(true); }
/** * Create the top panel, containing the fields with the performance data. * * @return The top panel. */ public JComponent createTopPanel() { String[] texts = new String[NBR_FIELDS]; texts[MOVIE_NAME] = "Movie"; texts[PERF_DATE] = "Date"; texts[THEATER_NAME] = "Plays at"; texts[FREE_SEATS] = "Free seats"; fields = new JTextField[NBR_FIELDS]; for (int i = 0; i < fields.length; i++) { fields[i] = new JTextField(20); fields[i].setEditable(false); } JPanel input = new InputPanel(texts, fields); JPanel p1 = new JPanel(); p1.setLayout(new FlowLayout(FlowLayout.LEFT)); p1.add(new JLabel("Current user: "******""); p1.add(currentUserNameLabel); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(p1); p.add(input); return p; }
private void jbInit() throws Exception { border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20); contentPane.setBorder(border1); contentPane.setLayout(borderLayout1); controlsPane.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setHgap(10); gridLayout1.setRows(0); gridLayout1.setVgap(10); okButton.setVerifyInputWhenFocusTarget(true); okButton.setMnemonic('O'); okButton.setText("OK"); buttonsPane.setLayout(flowLayout1); flowLayout1.setAlignment(FlowLayout.CENTER); messagePane.setEditable(false); messagePane.setText(""); borderLayout1.setHgap(10); borderLayout1.setVgap(10); this.setTitle("Subscription Authorization"); this.getContentPane().add(contentPane, BorderLayout.CENTER); contentPane.add(controlsPane, BorderLayout.SOUTH); controlsPane.add(responsesComboBox, null); controlsPane.add(buttonsPane, null); buttonsPane.add(okButton, null); contentPane.add(messageScrollPane, BorderLayout.CENTER); messageScrollPane.getViewport().add(messagePane, null); }
private void jbInit() throws Exception { box1 = Box.createVerticalBox(); this.getContentPane().setLayout(borderLayout1); close.setText("Close"); close.addActionListener(new CellHelpWindow_close_actionAdapter(this)); jLabel1.setText("Recommendation"); jLabel2.setText("Description"); jPanel1.setLayout(borderLayout2); jPanel2.setLayout(borderLayout3); description.setText("jTextPane1"); description.setContentType("text/html"); scp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scp1.setToolTipText(""); recom.setText(""); recom.setContentType("text/html"); this.getContentPane().add(box1, BorderLayout.CENTER); box1.add(jPanel1, null); box1.add(jPanel2, null); this.getContentPane().add(jPanel3, BorderLayout.SOUTH); jPanel3.add(close, null); jPanel2.add(jLabel1, BorderLayout.NORTH); jPanel2.add(scp2, BorderLayout.CENTER); scp2.getViewport().add(recom, null); jPanel2.add(scp2, BorderLayout.CENTER); jPanel1.add(jLabel2, BorderLayout.NORTH); jPanel1.add(scp1, BorderLayout.CENTER); scp1.getViewport().add(description, null); }
/** * Component initialization. * * @throws java.lang.Exception */ private void jbInit() throws Exception { image1 = new ImageIcon(pt.inescporto.siasoft.MenuFrame.class.getResource("about.png")); imageLabel.setIcon(image1); setTitle("About"); panel1.setLayout(borderLayout1); panel2.setLayout(borderLayout2); insetsPanel1.setLayout(flowLayout1); insetsPanel2.setLayout(flowLayout1); insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); gridLayout1.setRows(4); gridLayout1.setColumns(1); label1.setText(product); label2.setText(version); label3.setText(copyright); label4.setText(comments); insetsPanel3.setLayout(gridLayout1); insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60, 10, 10)); button1.setText("OK"); button1.addActionListener(this); insetsPanel2.add(imageLabel, null); panel2.add(insetsPanel2, BorderLayout.WEST); getContentPane().add(panel1, null); insetsPanel3.add(label1, null); insetsPanel3.add(label2, null); insetsPanel3.add(label3, null); insetsPanel3.add(label4, null); panel2.add(insetsPanel3, BorderLayout.CENTER); insetsPanel1.add(button1, null); panel1.add(insetsPanel1, BorderLayout.SOUTH); panel1.add(panel2, BorderLayout.NORTH); setResizable(true); }
private void initGUI() { JPanel pCommand = new JPanel(); pResult = new JPanel(); nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new JTextArea(5, 40); txtCommand.setMargin(new Insets(5, 5, 5, 5)); txtCommand.addKeyListener(this); txtCommandScroll = new JScrollPane(txtCommand); txtResult = new JTextArea(20, 40); txtResult.setMargin(new Insets(5, 5, 5, 5)); txtResultScroll = new JScrollPane(txtResult); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); /* // button replaced by toolbar butExecute = new JButton("Execute"); butExecute.addActionListener(this); pCommand.add(butExecute, BorderLayout.EAST); */ pCommand.add(txtCommandScroll, BorderLayout.CENTER); gResult = new GridSwing(); gResultTable = new JTable(gResult); gScrollPane = new JScrollPane(gResultTable); // getContentPane().setLayout(new BorderLayout()); pResult.add(gScrollPane, BorderLayout.CENTER); // Set up the tree rootNode = new DefaultMutableTreeNode("Connection"); treeModel = new DefaultTreeModel(rootNode); tTree = new JTree(treeModel); tScrollPane = new JScrollPane(tTree); tScrollPane.setPreferredSize(new Dimension(120, 400)); tScrollPane.setMinimumSize(new Dimension(70, 100)); txtCommandScroll.setPreferredSize(new Dimension(360, 100)); txtCommandScroll.setMinimumSize(new Dimension(180, 100)); gScrollPane.setPreferredSize(new Dimension(460, 300)); ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane); fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER); doLayout(); fMain.pack(); }
public AddNewStudent() // constructor { // initializing buttons btnok = new JButton("OK"); btnok.addActionListener(this); btnexit = new JButton("Exit"); btnexit.addActionListener(this); btnaddnew = new JButton("AddNew"); btnaddnew.addActionListener(this); // initializing textfields tf1 = new JTextField(12); tf2 = new JTextField(12); // initializing labels lblname = new JLabel("Name:"); lbladd = new JLabel("Address:"); lblmsg = new JLabel("", JLabel.CENTER); // initializing panels p1 = new JPanel(); p2 = new JPanel(); p3 = new JPanel(); psouth = new JPanel(); // adding buttons and label to panel p1 // setting flowlayout p1.setLayout(new FlowLayout()); p1.add(btnok); p1.add(btnexit); p1.add(btnaddnew); // adding lblmsg to panel p3 p3.add(lblmsg); // adding both the panels to new panel,psouth // settin layout 2:1 psouth.setLayout(new GridLayout(2, 1)); psouth.add(p3); psouth.add(p1); // adding label and textfields to panel p2 p2.setLayout(new GridLayout(3, 1)); // setting line and titled border for panel p2 p2.setBorder(BorderFactory.createLineBorder(Color.red)); p2.setBorder(BorderFactory.createTitledBorder("Enter Your Details")); p2.add(lblname); p2.add(tf1); p2.add(lbladd); p2.add(tf2); // adding panel to container this.getContentPane().add(p2, "Center"); this.getContentPane().add(psouth, "South"); this.setSize(300, 300); this.setLocation(100, 200); this.show(); }
public CopyFileToTable() { JPanel jPane1 = new JPanel(); jPane1.setLayout(new BorderLayout()); jPane1.add(new JLabel("Filename"), BorderLayout.WEST); jPane1.add(jbtViewFile, BorderLayout.EAST); jPane1.add(jtfFilename, BorderLayout.CENTER); JPanel jPane2 = new JPanel(); jPane2.setLayout(new BorderLayout()); jPane2.setBorder(new TitledBorder("Source Text File")); jPane2.add(jPane1, BorderLayout.NORTH); jPane2.add(new JScrollPane(jtaFile), BorderLayout.CENTER); JPanel jPane3 = new JPanel(); jPane3.setLayout(new GridLayout(5, 0)); jPane3.add(new JLabel("JDBC Driver")); jPane3.add(new JLabel("Database URL")); jPane3.add(new JLabel("Username")); jPane3.add(new JLabel("Password")); jPane3.add(new JLabel("Table Name")); JPanel jPane4 = new JPanel(); jPane4.setLayout(new GridLayout(5, 0)); jcboDriver.setEditable(true); jPane4.add(jcboDriver); jcboURL.setEditable(true); jPane4.add(jcboURL); jPane4.add(jtfUsername); jPane4.add(jtfPassword); jPane4.add(jtfTableName); JPanel jPane5 = new JPanel(); jPane5.setLayout(new BorderLayout()); jPane5.setBorder(new TitledBorder("Target Database Table")); jPane5.add(jbtCopy, BorderLayout.SOUTH); jPane5.add(jPane3, BorderLayout.WEST); jPane5.add(jPane4, BorderLayout.CENTER); add(jlblStatus, BorderLayout.SOUTH); add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPane2, jPane5), BorderLayout.CENTER); jbtViewFile.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { showFile(); } }); jbtCopy.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { copyFile(); } catch (Exception ex) { jlblStatus.setText(ex.toString()); } } }); }
// Constructor public FileWindow() { myWindow = new JFrame("New File"); myWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Container contentPane = myWindow.getContentPane(); contentPane.setLayout(new BorderLayout()); saveButton = new JButton("Save File"); saveButton.setSelected(false); saveButton.setActionCommand("save"); saveButton.setMnemonic('S'); // saveButton.addActionListener(new ScriptWindowButtonListener()); clearButton = new JButton("Clear Contents"); clearButton.setSelected(false); clearButton.setActionCommand("clear"); clearButton.setMnemonic('B'); clearButton.addActionListener(new ScriptWindowButtonListener()); cancelButton = new JButton("Quit"); cancelButton.setSelected(false); cancelButton.setActionCommand("quit"); cancelButton.setMnemonic('Q'); cancelButton.addActionListener(new ScriptWindowButtonListener()); // loadButton = new JButton("Load Script"); // loadButton.setSelected(false); // loadButton.setActionCommand("load"); // loadButton.setMnemonic('L'); // loadButton.addActionListener(new ScriptWindowButtonListener()); // // runButton = new JButton("Run Script"); // runButton.setSelected(false); // runButton.setActionCommand("run"); // runButton.setMnemonic('L'); // runButton.addActionListener(new ScriptWindowButtonListener()); buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(1, 0)); // buttonPanel.add(runButton); buttonPanel.add(saveButton); // buttonPanel.add(loadButton); buttonPanel.add(clearButton); // buttonPanel.add(cancelButton); fileChooser = new JFileChooser(); scriptArea = new JTextArea(35, 30); JScrollPane scroller = new JScrollPane(scriptArea); textHolder = new JPanel(); textHolder.setLayout(new BorderLayout()); textHolder.add(scroller, BorderLayout.CENTER); contentPane.add(buttonPanel, BorderLayout.NORTH); contentPane.add(textHolder, BorderLayout.CENTER); myWindow.pack(); }
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 GuiYahtzee() { final Match m = new Match(); final JFrame f = new JFrame(); JPanel titles = new JPanel(); JPanel cheatok = new JPanel(); titles.setLayout(new BorderLayout()); JLabel maintitle = new JLabel("Yahtzee World!\nPlayer Details..."); maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24)); JLabel instr = new JLabel("Type the name of each player (1 to " + Match.MAXPLAYERS + " players)"); instr.setFont(new Font("SansSerif", Font.PLAIN, 16)); titles.add(maintitle, "North"); titles.add(instr, "South"); JPanel names = new JPanel(); JLabel l[] = new JLabel[Match.MAXPLAYERS]; final JTextField t[] = new JTextField[Match.MAXPLAYERS]; names.setLayout(new GridLayout(Match.MAXPLAYERS, 2)); for (int player = 0; player < Match.MAXPLAYERS; player++) { l[player] = new JLabel("Player " + (player + 1) + " name"); t[player] = new JTextField(20); names.add(l[player]); names.add(t[player]); } cheatok.setLayout(new BorderLayout()); final JCheckBox cheat = new JCheckBox("Cheat", false); JButton ok = new JButton("OK"); ok.addActionListener( new ActionListener() { // This method is called when the user clicks the JButton public void actionPerformed(ActionEvent e) { String name = ""; for (int player = 0; player < Match.MAXPLAYERS; player++) { name = t[player].getText(); if (name.length() != 0) m.addPlayer(name); } if (m.getNumPlayers() == 0) { m.addPlayer("DUMMY"); System.out.println("No named players. Inventing one called `DUMMY'"); } GuiYahtzee me = new GuiYahtzee(m, cheat.isSelected()); f.dispose(); } }); cheatok.add(cheat, "West"); cheatok.add(ok, "East"); f.add(titles, "North"); f.add(names, "Center"); f.add(cheatok, "South"); f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); f.setResizable(false); }
public LicenseDialog(Component parent) { setTitle("Licensing information"); pnlButtons.add(bttnOk); cbLang.addItem("English"); cbLang.addItem("Eesti"); FlowLayout fl = new FlowLayout(); fl.setAlignment(FlowLayout.LEFT); pnlHeader.setLayout(fl); pnlHeader.add(lblLang); pnlHeader.add(cbLang); pnlMain.setLayout(new BorderLayout()); pnlMain.add(pnlHeader, BorderLayout.NORTH); pnlMain.add(scrollPane, BorderLayout.CENTER); pnlMain.add(pnlButtons, BorderLayout.SOUTH); taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); taLicenseText.setLineWrap(true); taLicenseText.setEditable(false); taLicenseText.setWrapStyleWord(true); getContentPane().add(pnlMain); setPreferredSize(new Dimension(500, 600)); setLocationRelativeTo(parent); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); bttnOk.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { if (evt.getSource() == bttnOk) { dispose(); } } // end actionPerformed }); // end bttnOk Action Listener cbLang.addItemListener( new ItemListener() { public void itemStateChanged(final ItemEvent event) { if (event.getSource() == cbLang && event.getStateChange() == ItemEvent.SELECTED && cbLang.getItemCount() > 0) { taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); } } }); // end cbLang item listener pack(); setVisible(true); } // PortPropertiesDialog
private void initComponents() { final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT); panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel north = new JPanel(); north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS)); JLabel dateLbl = new JLabel("検査日:"); north.add(dateLbl); dateFld = new JTextField(10); dateFld.setMaximumSize(dateFld.getPreferredSize()); dateFld.setEditable(false); dateFld.setText(dateFrmt.format(new Date())); north.add(dateFld); north.add(Box.createHorizontalGlue()); editCheck = new JCheckBox("項目編集"); north.add(editCheck); panel.add(north, BorderLayout.NORTH); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); deleteBtn = new JButton("削除", deleteIcon); deleteBtn.setEnabled(false); south.add(deleteBtn); closeBtn = new JButton("閉じる", closeIcon); south.add(closeBtn); saveBtn = new JButton("保存", saveIcon); south.add(saveBtn); panel.add(south, BorderLayout.SOUTH); setTable = new JTable(); JScrollPane scroll = new JScrollPane(setTable); centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS)); centerPanel.add(scroll); panel.add(centerPanel, BorderLayout.CENTER); templateTable = new JTable(); templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。"); rtScroll = new JScrollPane(templateTable); Dimension d = new Dimension(200, 200); rtScroll.setPreferredSize(d); d = new Dimension(200, Integer.MAX_VALUE); rtScroll.setMaximumSize(d); dialog = new JDialog(); String title = ClientContext.getFrameTitle("院内検査項目追加"); dialog.setTitle(title); dialog.setModal(true); dialog.setContentPane(panel); ClientContext.setDolphinIcon(dialog); dialog.pack(); dialog.setLocationRelativeTo(chart.getFrame()); }
public void start() { frame = new JFrame("Multiple Components"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new BorderLayout()); // Label for instructions label = new JLabel("Use the buttons to control the layout of text"); contentPane.add(label, BorderLayout.NORTH); // West panel westpanel = new JPanel(); westpanel.setLayout(new BoxLayout(westpanel, BoxLayout.Y_AXIS)); buttonwrap = new JButton("Wrap Text "); buttonwrap.addActionListener(this); westpanel.add(buttonwrap); buttonDoNotWrap = new JButton("Do Not Wrap Text"); buttonDoNotWrap.addActionListener(this); westpanel.add(buttonDoNotWrap); buttonBlank = new JButton(" "); buttonBlank.addActionListener(this); westpanel.add(buttonBlank); buttonClearText = new JButton("Clear Text "); buttonClearText.addActionListener(this); westpanel.add(buttonClearText); contentPane.add(westpanel, BorderLayout.WEST); // Text area textArea = new JTextArea(10, 25); scrollArea = new JScrollPane(textArea); contentPane.add(scrollArea, BorderLayout.CENTER); // East panel to control scroll bars eastpanel = new JPanel(); eastpanel.setLayout(new BoxLayout(eastpanel, BoxLayout.Y_AXIS)); buttonScrollV = new JButton("Scroll Vertically"); buttonScrollV.addActionListener(this); eastpanel.add(buttonScrollV); buttonScrollH = new JButton("Scroll Horizontally"); buttonScrollH.addActionListener(this); eastpanel.add(buttonScrollH); buttonScrollBothWays = new JButton("Scroll Both Ways"); buttonScrollBothWays.addActionListener(this); eastpanel.add(buttonScrollBothWays); buttonDoNotScroll = new JButton("Do Not Scroll"); buttonDoNotScroll.addActionListener(this); eastpanel.add(buttonDoNotScroll); contentPane.add(eastpanel, BorderLayout.EAST); frame.pack(); frame.setVisible(true); }
private void initUI() { this.setLayout(new BorderLayout()); JPanel infoPanel = new JPanel(); infoPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); infoPanel.setBackground(Color.WHITE); infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); infoPanel.add( new JLabel( new ImageIcon( Thread.currentThread().getContextClassLoader().getResource("siw-logo3_2.gif")))); JLabel infoLabel = new JLabel("<html>Please select a project and context<br> Version must be a number</html>"); infoPanel.add(infoLabel); this.add(infoPanel, BorderLayout.NORTH); JPanel entryPanel = new JPanel(); entryPanel.setLayout(null); projectNameField.setText(""); JLabel projectNameLabel = new JLabel("Project Name"); projectNameLabel.setBounds(new Rectangle(30, 80, 135, 20)); projectNameField.setBounds(new Rectangle(180, 80, 175, 20)); JLabel projectVersionLabel = new JLabel("Project Version"); projectVersionLabel.setBounds(new Rectangle(30, 125, 135, 20)); projectVersionField.setBounds(new Rectangle(180, 125, 175, 20)); JLabel contextLabel = new JLabel("Context"); contextLabel.setBounds(new Rectangle(30, 165, 135, 20)); contextComboBox.setBounds(new Rectangle(180, 165, 175, 20)); JLabel packageLabel = new JLabel("Select Package"); packageLabel.setBounds(new Rectangle(30, 210, 135, 20)); packageComboBox.setBounds(new Rectangle(180, 210, 250, 20)); entryPanel.add(projectNameLabel, null); entryPanel.add(projectNameField, null); entryPanel.add(projectVersionLabel, null); entryPanel.add(projectVersionField, null); entryPanel.add(contextLabel, null); entryPanel.add(contextComboBox, null); entryPanel.add(packageLabel, null); entryPanel.add(packageComboBox, null); this.add(entryPanel, BorderLayout.CENTER); projectVersionField.addKeyListener(this); projectNameField.addKeyListener(this); }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
public HandyDialog(JFrame parent, String title, boolean modal) { super(parent, title, modal); this.parent = parent; this.getContentPane().setLayout(new BorderLayout(15, 15)); this.messagePanel = new JPanel(); messagePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15)); this.getContentPane().add(BorderLayout.CENTER, messagePanel); this.buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15)); this.getContentPane().add(BorderLayout.SOUTH, buttonPanel); }
private void final_scores(Match m) { int numPlayers = 0; int playerTotal = 0; int gameNum = 0, maxGameNum = 0; Player p; // Create window final JFrame f = new JFrame(); JPanel titles = new JPanel(); titles.setLayout(new BorderLayout()); JLabel maintitle = new JLabel("Yahtzee World!"); maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24)); JLabel instr = new JLabel("Final Scores (total of game scores)."); instr.setFont(new Font("SansSerif", Font.PLAIN, 16)); titles.add(maintitle, "North"); titles.add(instr, "South"); JPanel names = new JPanel(); JLabel l[] = new JLabel[Match.MAXPLAYERS]; final JTextField t[] = new JTextField[Match.MAXPLAYERS]; numPlayers = m.getNumPlayers(); names.setLayout(new GridLayout(numPlayers, 2)); for (int playerNum = 0; playerNum < numPlayers; playerNum++) { p = m.getPlayer(playerNum); playerTotal = 0; l[playerNum] = new JLabel(p.getName()); t[playerNum] = new JTextField(20); names.add(l[playerNum]); names.add(t[playerNum]); maxGameNum = (m.getGameNum() >= Match.MAXGAMES) ? (Match.MAXGAMES - 1) : m.getGameNum(); for (gameNum = 0; gameNum <= maxGameNum; gameNum++) { playerTotal += p.getScoreCell(gameNum, CellCodes.GRANDTOTAL); } t[playerNum].setText(String.valueOf(playerTotal)); } JButton quit = new JButton("Quit"); quit.addActionListener( new ActionListener() { // This method is called when the user clicks the JButton public void actionPerformed(ActionEvent e) { System.exit(0); } }); f.add(titles, "North"); f.add(names, "Center"); f.add(quit, "South"); f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); f.setResizable(false); }
/** Constructs a panel containing an options menu, then returns said panel. */ public JPanel buildOptionsMenu() { JPanel options = new JPanel(); // Create the height/width section JPanel dimensions = new JPanel(); dimensions.setLayout(new BoxLayout(dimensions, BoxLayout.Y_AXIS)); JLabel widthLabel = new JLabel("X:"); JTextField widthBox = new JTextField(10); widthField = widthBox; JPanel width = new JPanel(); width.add(widthLabel); width.add(widthBox); JLabel heightLabel = new JLabel("Y:"); JTextField heightBox = new JTextField(10); heightField = heightBox; JPanel height = new JPanel(); height.add(heightLabel); height.add(heightBox); dimensions.add(width); dimensions.add(height); // "Apply changes" button JButton apply = new JButton("Apply Changes"); apply.addActionListener(new ApplyHWChanges()); // Fill option JButton fill = new JButton("Fill with current tile"); fill.addActionListener(new FillButton()); options.add(fill); // Current selected tile JPanel tileArea = new JPanel(); tileArea.setLayout(new BoxLayout(tileArea, BoxLayout.Y_AXIS)); tileArea.add(new JLabel("Current Tile")); tileArea.add(currTileDisplay); // remove once testing is done backEnd.setTestImage(currTileImg); // Save button JButton save = new JButton("Save"); save.addActionListener(new SaveButton()); options.add(dimensions); options.add(apply); options.add(tileArea); options.add(save); return options; }
void run() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(10, 50, 400, 400); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(menuBar(), BorderLayout.NORTH); panel.add(responseArea(), BorderLayout.CENTER); panel.add(inputField(), BorderLayout.SOUTH); this.add(panel); setVisible(true); }
public void createLayout() { JPanel textFieldSubPanel = new JPanel(); textFieldSubPanel.setLayout(new BoxLayout(textFieldSubPanel, BoxLayout.Y_AXIS)); textFieldSubPanel.add((JLabel) component[LABEL]); textFieldSubPanel.add((JTextField) component[TEXT_FIELD]); panel.setLayout(new BorderLayout()); panel.add("North", textFieldSubPanel); panel.add("Center", (JComponent) component[TABBED_PANE]); panel.add("South", (JPanel) component[BUTTONS]); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }