private void initialize() { setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); getTeamNameLabel().setAlignmentX(Component.LEFT_ALIGNMENT); add(getTeamNameLabel()); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setAlignmentX(Component.LEFT_ALIGNMENT); getTeamNameField().setAlignmentX(Component.LEFT_ALIGNMENT); getTeamNameField().setMaximumSize(getTeamNameField().getPreferredSize()); // getVersionField().setMaximumSize(getVersionField().getPreferredSize()); p.setMaximumSize( new Dimension(Integer.MAX_VALUE, getTeamNameField().getPreferredSize().height)); p.add(getTeamPackageLabel()); p.add(getTeamNameField()); add(p); JLabel label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getDescriptionLabel()); JScrollPane scrollPane = new JScrollPane( getDescriptionArea(), ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setMaximumSize(scrollPane.getPreferredSize()); scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height)); scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); add(scrollPane); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getAuthorLabel()); getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT); getAuthorField().setMaximumSize(getAuthorField().getPreferredSize()); add(getAuthorField()); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getWebpageLabel()); getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT); getWebpageField().setMaximumSize(getWebpageField().getPreferredSize()); add(getWebpageField()); getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT); add(getWebpageHelpLabel()); JPanel panel = new JPanel(); panel.setAlignmentX(Component.LEFT_ALIGNMENT); add(panel); addComponentListener(eventHandler); }
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); } // constructor
public DateTimeView(DateTime time) { super(); this.time = time; Font f = new Font("Monospaced", Font.BOLD, 13); Color c = new Color(44, 68, 152); month = new JLabel(strMonth(time.getMonthOfYear())); month.setFont(f); month.setForeground(c); year = new JLabel("" + time.getYear()); year.setFont(f); year.setForeground(c); day = new JLabel("" + time.getDayOfMonth()); day.setFont(new Font("Calibri", Font.BOLD, 26)); day.setForeground(new Color(126, 148, 227)); t = new JLabel(formatTime(time.getHourOfDay(), time.getMinuteOfHour())); t.setFont(f); t.setForeground(c); JPanel topPanel = new JPanel(); topPanel.setLayout(new FlowLayout()); topPanel.add(month); topPanel.add(year); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); topPanel.setAlignmentX(Component.CENTER_ALIGNMENT); this.add(topPanel); this.add(Box.createVerticalStrut(3)); day.setAlignmentX(Component.CENTER_ALIGNMENT); this.add(day); t.setAlignmentX(Component.CENTER_ALIGNMENT); this.add(Box.createVerticalStrut(3)); this.add(t); this.setBorder(BorderFactory.createRaisedBevelBorder()); }
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 FindProf() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Search your campus!"); JLabel patternLabel2 = new JLabel(""); patternList = new JComboBox<Object>(searchNames); patternList.setEditable(true); patternList.setMaximumRowCount(5); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setHorizontalAlignment(SwingConstants.CENTER); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } // constructor
@Override protected JComponent createCenterPanel() { JPanel north = new JPanel(); north.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)); final JPanel namePanel = createNamePanel(); namePanel.setAlignmentX(Component.LEFT_ALIGNMENT); north.add(namePanel); createCheckBoxes(north); myGetterPanel = createFieldPanel(); myGetterPanel.setAlignmentX(Component.LEFT_ALIGNMENT); north.add(myGetterPanel); final JPanel root = new JPanel(new BorderLayout()); mySignaturePanel = createSignaturePanel(); root.add(mySignaturePanel, BorderLayout.CENTER); root.add(north, BorderLayout.NORTH); return root; }
// type 'java Parallel' to run this application public static void main(String args[]) throws VisADException, RemoteException, IOException { RealType index = RealType.getRealType("index"); RealType[] coords = new RealType[NCOORDS]; for (int i = 0; i < NCOORDS; i++) { coords[i] = RealType.getRealType("coord" + i); } RealTupleType range = new RealTupleType(coords); FunctionType ftype = new FunctionType(index, range); Integer1DSet index_set = new Integer1DSet(NROWS); float[][] samples = new float[NCOORDS][NROWS]; for (int i = 0; i < NCOORDS; i++) { for (int j = 0; j < NROWS; j++) { samples[i][j] = (float) Math.random(); } } FlatField data = new FlatField(ftype, index_set); data.setSamples(samples, false); // create a 2-D Display using Java3D DisplayImpl display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D()); parallel(display, data); // create JFrame (i.e., a window) for display and slider JFrame frame = new JFrame("Parallel Coordinates VisAD Application"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // create JPanel in JFrame JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentY(JPanel.TOP_ALIGNMENT); panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); frame.getContentPane().add(panel); // add display to JPanel panel.add(display.getComponent()); // set size of JFrame and make it visible frame.setSize(500, 500); frame.setVisible(true); }
public CategoryPanel( String name, List<ResourceLocator> locatorList, Set<String> loadedTrackNames) { expanded = true; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setAlignmentX(LEFT_ALIGNMENT); // setLayout(null); labelBar = new JPanel(); // labelBar.setBackground(Color.blue); labelBar.setLayout(new BoxLayout(labelBar, BoxLayout.X_AXIS)); labelBar.setBorder(BorderFactory.createRaisedBevelBorder()); // new LabelBorder(Color.black)); labelBar.setAlignmentX(LEFT_ALIGNMENT); JideButton toggleButton = new JideButton(expanded ? " - " : " + "); toggleButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE); labelBar.add(toggleButton); labelBar.add(new JLabel(name)); this.add(labelBar); listPanel = new JPanel(); listPanel.setLayout(new GridLayout(0, 4)); for (ResourceLocator loc : locatorList) { final String trackName = loc.getTrackName(); JCheckBox cb = new JCheckBox(trackName); cb.setSelected(loadedTrackNames.contains(trackName)); listPanel.add(cb); } this.add(listPanel); toggleButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { expanded = !expanded; listPanel.setVisible(expanded); } }); labelBar.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { expanded = !expanded; listPanel.setVisible(expanded); } }); }
/** Opens a new window with a drawing view. */ protected void open(DrawingView newDrawingView) { getVersionControlStrategy().assertCompatibleVersion(); setUndoManager(new UndoManager()); fIconkit = new Iconkit(this); getContentPane().setLayout(new BorderLayout()); // status line must be created before a tool is set fStatusLine = createStatusLine(); getContentPane().add(fStatusLine, BorderLayout.SOUTH); // create dummy tool until the default tool is activated during toolDone() setTool(new NullTool(this), ""); setView(newDrawingView); JComponent contents = createContents(view()); contents.setAlignmentX(LEFT_ALIGNMENT); JToolBar tools = createToolPalette(); createTools(tools); JPanel activePanel = new JPanel(); activePanel.setAlignmentX(LEFT_ALIGNMENT); activePanel.setAlignmentY(TOP_ALIGNMENT); activePanel.setLayout(new BorderLayout()); activePanel.add(tools, BorderLayout.NORTH); activePanel.add(contents, BorderLayout.CENTER); getContentPane().add(activePanel, BorderLayout.CENTER); JMenuBar mb = new JMenuBar(); createMenus(mb); setJMenuBar(mb); Dimension d = defaultSize(); if (d.width > mb.getPreferredSize().width) { setSize(d.width, d.height); } else { setSize(mb.getPreferredSize().width, d.height); } addListeners(); setVisible(true); fStorageFormatManager = createStorageFormatManager(); toolDone(); }
protected JPanel createOptionPanel() { JPanel oP = new JPanel(); oP.setLayout(new BoxLayout(oP, BoxLayout.Y_AXIS)); preservePermBox.setEnabled(false); preservePermBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { boolean selected = preservePermBox.isSelected(); boolean enableTargetPerm = !selected; permBox.setEnabled(enableTargetPerm); permButton.setEnabled(enableTargetPerm); } }); permButton.setActionCommand("permissions"); permButton.addActionListener(this); JPanel permPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); permPanel.add(permBox); permPanel.add(permButton); permBox.setEnabled(false); permButton.setEnabled(false); followSymLinkBox.setAlignmentX(Component.LEFT_ALIGNMENT); preserveMtimeBox.setAlignmentX(Component.LEFT_ALIGNMENT); preservePermBox.setAlignmentX(Component.LEFT_ALIGNMENT); permPanel.setAlignmentX(Component.LEFT_ALIGNMENT); oP.add(followSymLinkBox); oP.add(preserveMtimeBox); oP.add(preservePermBox); oP.add(permPanel); return oP; }
private void makeUi() { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); JPanel loginPane = createPane(); loginPane.setLayout(new BoxLayout(loginPane, BoxLayout.Y_AXIS)); add(loginPane); JLabel label = new JLabel("Login"); loginPane.add(label); login = new JTextField(); login.setAlignmentX(LEFT_ALIGNMENT); login.setPreferredSize(new Dimension(225, 25)); loginPane.add(login); JPanel passwordPane = createPane(); passwordPane.setLayout(new BoxLayout(passwordPane, BoxLayout.Y_AXIS)); add(passwordPane); passwordPane.add(new JLabel("Password")); password = new JTextField(); password.setAlignmentX(LEFT_ALIGNMENT); ; password.setPreferredSize(new Dimension(225, 25)); passwordPane.add(password); JPanel dirPane = createPane(); add(dirPane); dirPane.add(new JLabel("Directory")); JPanel dirSelectPane = new JPanel(); dirSelectPane.setAlignmentX(LEFT_ALIGNMENT); dirPane.add(dirSelectPane); dirSelectPane.setLayout(new BoxLayout(dirSelectPane, BoxLayout.X_AXIS)); directory = new JTextField(); dirSelectPane.add(directory); JButton dirSelBtn = new JButton("..."); dirSelectPane.add(dirSelBtn); final JDialog self = this; dirSelBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog(self); if (returnVal == JFileChooser.APPROVE_OPTION) { directory.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); JPanel buttonsPane = new JPanel(); buttonsPane.setLayout(new BoxLayout(buttonsPane, BoxLayout.X_AXIS)); buttonsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonsPane.setAlignmentX(LEFT_ALIGNMENT); buttonsPane.add(Box.createHorizontalGlue()); JButton okBtn = new JButton("OK"); okBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { isOk = true; setVisible(false); } }); buttonsPane.add(okBtn); JButton cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { isOk = false; setVisible(false); } }); buttonsPane.add(cancelBtn); add(buttonsPane); }
protected boolean exportApplicationPrompt() throws IOException, SketchException { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalStrut(6)); // Box panel = Box.createVerticalBox(); // Box labelBox = Box.createHorizontalBox(); // String msg = "<html>Click Export to Application to create a standalone, " + // "double-clickable application for the selected plaforms."; // String msg = "Export to Application creates a standalone, \n" + // "double-clickable application for the selected plaforms."; String line1 = "Export to Application creates double-clickable,"; String line2 = "standalone applications for the selected plaforms."; JLabel label1 = new JLabel(line1, SwingConstants.CENTER); JLabel label2 = new JLabel(line2, SwingConstants.CENTER); label1.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT); // label1.setAlignmentX(); // label2.setAlignmentX(0); panel.add(label1); panel.add(label2); int wide = label2.getPreferredSize().width; panel.add(Box.createVerticalStrut(12)); final JCheckBox windowsButton = new JCheckBox("Windows"); // windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); windowsButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean( "export.application.platform.windows", windowsButton.isSelected()); } }); final JCheckBox macosxButton = new JCheckBox("Mac OS X"); // macosxButton.setMnemonic(KeyEvent.VK_M); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); final JCheckBox linuxButton = new JCheckBox("Linux"); // linuxButton.setMnemonic(KeyEvent.VK_L); linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux")); linuxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected()); } }); JPanel platformPanel = new JPanel(); // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS)); platformPanel.add(windowsButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(macosxButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(linuxButton); platformPanel.setBorder(new TitledBorder("Platforms")); // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height); // platformPanel.setMaximumSize(goodIdea); wide = Math.max(wide, platformPanel.getPreferredSize().width); platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(platformPanel); // Box indentPanel = Box.createHorizontalBox(); // indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width)); final JCheckBox showStopButton = new JCheckBox("Show a Stop button"); // showStopButton.setMnemonic(KeyEvent.VK_S); showStopButton.setSelected(Preferences.getBoolean("export.application.stop")); showStopButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.stop", showStopButton.isSelected()); } }); showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen")); showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13)); // indentPanel.add(showStopButton); // indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT); final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)"); // fullscreenButton.setMnemonic(KeyEvent.VK_F); fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen")); fullScreenButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean sal = fullScreenButton.isSelected(); Preferences.setBoolean("export.application.fullscreen", sal); showStopButton.setEnabled(sal); } }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(fullScreenButton); optionPanel.add(showStopButton); // optionPanel.add(indentPanel); optionPanel.setBorder(new TitledBorder("Options")); wide = Math.max(wide, platformPanel.getPreferredSize().width); // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // optionPanel.setMaximumSize(goodIdea); panel.add(optionPanel); Dimension good; // label1, label2, platformPanel, optionPanel good = new Dimension(wide, label1.getPreferredSize().height); label1.setMaximumSize(good); good = new Dimension(wide, label2.getPreferredSize().height); label2.setMaximumSize(good); good = new Dimension(wide, platformPanel.getPreferredSize().height); platformPanel.setMaximumSize(good); good = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setMaximumSize(good); // JPanel actionPanel = new JPanel(); // optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); // optionPanel.add(Box.createHorizontalGlue()); // final JDialog frame = new JDialog(editor, "Export to Application"); // JButton cancelButton = new JButton("Cancel"); // cancelButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // frame.dispose(); // return false; // } // }); // Add the buttons in platform-specific order // if (PApplet.platform == PConstants.MACOSX) { // optionPanel.add(cancelButton); // optionPanel.add(exportButton); // } else { // optionPanel.add(exportButton); // optionPanel.add(cancelButton); // } String[] options = {"Export", "Cancel"}; final JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, // JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); final JDialog dialog = new JDialog(this, "Export Options", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setResizable(false); Rectangle bounds = getBounds(); dialog.setLocation( bounds.x + (bounds.width - dialog.getSize().width) / 2, bounds.y + (bounds.height - dialog.getSize().height) / 2); dialog.setVisible(true); Object value = optionPane.getValue(); if (value.equals(options[0])) { return jmode.handleExportApplication(sketch); } else if (value.equals(options[1]) || value.equals(new Integer(-1))) { // closed window by hitting Cancel or ESC statusNotice("Export to Application canceled."); } return false; }
private void initialize() { setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JLabel label = new JLabel( "It is up to you whether or not to include the source when you distribute your robot."); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); label = new JLabel( "If you include the source, other people will be able to look at your code and learn from it."); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); getIncludeSource().setAlignmentX(Component.LEFT_ALIGNMENT); add(getIncludeSource()); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getVersionLabel()); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setAlignmentX(Component.LEFT_ALIGNMENT); getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT); getVersionField().setMaximumSize(getVersionField().getPreferredSize()); p.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height)); p.add(getVersionField()); p.add(getVersionHelpLabel()); add(p); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getDescriptionLabel()); JScrollPane scrollPane = new JScrollPane( getDescriptionArea(), ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setMaximumSize(scrollPane.getPreferredSize()); scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height)); scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); add(scrollPane); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getAuthorLabel()); getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT); getAuthorField().setMaximumSize(getAuthorField().getPreferredSize()); add(getAuthorField()); label = new JLabel(" "); label.setAlignmentX(Component.LEFT_ALIGNMENT); add(label); add(getWebpageLabel()); getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT); getWebpageField().setMaximumSize(getWebpageField().getPreferredSize()); add(getWebpageField()); getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT); add(getWebpageHelpLabel()); JPanel panel = new JPanel(); panel.setAlignmentX(Component.LEFT_ALIGNMENT); add(panel); addComponentListener(eventHandler); }
public CustomDialog(Frame name) { super(name, "Customize Text Properties", true); this.setResizable(false); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontList = ge.getAvailableFontFamilyNames(); fontCombo = new JComboBox(fontList); italic = new JCheckBox("Italic"); bold = new JCheckBox("Bold"); sizeCombo = new JComboBox(stringSize); ((JLabel) sizeCombo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER); sizeCombo.setSelectedIndex(4); sizeCombo.setPreferredSize(new Dimension(45, 21)); // tweek size example = new JTextField(" Preview "); example.setHorizontalAlignment(SwingConstants.CENTER); example.setFont(new Font("sanserif", Font.PLAIN, 28)); example.setEditable(false); ok = new JButton("Apply"); cancel = new JButton("Cancel"); ok.setPreferredSize(cancel.getPreferredSize()); foreground = new JButton("Edit Color"); foreground.setPreferredSize(new Dimension(100, 50)); // add the listeners fontCombo.addActionListener(this); italic.addItemListener(this); bold.addItemListener(this); sizeCombo.addActionListener(this); ok.addActionListener(this); cancel.addActionListener(this); foreground.addActionListener(this); JPanel p0 = new JPanel(); p0.add(fontCombo); p0.setBorder(new TitledBorder(new EtchedBorder(), "Font family")); JPanel p1a = new JPanel(); p1a.add(italic); p1a.add(bold); p1a.setBorder(new TitledBorder(new EtchedBorder(), "Font style")); JPanel p1b = new JPanel(); p1b.add(sizeCombo); p1b.add(new JLabel("pt.")); p1b.setBorder(new TitledBorder(new EtchedBorder(), "Font size")); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); p1.add(p1a); p1.add(p1b); p1.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p2 = new JPanel(); // use FlowLayout p2.add(foreground); p2.setBorder(new TitledBorder(new EtchedBorder(), "Message color")); p2.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p3 = new JPanel(); p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS)); p3.add(example); p3.setPreferredSize(new Dimension(250, 60)); p3.setMaximumSize(new Dimension(250, 60)); p3.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p4 = new JPanel(); p4.add(ok); p4.add(cancel); p4.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(p0); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p1); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p2); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p3); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p4); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); Dimension d1 = p3.getPreferredSize(); Dimension d2 = p1.getPreferredSize(); p1.setPreferredSize(new Dimension(d1.width, d2.height)); p1.setMaximumSize(new Dimension(d1.width, d2.height)); d2 = p2.getPreferredSize(); p2.setPreferredSize(new Dimension(d1.width, d2.height)); p2.setMaximumSize(new Dimension(d1.width, d2.height)); this.setContentPane(p); this.pack(); }
private void layoutComponentsOfProxySocksPanel() { proxySocksPanel.setLayout(new GridBagLayout()); proxySocksPanel.setBackground(Color.WHITE); GridBagConstraints gc = new GridBagConstraints(); ///////////////// First row //////////////////////////////////////////// gc.gridy = 0; gc.weightx = 1; gc.weighty = 0.1; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); proxySocksPanel.add(noProxyLabel, gc); gc.gridx = 1; gc.insets = new Insets(0, 0, 0, 0); gc.anchor = GridBagConstraints.LINE_START; proxySocksPanel.add(noProxyRadioButton, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); proxySocksPanel.add(systemProxyLabel, gc); gc.gridx = 1; gc.insets = new Insets(0, 0, 0, 0); gc.anchor = GridBagConstraints.LINE_START; proxySocksPanel.add(systemProxyRadioButton, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); proxySocksPanel.add(manualProxyLabel, gc); gc.gridx = 1; gc.insets = new Insets(0, 0, 0, 0); gc.anchor = GridBagConstraints.LINE_START; proxySocksPanel.add(manualProxyRadioButton, gc); ///////////////// Next row //////////////////////////////////////////// // gc.gridy++; // // gc.gridx = 0; // gc.gridwidth = 2; // gc.fill = GridBagConstraints.NONE; // // gc.anchor = GridBagConstraints.LINE_END; // gc.insets = new Insets(0, 0, 0, 5); // proxyPanel.add(manualProxyPanel, gc); // gc.gridx = 1; // gc.insets = new Insets(0, 0, 0, 0); // gc.anchor = GridBagConstraints.LINE_START; // proxyPanel.add(manualProxyRadioButton, gc); proxySocksPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(proxySocksPanel); }
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
/** * run 'java FlowTest middle_latitude' to test with (lat, lon) run 'java FlowTest middle_latitude * x' to test with (lon, lat) adjust middle_latitude for south or north */ public static void main(String args[]) throws VisADException, RemoteException { double mid_lat = -10.0; if (args.length > 0) { try { mid_lat = Double.valueOf(args[0]).doubleValue(); } catch (NumberFormatException e) { } } boolean swap = (args.length > 1); RealType lat = RealType.Latitude; RealType lon = RealType.Longitude; RealType[] types; if (swap) { types = new RealType[] {lon, lat}; } else { types = new RealType[] {lat, lon}; } RealTupleType earth_location = new RealTupleType(types); System.out.println("earth_location = " + earth_location + " mid_lat = " + mid_lat); RealType flowx = RealType.getRealType("flowx", CommonUnit.meterPerSecond); RealType flowy = RealType.getRealType("flowy", CommonUnit.meterPerSecond); RealType red = RealType.getRealType("red"); RealType green = RealType.getRealType("green"); EarthVectorType flowxy = new EarthVectorType(flowx, flowy); TupleType range = null; range = new TupleType(new MathType[] {flowxy, red, green}); FunctionType flow_field = new FunctionType(earth_location, range); DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D()); ScalarMap xmap = new ScalarMap(lon, Display.XAxis); display.addMap(xmap); ScalarMap ymap = new ScalarMap(lat, Display.YAxis); display.addMap(ymap); ScalarMap flowx_map = new ScalarMap(flowx, Display.Flow1X); display.addMap(flowx_map); flowx_map.setRange(-10.0, 10.0); ScalarMap flowy_map = new ScalarMap(flowy, Display.Flow1Y); display.addMap(flowy_map); flowy_map.setRange(-10.0, 10.0); FlowControl flow_control = (FlowControl) flowy_map.getControl(); flow_control.setFlowScale(0.05f); display.addMap(new ScalarMap(red, Display.Red)); display.addMap(new ScalarMap(green, Display.Green)); display.addMap(new ConstantMap(1.0, Display.Blue)); double lonlow = -10.0; double lonhi = 10.0; double latlow = mid_lat - 10.0; double lathi = mid_lat + 10.0; Linear2DSet set; if (swap) { set = new Linear2DSet(earth_location, lonlow, lonhi, N, latlow, lathi, N); } else { set = new Linear2DSet(earth_location, latlow, lathi, N, lonlow, lonhi, N); } double[][] values = new double[4][N * N]; int m = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { int k = i; int l = j; if (swap) { k = j; l = i; } double u = (N - 1.0) / 2.0 - l; double v = k - (N - 1.0) / 2.0; // double u = 2.0 * k / (N - 1.0) - 1.0; // double v = 2.0 * l / (N - 1.0); double fx = 6.0 * u; double fy = 6.0 * v; values[0][m] = fx; values[1][m] = fy; values[2][m] = u; values[3][m] = v; m++; } } FlatField field = new FlatField(flow_field, set); field.setSamples(values); DataReferenceImpl ref = new DataReferenceImpl("ref"); ref.setData(field); display.addReference(ref); // create JFrame (i.e., a window) for display and slider JFrame frame = new JFrame("test FlowTest"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // create JPanel in JFrame JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentY(JPanel.TOP_ALIGNMENT); panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); frame.getContentPane().add(panel); // add display to JPanel panel.add(display.getComponent()); // set size of JFrame and make it visible frame.setSize(500, 500); frame.setVisible(true); }
public InfoPanelForDrawable( final Map map_line2treenodes, final String[] y_colnames, final Drawable dobj) { super(); super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /* Define DecialFormat for the displayed time */ if (fmt == null) { fmt = (DecimalFormat) NumberFormat.getInstance(); fmt.applyPattern(FORMAT); } if (tfmt == null) tfmt = new TimeFormat(); if (Normal_Border == null) { /* Normal_Border = BorderFactory.createCompoundBorder( BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder() ); */ Normal_Border = BorderFactory.createEtchedBorder(); } if (Shadow_Border == null) { Shadow_Border = BorderFactory.createTitledBorder( Normal_Border, " Preview State ", TitledBorder.LEFT, TitledBorder.TOP, Const.FONT, Color.magenta); } drawable = dobj; // Set the CategoryLabel Icon Dimension panel_max_size; Category type = null; CategoryLabel label_type = null; JPanel top_panel = new JPanel(); top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.X_AXIS)); if (drawable instanceof Shadow && ((Shadow) drawable).getSelectedSubCategory() != null) { type = ((Shadow) drawable).getSelectedSubCategory(); label_type = new CategoryLabel(type); ((Shadow) drawable).clearSelectedSubCategory(); top_panel.setBorder(Shadow_Border); } else { type = drawable.getCategory(); label_type = new CategoryLabel(type); top_panel.setBorder(Normal_Border); } top_panel.add(STRUT); top_panel.add(label_type); top_panel.add(GLUE); top_panel.setAlignmentX(Component.LEFT_ALIGNMENT); panel_max_size = top_panel.getPreferredSize(); panel_max_size.width = Short.MAX_VALUE; top_panel.setMaximumSize(panel_max_size); super.add(top_panel); // Determine the text of the drawable TextAreaBuffer textbuf; int num_cols, num_rows; textbuf = new TextAreaBuffer(map_line2treenodes, y_colnames); if (drawable instanceof Shadow) textbuf.setShadowText((Shadow) drawable, type); else if (drawable instanceof Composite) textbuf.setCompositeText((Composite) drawable); else textbuf.setPrimitiveText((Primitive) drawable); textbuf.finalized(); num_cols = textbuf.getColumnCount(); num_rows = textbuf.getRowCount(); // Set the TextArea JTextArea text_area; int adj_num_cols; text_area = new JTextArea(textbuf.toString()); adj_num_cols = Routines.getAdjNumOfTextColumns(text_area, num_cols); num_cols = (int) Math.ceil(adj_num_cols * 85.0d / 100.0d); text_area.setColumns(num_cols); text_area.setRows(num_rows); text_area.setEditable(false); text_area.setLineWrap(true); JScrollPane scroller = new JScrollPane(text_area); scroller.setAlignmentX(Component.LEFT_ALIGNMENT); super.add(scroller); }
private void layoutComponentsOfManualProxyPanel() { manualProxyPanel.setLayout(new GridBagLayout()); manualProxyPanel.setBorder(BorderFactory.createTitledBorder("Manual proxy configuration")); manualProxyPanel.setBackground(Color.WHITE); GridBagConstraints gc = new GridBagConstraints(); ///////////////// First row //////////////////////////////////////////// gc.gridy = 0; gc.weightx = 1; gc.weighty = 0.1; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(useProxyLabel, gc); gc.gridx = 1; gc.insets = new Insets(0, 0, 0, 0); gc.anchor = GridBagConstraints.LINE_START; manualProxyPanel.add(useProxyRadioButton, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 1; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.CENTER; manualProxyPanel.add(proxyAddressLabel, gc); gc.gridx = 2; manualProxyPanel.add(proxyPortLabel, gc); gc.gridx = 3; manualProxyPanel.add(proxyUserNameLabel, gc); gc.gridx = 4; manualProxyPanel.add(proxyPasswordLabel, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(httpLabel, gc); gc.gridx = 1; gc.fill = GridBagConstraints.NONE; manualProxyPanel.add(httpProxyAddressTextField, gc); gc.gridx = 2; manualProxyPanel.add(httpProxyPortSpinner, gc); gc.gridx = 3; manualProxyPanel.add(httpProxyUserNameTextField, gc); gc.gridx = 4; manualProxyPanel.add(httpProxyPasswordField, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(httpsLabel, gc); gc.gridx = 1; gc.fill = GridBagConstraints.NONE; manualProxyPanel.add(httpsProxyAddressTextField, gc); gc.gridx = 2; manualProxyPanel.add(httpsProxyPortSpinner, gc); gc.gridx = 3; manualProxyPanel.add(httpsProxyUserNameTextField, gc); gc.gridx = 4; manualProxyPanel.add(httpsProxyPasswordField, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(ftpLabel, gc); gc.gridx = 1; gc.fill = GridBagConstraints.NONE; manualProxyPanel.add(ftpProxyAddressTextField, gc); gc.gridx = 2; manualProxyPanel.add(ftpProxyPortSpinner, gc); gc.gridx = 3; manualProxyPanel.add(ftpProxyUserNameTextField, gc); gc.gridx = 4; manualProxyPanel.add(ftpProxyPasswordField, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(useSocksLabel, gc); gc.gridx = 1; gc.insets = new Insets(0, 0, 0, 0); gc.anchor = GridBagConstraints.LINE_START; manualProxyPanel.add(useSocksRadioButton, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 1; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.CENTER; manualProxyPanel.add(socksProxyAddressLabel, gc); gc.gridx = 2; manualProxyPanel.add(socksProxyPortLabel, gc); gc.gridx = 3; manualProxyPanel.add(socksProxyUserNameLabel, gc); gc.gridx = 4; manualProxyPanel.add(socksProxyPasswordLabel, gc); ///////////////// Next row //////////////////////////////////////////// gc.gridy++; gc.gridx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.LINE_END; gc.insets = new Insets(0, 0, 0, 5); manualProxyPanel.add(socksLabel, gc); gc.gridx = 1; gc.fill = GridBagConstraints.NONE; manualProxyPanel.add(socksProxyAddressTextField, gc); gc.gridx = 2; manualProxyPanel.add(socksProxyPortSpinner, gc); gc.gridx = 3; manualProxyPanel.add(socksProxyUserNameTextField, gc); gc.gridx = 4; manualProxyPanel.add(socksProxyPasswordField, gc); manualProxyPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(manualProxyPanel); }
public Displayer(Player x, int num) { super("Player " + num + " Information"); playernum = num; this.x = x; setSize(400, 400); setResizable(false); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); moneyLabel = new JLabel("Money Owned:" + x.getMoney() + ""); jcards = new JLabel("Get out of Jail Cards Owned: " + x.getJailCards()); propertydisplay = new JComboBox(getPropertyName()); icon = new ImageIcon(Game.wdr + "images/tokens/monopoly_token_" + x.getToken() + ".png"); mortgage = new JButton("Manage Mortgage"); mortgage.addActionListener(this); mortgage.setActionCommand("mortgage"); buyHouse = new JButton("Buy a House"); buyHouse.addActionListener(this); buyHouse.setActionCommand("buyHouse"); sellHouse = new JButton("Sell a House"); sellHouse.addActionListener(this); sellHouse.setActionCommand("sellHouse"); sellProperty = new JButton("Sell this Property"); sellProperty.addActionListener(this); sellProperty.setActionCommand("sellProperty"); Image img = icon.getImage(); Image newimg = img.getScaledInstance(80, 80, java.awt.Image.SCALE_SMOOTH); ImageIcon newicon = new ImageIcon(newimg); timg = new JLabel(newicon); propertydisplay.addItemListener(this); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); p2.setAlignmentX(Component.RIGHT_ALIGNMENT); p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS)); p3.setAlignmentX(Component.LEFT_ALIGNMENT); p2.add(timg); p3.add(moneyLabel); p3.add(jcards); p1.add(p2); p1.add(p3); p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS)); p4.setAlignmentY(Component.CENTER_ALIGNMENT); p4.add(propertydisplay); p4.add(pr1); p4.add(pr2); p4.add(pr3); p4.add(pr4); p4.add(pr5); p5.setLayout(new BoxLayout(p5, BoxLayout.X_AXIS)); p5.add(mortgage); p5.add(buyHouse); p5.add(sellHouse); p.add(p1); p.add(p4); p.add(p5); add(p); setVisible(true); timer.setActionCommand("timing"); timer.setInitialDelay(500); timer.start(); }