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 MainPanel() { super(new BorderLayout()); JEditorPane editor = new JEditorPane("text/html", String.format("<html><a href='%s'>%s</a>", MYSITE, MYSITE)); editor.setOpaque(false); editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); editor.setEditable(false); editor.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(MYSITE)); } catch (IOException | URISyntaxException ex) { ex.printStackTrace(); } textArea.setText(e.toString()); } } }); JPanel p = new JPanel(); p.add(editor); p.setBorder(BorderFactory.createTitledBorder("Desktop.getDesktop().browse(URI)")); add(p, BorderLayout.NORTH); add(new JScrollPane(textArea)); setPreferredSize(new Dimension(320, 240)); }
private OffsetPanel(Component comp) { this.setLayout(new BorderLayout(0, 0)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOffsetBy")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } this.setBorder(tb); JPanel controls = new JPanel(); controls.setLayout(new GridLayout(3, 1, 5, 0)); b1 = new JOAJRadioButton(b.getString("kSequence")); b2 = new JOAJRadioButton(b.getString("kDistance"), true); b3 = new JOAJRadioButton(b.getString("kTime")); controls.add(b2); controls.add(b1); controls.add(b3); controls.add(new JOAJLabel(" ")); ButtonGroup bg = new ButtonGroup(); bg.add(b1); bg.add(b2); bg.add(b3); this.add("Center", controls); b1.addItemListener((ItemListener) comp); b2.addItemListener((ItemListener) comp); b3.addItemListener((ItemListener) comp); }
public DynamicTree() { super(new GridLayout(1, 0)); rootNode = new JscTreeNode("Vitenfabrikken"); treeModel = new DefaultTreeModel(rootNode); tree = new JTree(treeModel); tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); tree.addTreeSelectionListener(this); JPanel content = new JPanel(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setSize(500, 300); scrollPane.setBorder(BorderFactory.createTitledBorder("Maskiner")); content.add(scrollPane); // add(scrollPane); currentSelectionField = new JTextField("Valgt: NONE"); // currentSelectionField.setSize(500, 15); currentSelectionField.setMaximumSize(new Dimension(500, 15)); content.add(currentSelectionField, BorderLayout.SOUTH); // add(currentSelectionField); // content.setPreferredSize(new Dimension(500, 315)); add(content); setSize(500, 315); }
public CreInvChecker(Component parent) { typeButtons = new JCheckBox[CHECKTYPES.length]; JPanel boxPanel = new JPanel(new GridLayout(0, 1)); for (int i = 0; i < typeButtons.length; i++) { typeButtons[i] = new JCheckBox(CHECKTYPES[i], true); boxPanel.add(typeButtons[i]); } bstart.setMnemonic('s'); bcancel.setMnemonic('c'); bstart.addActionListener(this); bcancel.addActionListener(this); selectframe.getRootPane().setDefaultButton(bstart); selectframe.setIconImage(Icons.getIcon("Find16.gif").getImage()); boxPanel.setBorder(BorderFactory.createTitledBorder("Select test to check:")); JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); bpanel.add(bstart); bpanel.add(bcancel); JPanel mainpanel = new JPanel(new BorderLayout()); mainpanel.add(boxPanel, BorderLayout.CENTER); mainpanel.add(bpanel, BorderLayout.SOUTH); mainpanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); JPanel pane = (JPanel) selectframe.getContentPane(); pane.setLayout(new BorderLayout()); pane.add(mainpanel, BorderLayout.CENTER); selectframe.pack(); Center.center(selectframe, parent.getBounds()); selectframe.setVisible(true); }
/* *Creates the JTextField for the GUI. */ private JTextField inputField() { inputField = new JTextField(); Border inputBorder = BorderFactory.createEtchedBorder(); inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:"); inputField.setBorder(inputBorder); inputField.addActionListener(new ActionListenerField()); return inputField; }
public ColorChooserDemo() { super(new BorderLayout()); // 设置一个标签,做广告的。也用来显示用户选择的颜色。 banner = new JLabel("欢迎使用颜色选择器!", JLabel.CENTER); banner.setForeground(Color.yellow); banner.setBackground(Color.blue); banner.setOpaque(true); banner.setFont(new Font("SansSerif", Font.BOLD, 24)); banner.setPreferredSize(new Dimension(100, 65)); JPanel bannerPanel = new JPanel(new BorderLayout()); bannerPanel.add(banner, BorderLayout.CENTER); bannerPanel.setBorder(BorderFactory.createTitledBorder("广告")); // 设置选择颜色选择器 tcc = new JColorChooser(banner.getForeground()); // 设置初始颜色 tcc.getSelectionModel().addChangeListener(this); // 给所有模式添加监听 tcc.setBorder(BorderFactory.createTitledBorder("选择颜色")); add(bannerPanel, BorderLayout.CENTER); add(tcc, BorderLayout.PAGE_END); }
boolean initControlCenter(String title) { this.setTitle(title); // set up content pane Container content = this.getContentPane(); content.setLayout(new BorderLayout()); panelAbout.setLayout(new BorderLayout()); JTextArea textArea = new JTextArea( "PlayStation 2 Virtual File System release 1.0 \n\nSpecials thanks to our betatester\nPS2Linux Betatester: Mrbrown and Sarah\nPS2 betatester: Oobles, Caveman, Gamebytes, Ping^Spike, Josekenshin, Padawan, pakor, SandraThx and Rolando\n\nAdded little gui in java swing\nAdded feature to choose directory for media files\nAdded support for properties files\nCheck for updates at ps2dev.org\n\nRelease 1.2\n\nRewrite io with java NIO\nadded console mode support\n"); textArea.setEditable(false); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); TitledBorder aboutBorder = BorderFactory.createTitledBorder("Change log and Greets"); aboutBorder.setTitleColor(Color.blue); panelAbout.setBorder(aboutBorder); panelAbout.add(areaScrollPane); // set up tabbed pane content.add(jtpMain); jtpMain.addTab("Configure", panelChooser); jtpMain.addTab("About", panelAbout); // set up display area // jtaDisplay.setEditable(false); // jtaDisplay.setLineWrap(true); // jtaDisplay.setMargin(new Insets(5, 5, 5, 5)); // jtaDisplay.setFont( // new Font("Monospaced", Font.PLAIN, iDEFAULT_FontSize)); // jspDisplay.setViewportView(jtaDisplay); // jspDisplay.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); // panelConsole.add(jspDisplay, BorderLayout.CENTER); // panelConsole.add(jtfCommand, BorderLayout.SOUTH); // panelConsole.add(jtaDisplay, BorderLayout.CENTER); // listener: window closer this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.vResize(); return true; }
public JList7() { JFrame f = new JFrame("JList"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); label = new JLabel(); list = new JList(s); list.setVisibleRowCount(5); list.setBorder(BorderFactory.createTitledBorder("您最喜欢到哪个国家玩呢?")); list.addListSelectionListener(this); contentPane.add(label, BorderLayout.NORTH); contentPane.add(new JScrollPane(list), BorderLayout.CENTER); f.pack(); f.show(); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
/** Generates Configuration tab. */ private void fillConfigurationPanel() { JPanel desc = new JPanel(new GridLayout(2, 0)); desc.setBorder(BorderFactory.createTitledBorder("Description")); desc.add( new JLabel("<html><font color=\"blue\">" + myMonitor.getDescription() + "</font></html>")); desc.add(cbEnabled); cbEnabled.setSelected(enabled); cbEnabled.addChangeListener(this); confPanel.add(desc); JPanel mlpanel = new JPanel(new GridLayout(1, 0)); mlpanel.setBorder(BorderFactory.createTitledBorder("Monitored Network Elements")); montable = new JTable(montablemodel); montable.setPreferredScrollableViewportSize(new Dimension(200, 100)); montable.getColumnModel().getColumn(0).setPreferredWidth(140); montable.getColumnModel().getColumn(1).setPreferredWidth(60); montable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = montable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getPredecessors().size())) ne = myMonitor.getPredecessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); mlpanel.add(new JScrollPane(montable)); confPanel.add(mlpanel); JPanel cpanel = new JPanel(new GridLayout(1, 0)); cpanel.setBorder(BorderFactory.createTitledBorder("Controlleded Network Elements")); ctrltable = new JTable(ctrltablemodel); ctrltable.setPreferredScrollableViewportSize(new Dimension(200, 100)); ctrltable.getColumnModel().getColumn(0).setPreferredWidth(140); ctrltable.getColumnModel().getColumn(1).setPreferredWidth(60); ctrltable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = ctrltable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getSuccessors().size())) ne = myMonitor.getSuccessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); cpanel.add(new JScrollPane(ctrltable)); confPanel.add(cpanel); JPanel pcl = new JPanel(new FlowLayout()); // controller list buttonProp.setEnabled(false); buttonProp.setActionCommand(cmdCtrlProp); buttonProp.addActionListener(this); pcl.setBorder(BorderFactory.createTitledBorder("Complex Controller")); buttonProp.setEnabled(false); listCControllers = new JComboBox(); listCControllers.addItem("None"); String[] ctrlClasses = myMonitor.getComplexControllerClasses(); for (int i = 0; i < ctrlClasses.length; i++) { if ((myController != null) && (myController.getClass().getName().compareTo(ctrlClasses[i]) == 0)) { listCControllers.addItem(myController); listCControllers.setSelectedIndex(i + 1); buttonProp.setEnabled(true); } else { try { Class cl = Class.forName(ctrlClasses[i]); AbstractControllerComplex cc = (AbstractControllerComplex) cl.newInstance(); cc.setMyMonitor(myMonitor); cc.initialize(); listCControllers.addItem(cc); } catch (Exception e) { } } } listCControllers.setActionCommand(cmdCtrlList); listCControllers.addActionListener(this); pcl.add(listCControllers); pcl.add(buttonProp); confPanel.add(pcl); return; }
private Border createTitleBorder(String title) { TitledBorder b = BorderFactory.createTitledBorder(title); // b.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); return new CompoundBorder(b, BorderFactory.createEmptyBorder(10, 10, 10, 10)); }
public void init() { symbolData = new Icon[] { new ImageIcon(getClass().getResource("images/sym_square.gif")), new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")), new ImageIcon(getClass().getResource("images/sym_circle.gif")), new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")), new ImageIcon(getClass().getResource("images/sym_diamond.gif")), new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")), new ImageIcon(getClass().getResource("images/sym_triangle.gif")), new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")), new ImageIcon(getClass().getResource("images/sym_cross1.gif")), new ImageIcon(getClass().getResource("images/sym_cross2.gif")) }; mSymbolPopup = new JOAJComboBox(); for (int i = 0; i < symbolData.length; i++) { mSymbolPopup.addItem(symbolData[i]); } mSymbolPopup.setSelectedIndex(mCurrSymbol - 1); JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5)); // create the two parameter chooser lists Container contents = this.getContentPane(); this.getContentPane().setLayout(new BorderLayout(5, 5)); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(5, 5)); JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5)); JPanel upperPanel = new JPanel(new BorderLayout(5, 5)); mYParamList = new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT"); OffsetPanel ofp = new OffsetPanel(this); mYParamList.init(); paramPanel.add(mYParamList); paramPanel.add(ofp); upperPanel.add("Center", paramPanel); everyThingPanel.add(BorderLayout.NORTH, upperPanel); // Options JPanel middlePanel = new JPanel(); middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } middlePanel.setBorder(tb); // containers for the non-advanced options JPanel nonAdvOptions = new JPanel(); nonAdvOptions.setLayout(new BorderLayout(5, 0)); JPanel ctrNonAdvOptions = new JPanel(); ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2)); // plot axes goes in ctrNonAdvOptions JPanel axesOptions = new JPanel(); axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kAxes")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } axesOptions.setBorder(tb); JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true); mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false); mReverseY.addItemListener(this); mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid")); mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid")); line0.add(mConnectObs); line1.add(mReverseY); line3.add(mPlotYGrid); line33.add(mPlotXGrid); axesOptions.add(line1); axesOptions.add(line3); axesOptions.add(line33); // other options JPanel otherOptions = new JPanel(); otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kOther")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } otherOptions.setBorder(tb); // plot symbols JPanel line4 = new JPanel(); line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); mEnableSymbols = new JOAJLabel(b.getString("kSymbol")); line4.add(mEnableSymbols); line4.add(mSymbolPopup); mSymbolPopup.addItemListener(this); mSizeLabel = new JOAJLabel(b.getString("kSize")); line4.add(mSizeLabel); SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1); mSizeField = new JSpinner(model); line4.add(mSizeField); otherOptions.add(line0); otherOptions.add(line4); // add the axes and other panels to the gridlayout ctrNonAdvOptions.add(axesOptions); ctrNonAdvOptions.add(otherOptions); // add this panel to the north of the borderlayout nonAdvOptions.add("Center", ctrNonAdvOptions); JPanel colorNameContPanel = new JPanel(); colorNameContPanel.setLayout(new BorderLayout(0, 0)); JPanel colorNamePanel = new JPanel(); colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); // swatches JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineLCS.add(new JOAJLabel(b.getString("kLineColor"))); mLineColorSwatch = new Swatch(Color.black, 12, 12); lineLCS.add(new JOAJLabel(" ")); lineLCS.add(mLineColorSwatch); JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineSCS.add(new JOAJLabel(b.getString("kSymbolColor"))); mSymbolColorSwatch = new Swatch(Color.black, 12, 12); lineSCS.add(new JOAJLabel(" ")); lineSCS.add(mSymbolColorSwatch); JPanel line7 = new JPanel(); line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line7.add(new JOAJLabel(b.getString("kBackgroundColor"))); plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12); line7.add(new JOAJLabel(" ")); line7.add(plotBg); JPanel line8 = new JPanel(); line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line8.add(new JOAJLabel(b.getString("kGridColor"))); axesColor = new Swatch(Color.black, 12, 12); line8.add(new JOAJLabel(" ")); line8.add(axesColor); JPanel line9 = new JPanel(); line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); line9.add(new JOAJLabel(b.getString("kColorSchemes"))); Vector<String> presetSchemes = new Vector<String>(); presetSchemes.addElement(b.getString("kDefault")); presetSchemes.addElement(b.getString("kWhiteBackground")); presetSchemes.addElement(b.getString("kBlackBackground")); presetColorSchemes = new JOAJComboBox(presetSchemes); presetColorSchemes.setSelectedItem(b.getString("kDefault")); presetColorSchemes.addItemListener(this); line9.add(presetColorSchemes); JPanel swatchCont = new JPanel(); swatchCont.setLayout(new GridLayout(4, 1, 0, 5)); swatchCont.add(lineLCS); swatchCont.add(lineSCS); swatchCont.add(line7); swatchCont.add(line8); JPanel swatchContCont = new JPanel(); swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); swatchContCont.add(swatchCont); swatchContCont.add(line9); tb = BorderFactory.createTitledBorder(b.getString("kColors")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } swatchContCont.setBorder(tb); // window name JPanel namePanel = new JPanel(); namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5)); namePanel.add(new JOAJLabel(b.getString("kWindowName"))); mNameField = new JOAJTextField(30); mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); namePanel.add(mNameField); // add the color panel colorNameContPanel.add("North", swatchContCont); colorNamePanel.add(colorNameContPanel); // add the name panel colorNamePanel.add(namePanel); // add these to the south of the borderlayout nonAdvOptions.add("South", colorNamePanel); // add all of this to the middle panel middlePanel.add(nonAdvOptions); // advanced options panel // axis container // y axis detail // container for the axes stuff plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5)); // y axis container JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kYAxis")); yAxis.setBorder(tb); StnPlotSpecification mPlotSpec = new StnPlotSpecification(); JPanel line5y = new JPanel(); line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5y.add(new JOAJLabel(b.getString("kMinimum"))); yMin = new JOAJTextField(6); yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false)); yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5y.add(yMin); JPanel line6y = new JPanel(); line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6y.add(new JOAJLabel(b.getString("kMaximum"))); yMax = new JOAJTextField(6); yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false)); yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6y.add(yMax); JPanel line7y = new JPanel(); line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7y.add(new JOAJLabel(b.getString("kIncrement"))); yInc = new JOAJTextField(6); yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false)); yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7y.add(yInc); JPanel line8y = new JPanel(); line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8y.add(new JOAJLabel(b.getString("kNoMinorTicks"))); SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1); yTics = new JSpinner(model3); line8y.add(yTics); yAxis.add(line5y); yAxis.add(line6y); yAxis.add(line7y); yAxis.add(line8y); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); plotScaleCont.add(yAxis); // x axis container JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kXAxis")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } xAxis.setBorder(tb); JPanel line5x = new JPanel(); line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5x.add(mMinXLabel); xMin = new JOAJTextField(6); xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false)); xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5x.add(xMin); JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); minTime.add(mMinXTLabel); JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); maxTime.add(mMaxXTLabel); GeoDate minDate = new GeoDate(mFileViewer.getMinDate()); minDate.decrement(1.0, GeoDate.YEARS); GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate()); maxDate.increment(1.0, GeoDate.YEARS); // value, start,end SpinnerDateModel mStartDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR); mStartSpinner = new JSpinner(mStartDateModel); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm"); mStartSpinner.setEditor(dateEditor); SpinnerDateModel mEndDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR); mEndSpinner = new JSpinner(mEndDateModel); JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm"); minTime.add(mStartSpinner); maxTime.add(mEndSpinner); mEndSpinner.setEditor(dateEditor2); JPanel line6x = new JPanel(); line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6x.add(mMaxXLabel); xMax = new JOAJTextField(6); xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false)); xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6x.add(xMax); JPanel line7x = new JPanel(); line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7x.add(mIncLabel); xInc = new JOAJTextField(6); xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false)); xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7x.add(xInc); JPanel line8x = new JPanel(); line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8x.add(mXIncLabel); SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1); xTics = new JSpinner(model2); line8x.add(xTics); xAxis.add(minTime); xAxis.add(maxTime); xAxis.add(line5x); xAxis.add(line6x); xAxis.add(line7x); xAxis.add(line8x); plotScaleCont.add(xAxis); everyThingPanel.add(BorderLayout.CENTER, plotScaleCont); everyThingPanel.add(BorderLayout.SOUTH, middlePanel); mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10)); // lower panel mOKBtn = new JOAJButton(b.getString("kPlot")); mOKBtn.setActionCommand("ok"); this.getRootPane().setDefaultButton(mOKBtn); mCancelButton = new JOAJButton(b.getString("kCancel")); mCancelButton.setActionCommand("cancel"); JPanel dlgBtnsInset = new JPanel(); JPanel dlgBtnsPanel = new JPanel(); dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1)); dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1)); if (JOAConstants.ISMAC) { dlgBtnsPanel.add(mCancelButton); dlgBtnsPanel.add(mOKBtn); } else { dlgBtnsPanel.add(mOKBtn); dlgBtnsPanel.add(mCancelButton); } dlgBtnsInset.add(dlgBtnsPanel); mOKBtn.addActionListener(this); mCancelButton.addActionListener(this); mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South"); contents.add("Center", mainPanel); this.pack(); runTimer(); setXRangeToDistance(); // show dialog at center of screen Rectangle dBounds = this.getBounds(); Dimension sd = Toolkit.getDefaultToolkit().getScreenSize(); int x = sd.width / 2 - dBounds.width / 2; int y = sd.height / 2 - dBounds.height / 2; this.setLocation(x, y); }
/** Building up the core GUI. */ private void buildUpGUI() { table = new JTable(new ConstantPoolTableModel()); setLayout(new BorderLayout()); add(mainPanel); mainPanel.add(tablePanel, BorderLayout.CENTER); mainPanel.add(searchPanel, BorderLayout.NORTH); tablePanel.add(table.getTableHeader(), BorderLayout.NORTH); tablePanel.add(new JScrollPane(table), BorderLayout.CENTER); searchPanel.setLayout(new GridLayout(0, 3)); searchPanel.add(findPanel); searchPanel.add(gotoPanel); searchPanel.add(filterPanel); findPanel.setBorder(BorderFactory.createTitledBorder("Search String:")); gotoPanel.setBorder(BorderFactory.createTitledBorder("Jump to index:")); filterPanel.setBorder(BorderFactory.createTitledBorder("Filtering:")); findPanel.setLayout(new BoxLayout(findPanel, BoxLayout.Y_AXIS)); findTextField.setAlignmentX(Component.CENTER_ALIGNMENT); findPanel.add(findTextField); findButtonPanel.add(findNextButton); findButtonPanel.add(findPrevButton); findButtonPanel.setAlignmentX(Component.CENTER_ALIGNMENT); findPanel.add(findButtonPanel); gotoPanel.setLayout(new BorderLayout()); JPanel tmp = new JPanel(); gotoPanel.add(tmp, BorderLayout.CENTER); tmp.add(gotoTextField); tmp = new JPanel(); gotoPanel.add(tmp, BorderLayout.EAST); tmp.add(gotoButton); filterPanel.setLayout(new BorderLayout()); tmp = new JPanel(); filterPanel.add(tmp, BorderLayout.CENTER); tmp.add(filterComboBox); tmp = new JPanel(); filterPanel.add(tmp, BorderLayout.EAST); tmp.add(filterButton); // adding listeners findTextField.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent ke) { if (KeyEvent.VK_ENTER == ke.getKeyChar()) { findNext(); } } }); findNextButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { findNext(); } }); findPrevButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { findPrev(); } }); gotoTextField.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent ke) { if (KeyEvent.VK_ENTER == ke.getKeyChar()) { gotoLine(); } } }); gotoButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { gotoLine(); } }); filterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { filterData(); } }); } // buildUpGUI
QueryPanel(ControlHandler c) { // initialize the important stuff control = c; control.setQueryPanel(this); // make a few buttons and fields JButton queryButton = new JButton("Query"); queryField = new JTextField("", 30); // query socketField = new JTextField("0", 3); JButton downloadButton = new JButton("Download"); // add actions queryButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { sendQuery(); } }); downloadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { startDownload(); } }); // initialize the query table queryModel = new QueryTableModel(3, control.getQueryVector()); queryTable = new JTable(queryModel); queryTable.addMouseListener(new TableListener()); // TableColumnModel columnModel = new TableColumn(); // columnModel.getColumn(0).setWidth(350); JScrollPane scrollPane = new JScrollPane(queryTable); scrollPane.setPreferredSize(new Dimension(625, 150)); scrollPane.setBorder(BorderFactory.createLoweredBevelBorder()); // Create a panel to hold the query search JPanel commandPanel = new JPanel(); commandPanel.add(queryButton); commandPanel.add(queryField); commandPanel.add(downloadButton); add(commandPanel); // Create a panel to hold the download button JPanel query = new JPanel(); query.setBorder(BorderFactory.createTitledBorder("Queries")); query.add(scrollPane); add(query); // --------------------------------------------------------------------- // Download Table downloadModel = new DownloadTableModel(3, control.getDownloadVector()); downloadTable = new JTable(downloadModel); downloadTable.addMouseListener(new TableListener()); JScrollPane downloadPane = new JScrollPane(downloadTable); downloadPane.setPreferredSize(new Dimension(625, 80)); downloadPane.setBorder(BorderFactory.createLoweredBevelBorder()); // Buttons JButton cancelDownload = new JButton("Cancel Selected"); JButton cancelAllDownload = new JButton("Cancel All"); JButton clearDownloadButton = new JButton("Clear completed"); cancelDownload.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { control.removeDownloadAt(downloadRow); } }); clearDownloadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { control.removeCompletedDownloads(); } }); // A panel for the buttons and things JPanel downloadCommand = new JPanel(); downloadCommand.add(cancelDownload); downloadCommand.add(cancelAllDownload); downloadCommand.add(clearDownloadButton); JPanel down = new JPanel(); down.setBorder(BorderFactory.createTitledBorder("Downloads")); down.add(downloadPane); add(down); add(downloadCommand); }
public ColorDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); setTitle("Choose Color"); // Group two buttons OK and Cancel JPanel jpButtons = new JPanel(); jpButtons.add(jbtOK); jpButtons.add(jbtCancel); // Group labels JPanel jpLabels = new JPanel(); jpLabels.setLayout(new GridLayout(3, 0)); jpLabels.add(new JLabel("Red")); jpLabels.add(new JLabel("Green")); jpLabels.add(new JLabel("Blue")); // Group sliders for selecting red, green, and blue colors JPanel jpSliders = new JPanel(); jpSliders.setLayout(new GridLayout(3, 0)); jpSliders.add(jslRed); jpSliders.add(jslGreen); jpSliders.add(jslBlue); // Group jpLabels and jpSliders JPanel jpSelectColor = new JPanel(); jpSelectColor.setLayout(new BorderLayout()); jpSelectColor.setBorder(BorderFactory.createTitledBorder("Select Color")); jpSelectColor.add(jpLabels, BorderLayout.WEST); jpSelectColor.add(jpSliders, BorderLayout.CENTER); // Group jpSelectColor and jpSelectedColor JPanel jpColor = new JPanel(); jpColor.setLayout(new BorderLayout()); jpColor.add(jpSelectColor, BorderLayout.SOUTH); jpColor.add(jpSelectedColor, BorderLayout.CENTER); // Place jpButtons and jpColor into the dialog box getContentPane().add(jpButtons, BorderLayout.SOUTH); getContentPane().add(jpColor, BorderLayout.CENTER); pack(); jbtOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); jbtCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { color = null; setVisible(false); } }); jslRed.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { redValue = jslRed.getValue(); color = new Color(redValue, greenValue, blueValue); jpSelectedColor.setBackground(color); } }); jslGreen.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { greenValue = jslGreen.getValue(); color = new Color(redValue, greenValue, blueValue); jpSelectedColor.setBackground(color); } }); jslBlue.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { blueValue = jslBlue.getValue(); color = new Color(redValue, greenValue, blueValue); jpSelectedColor.setBackground(color); } }); }
/** Creating the configuration form */ private void init() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); enableCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); enableCheckBox.addActionListener(this); sipProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); sipProtocolCheckBox.addActionListener(this); jabberProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); jabberProtocolCheckBox.addActionListener(this); String rtpDescription = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); rtpProtocolCheckBox = new SIPCommCheckBox( resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + " " + rtpDescription); rtpProtocolCheckBox.addActionListener(this); rtpProtocolCheckBox.setToolTipText(rtpDescription); ice4jProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); ice4jProtocolCheckBox.addActionListener(this); JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; mainPanel.add(enableCheckBox, c); String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); JLabel descriptionLabel = new JLabel(label); descriptionLabel.setToolTipText(label); enableCheckBox.setToolTipText(label); descriptionLabel.setForeground(Color.GRAY); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); c.gridy = 1; c.insets = new Insets(0, 25, 10, 0); mainPanel.add(descriptionLabel, c); final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1)); loggersButtonPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL"))); loggersButtonPanel.add(sipProtocolCheckBox); loggersButtonPanel.add(jabberProtocolCheckBox); loggersButtonPanel.add(rtpProtocolCheckBox); loggersButtonPanel.add(ice4jProtocolCheckBox); c.insets = new Insets(0, 20, 10, 0); c.gridy = 2; mainPanel.add(loggersButtonPanel, c); final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2)); advancedPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED"))); fileCountField.getDocument().addDocumentListener(this); fileSizeField.getDocument().addDocumentListener(this); fileCountLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); advancedPanel.add(fileCountLabel); advancedPanel.add(fileCountField); fileSizeLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); advancedPanel.add(fileSizeLabel); advancedPanel.add(fileSizeField); c.gridy = 3; mainPanel.add(advancedPanel, c); archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); archiveButton.addActionListener(this); c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.gridx = 0; c.gridy = 4; mainPanel.add(archiveButton, c); if (!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); uploadLogsButton.addActionListener(this); c.insets = new Insets(10, 0, 0, 0); c.gridy = 5; mainPanel.add(uploadLogsButton, c); } }
public Component getCustomOptionComponent() { /* DEPTH */ final JSpinner jspnMaxDepth = new JSpinner(new SpinnerNumberModel(s_maxDepth + 1, 1, 100, 1)); jspnMaxDepth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { Integer value = (Integer) ((JSpinner) e.getSource()).getValue(); s_maxDepth = value - 1; logger.debug("maxDepth " + (s_maxDepth + 1)); } }); final JRadioButton jrbMaxDepth = new JRadioButton("Depth"); final JLabel lblMaxDepth = new JLabel("Depth: "); final JPanel jpMaxDepthSub = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jspnMaxDepth.setEnabled(b); lblMaxDepth.setEnabled(b); } }; jpMaxDepthSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); jpMaxDepthSub.add(lblMaxDepth); jpMaxDepthSub.add(jspnMaxDepth); /// final JPanel jpMaxDepth = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jrbMaxDepth.setEnabled(b); jpMaxDepthSub.setEnabled(b); } }; jpMaxDepth.setLayout(new BoxLayout(jpMaxDepth, BoxLayout.Y_AXIS)); jpMaxDepth.add(GuiUtil.addComponentAsFlow(jrbMaxDepth, FlowLayout.LEFT)); jpMaxDepth.add(GuiUtil.addComponentAsFlow(jpMaxDepthSub, FlowLayout.RIGHT)); /* REPETITION */ final JSpinner jspnMaxRept = new JSpinner(new SpinnerNumberModel(s_maxRept, 1, 100, 1)); jspnMaxRept.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { s_maxRept = (Integer) ((JSpinner) e.getSource()).getValue(); logger.debug("maxRept " + s_maxRept); } }); final JRadioButton jrbMaxRept = new JRadioButton("Repetition"); final JLabel lblMaxRept = new JLabel("Count: "); final JPanel jpMaxReptSub = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jspnMaxRept.setEnabled(b); lblMaxRept.setEnabled(b); } }; jpMaxReptSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); jpMaxReptSub.add(lblMaxRept); jpMaxReptSub.add(jspnMaxRept); final JPanel jpMaxRept = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jrbMaxRept.setEnabled(b); jpMaxReptSub.setEnabled(b); } }; jpMaxRept.setLayout(new BoxLayout(jpMaxRept, BoxLayout.Y_AXIS)); jpMaxRept.add(GuiUtil.addComponentAsFlow(jrbMaxRept, FlowLayout.LEFT)); jpMaxRept.add(GuiUtil.addComponentAsFlow(jpMaxReptSub, FlowLayout.RIGHT)); /////////////////////////////////////// final JLabel lbl = new JLabel("Limit search by:", SwingConstants.LEFT); final JPanel panel = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); lbl.setEnabled(b); jpMaxDepth.setEnabled(b); jpMaxRept.setEnabled(b); } @Override public void setVisible(boolean b) { super.setVisible(b); final JPanel p = this; // SwingUtilities.invokeLater( new Runnable() { // public void run() { Window win = SwingUtilities.getWindowAncestor(p); System.err.println(win); if (win != null) { System.err.println("packing"); win.pack(); } // } // } ); } }; panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); panel.add(GuiUtil.addComponentAsFlow(lbl, FlowLayout.LEFT)); panel.add(jpMaxDepth); panel.add(jpMaxRept); ButtonGroup bg = new ButtonGroup(); bg.add(jrbMaxDepth); bg.add(jrbMaxRept); /* CHECKBOX */ final JCheckBox chboxRepeat = new JCheckBox("Allow subtask recursive repetition", s_isSubtaskRepetitionAllowed); chboxRepeat.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_isSubtaskRepetitionAllowed == chboxRepeat.isSelected()) return; s_isSubtaskRepetitionAllowed = chboxRepeat.isSelected(); panel.setVisible(s_isSubtaskRepetitionAllowed); logger.debug("m_isSubtaskRepetitionAllowed " + s_isSubtaskRepetitionAllowed); } }); panel.setVisible(s_isSubtaskRepetitionAllowed); final JCheckBox chboxIncremental = new JCheckBox("Incremental", s_isIncremental); chboxIncremental.setToolTipText("Incremental depth-first search"); chboxIncremental.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_isIncremental == chboxIncremental.isSelected()) return; s_isIncremental = chboxIncremental.isSelected(); logger.debug("isIncremental " + s_isIncremental); } }); final JCheckBox chboxOptimize = new JCheckBox("Disable optimization in subtasks", s_disableOptimizationInSubtasks); chboxOptimize.setToolTipText("Use for debugging purposes"); chboxOptimize.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_disableOptimizationInSubtasks == chboxOptimize.isSelected()) return; s_disableOptimizationInSubtasks = chboxOptimize.isSelected(); logger.debug("disableOptimizationInSubtasks " + s_disableOptimizationInSubtasks); } }); JPanel container1 = new JPanel(); container1.setLayout(new BoxLayout(container1, BoxLayout.Y_AXIS)); container1.setBorder(BorderFactory.createTitledBorder("Planning settings")); container1.add(GuiUtil.addComponentAsFlow(chboxOptimize, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(chboxIncremental, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(chboxRepeat, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(panel, FlowLayout.LEFT)); JPanel container2 = new JPanel(new GridLayout(2, 0)); container2.setBorder(BorderFactory.createTitledBorder("Logging options")); final JCheckBox linear = new JCheckBox("Detailed linear planning", isLinearLoggingOn()); linear.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setLinearLoggingOn(linear.isSelected()); } }); container2.add(linear); final JCheckBox subtask = new JCheckBox("Detailed subtask planning", isSubtaskLoggingOn()); subtask.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setSubtaskLoggingOn(subtask.isSelected()); } }); container2.add(subtask); JPanel main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); main.add(container1); main.add(container2); return main; }
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = {"one", "two", "three", "four", "five", "six", "seven"}; String[] columnNames = {"French", "Spanish", "Italian"}; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane( output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
public ImageLabFrame() { // Set up menus JMenuBar menuBar = new JMenuBar(); JMenu imageLabMenu = new JMenu("imageLab"); menuBar.add(imageLabMenu); aboutItem = new JMenuItem("About imageLab"); imageLabMenu.add(aboutItem); quitItem = new JMenuItem("Quit"); imageLabMenu.add(quitItem); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); openItem = new JMenuItem("Open File..."); fileMenu.add(openItem); saveItem = new JMenuItem("Save As..."); fileMenu.add(saveItem); JMenu imageMenu = new JMenu("Images"); menuBar.add(imageMenu); addPictureGenerator(imageMenu, new Stripe()); JMenu filterMenu = new JMenu("Filters"); menuBar.add(filterMenu); addFilter(filterMenu, new BWFilter()); filterMenu.addSeparator(); addScalableFilter(filterMenu, new SwirlFilter()); // Listeners for filters are added in addScalableFilter aboutItem.addActionListener(this); quitItem.addActionListener(this); openItem.addActionListener(this); saveItem.addActionListener(this); // Set up rest of GUI lab = initialImage().getJLabel(); slider = new JSlider(0, 100); sliderPanel = new JPanel(); sliderPanel.add(slider); sliderPanel.setVisible(false); Border b1 = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); border = BorderFactory.createTitledBorder(b1, ""); sliderPanel.setBorder(border); slider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { double scale = (slider.getValue() - 50) / 50.0; currentFilter.apply(pic1, pic2, scale); lab.setIcon(pic2.getJLabel().getIcon()); repaint(); } }); JPanel panel = new JPanel(new BorderLayout()); getContentPane().add(panel); panel.add(lab, BorderLayout.NORTH); panel.add(sliderPanel, BorderLayout.SOUTH); setJMenuBar(menuBar); pack(); setTitle("imageLab"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Prepare file chooser chooser = new JFileChooser(new File(".")); FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG Images", "jpg"); chooser.setFileFilter(filter); }
public DownloadGUI() { setTitle("Rav's Download Manager"); setSize(640, 480); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { actionExit(); } }); JPanel addPanel = new JPanel(); pauseButton = new JButton("", new ImageIcon("icons/pause.gif")); pauseButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionPause(); } }); pauseButton.setEnabled(false); addPanel.add(pauseButton); resumeButton = new JButton("", new ImageIcon("icons/resume.gif")); resumeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionResume(); } }); resumeButton.setEnabled(false); addPanel.add(resumeButton); cancelButton = new JButton("", new ImageIcon("icons/cancel.gif")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionCancel(); } }); cancelButton.setEnabled(false); addPanel.add(cancelButton); clearButton = new JButton("", new ImageIcon("icons/clear.gif")); clearButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionClear(); } }); clearButton.setEnabled(false); addPanel.add(clearButton); JPanel addPane2 = new JPanel(); addTextField = new JTextField(30); addPane2.add(addTextField); JButton addButton = new JButton("", new ImageIcon("icons/add.gif")); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionAdd(); } }); addPane2.add(addButton); tableModel = new DownloadList(); table = new JTable(tableModel); table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { tableSelectionChanged(); } }); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ProgressBar renderer = new ProgressBar(0, 100); renderer.setStringPainted(true); table.setDefaultRenderer(JProgressBar.class, renderer); table.setRowHeight((int) renderer.getPreferredSize().getHeight()); JPanel downloadsPanel = new JPanel(); downloadsPanel.setBorder(BorderFactory.createTitledBorder("Downloads")); downloadsPanel.setLayout(new BorderLayout()); downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER); getContentPane().setLayout(new GridLayout(3, 1)); getContentPane().add(addPane2); getContentPane().add(addPanel); getContentPane().add(downloadsPanel); }
public MainPanel() { super(new BorderLayout()); add(new JScrollPane(makeTable())); setBorder(BorderFactory.createTitledBorder("Multiple Buttons in a Table Cell")); setPreferredSize(new Dimension(320, 240)); }
public DOMTreeView(Document dom) { super("TreeWalkerView "); document = dom; // jtree UI setup jtree = new DOMTreeFull((Node) document); jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes, call nodeSelected(node) jtree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { TreePath path = (TreePath) e.getPath(); TreeNode treeNode = (TreeNode) path.getLastPathComponent(); if (jtree.getSelectionModel().isPathSelected(path)) nodeSelected(treeNode); } }); treeScroll = new JScrollPane(jtree); treeScroll.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("DOM Tree View"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); JPanel urlPanel = new JPanel(); JLabel urlLabel = new JLabel("URL:"); urlTextField = new JTextField(50); urlTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == urlTextField) { reloadJTree(urlTextField.getText()); } } }); urlPanel.add(urlLabel); urlPanel.add(urlTextField); JPanel selectedXPathPanel = new JPanel(); JLabel xpathLabel = new JLabel("XPath: "); selectedXPathTextField = new JTextField(50); selectedXPathTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == selectedXPathTextField) { lookupByXPath(selectedXPathTextField.getText()); } } }); selectedXPathPanel.add(xpathLabel); selectedXPathPanel.add(selectedXPathTextField); JPanel lookupPanel = new JPanel(); JLabel lookupLabel = new JLabel("look up:"); lookupTextField = new JTextField(20); lookupTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == lookupTextField) { lookup(lookupTextField.getText()); } } }); foundList = new JList(); foundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); foundList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { Object source = evt.getSource(); if (source == foundList) { FoundItem fi = (FoundItem) foundList.getSelectedValue(); if (fi == null) return; jtree.setSelectionPath(fi.treePath); jtree.scrollPathToVisible(fi.treePath); } } }); JScrollPane foundScroll = new JScrollPane(foundList); foundScroll.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Nodes found"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); // foundScroll.set JPanel queryPanel = new JPanel(); queryPanel.add(lookupLabel); queryPanel.add(lookupTextField); lookupPanel.setLayout(new BorderLayout()); lookupPanel.add(queryPanel, BorderLayout.NORTH); lookupPanel.add(foundScroll, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, lookupPanel); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(400); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(urlPanel, BorderLayout.NORTH); mainPanel.add(selectedXPathPanel, BorderLayout.SOUTH); mainPanel.add(splitPane, BorderLayout.CENTER); // mainPanel.add(treeScroll, BorderLayout.CENTER); // mainPanel.add(lookupPanel, BorderLayout.EAST); getContentPane().add(mainPanel); }
/** Fills the panel with event specific fields. */ protected void fillPanel() { JLabel l; Box fdp = Box.createVerticalBox(); fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram")); fdChart = makeFDChart(); ChartPanel cp = new ChartPanel(fdChart); cp.setMinimumDrawWidth(100); cp.setMinimumDrawHeight(60); cp.setPreferredSize(new Dimension(250, 80)); fdp.add(new JScrollPane(cp)); JPanel prmp = new JPanel(new SpringLayout()); l = new JLabel("Capacity:", JLabel.TRAILING); prmp.add(l); spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0)); spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00")); spinMaxFlow.addChangeListener(this); spinMaxFlow.setName(nmSpinMaxFlow); l.setLabelFor(spinMaxFlow); prmp.add(spinMaxFlow); l = new JLabel("Cap.Drop:", JLabel.TRAILING); prmp.add(l); spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0)); spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00")); spinCapDrop.addChangeListener(this); spinCapDrop.setName(nmSpinCapDrop); l.setLabelFor(spinCapDrop); prmp.add(spinCapDrop); l = new JLabel("C.Density:", JLabel.TRAILING); prmp.add(l); spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0)); spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00")); spinCritDen.addChangeListener(this); spinCritDen.setName(nmSpinCritDen); l.setLabelFor(spinCritDen); prmp.add(spinCritDen); l = new JLabel(" V:", JLabel.TRAILING); prmp.add(l); spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0)); spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00")); spinVff.addChangeListener(this); spinVff.setName(nmSpinVff); l.setLabelFor(spinVff); prmp.add(spinVff); l = new JLabel("J.Density:", JLabel.TRAILING); prmp.add(l); spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0)); spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00")); spinJamDen.addChangeListener(this); spinJamDen.setName(nmSpinJamDen); l.setLabelFor(spinJamDen); prmp.add(spinJamDen); l = new JLabel(" W:", JLabel.TRAILING); prmp.add(l); if (jd == cd) jd = cd + 1; int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999); spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0)); spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00")); spinWc.addChangeListener(this); spinWc.setName(nmSpinWc); l.setLabelFor(spinWc); prmp.add(spinWc); SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2); fdp.add(prmp); // add(new JScrollPane(fdp)); add(fdp); return; }
/** Initializes all GUI components */ private void initComponents() { mainPanel = new JPanel(); editPanel = new JPanel(); editPanelLeft = new JPanel(); editPanelCenter = new JPanel(); editPanelRight = new JPanel(); tablePanel = new JPanel(); companyIdTextField = new JTextField(); companyIdTextField.setEditable(false); companyNameTextField = new JTextField(); urlTextField = new JTextField(); insuranceTypesTextField = new JTextField(); telephoneTextField = new JTextField(); percentageTextField = new JTextField(); percentageTextField.setToolTipText("<html>Only <b>numerical</b> values allowed</html>"); searchTextField = new JTextField(); searchTextField.setToolTipText( "<html>Use either <b>AND</b> or <b>OR</b> for combined search queries<br>You can also use <b>spaces</b> instead of <b>OR</b></html>"); generalDescriptionTextField = new JTextField(); companyIdLabel = new InsuranceCompanyLabel("ID"); companyNameLabel = new InsuranceCompanyLabel("Company"); urlLabel = new InsuranceCompanyLabel("Website"); insuranceTypesLabel = new InsuranceCompanyLabel("Insurance Types"); telephoneLabel = new InsuranceCompanyLabel("Telephone"); percentageLabel = new InsuranceCompanyLabel("Broker Percentage"); searchLabel = new InsuranceCompanyLabel("Search Insurance Types"); generalDescriptionLabel = new InsuranceCompanyLabel("General Description"); sortLabel = new InsuranceCompanyLabel("Sorting"); addInsuranceCompanyButton = new InsuranceCompanyButton("New Insurance Company", 190, 45); addInsuranceCompanyButton.setToolTipText( "<html>Create a new <b>empty</b> Insurance Company</html>"); saveInsuranceCompanyButton = new InsuranceCompanyButton("Save Insurance Company", 190, 45); saveInsuranceCompanyButton.setToolTipText( "<html>Save the <b>selected</b> Insurance Company<br>Hint: Press <b>Enter</b> to quickly save an entry</html>"); saveInsuranceCompanyButton.setDefaultCapable(true); getRootPane() .setDefaultButton( saveInsuranceCompanyButton); // Set the save button as default button, so quicker // editing by pressing Enter is possible deleteInsuranceCompanyButton = new InsuranceCompanyButton("Delete Insurance Company", 190, 45); deleteInsuranceCompanyButton.setToolTipText( "<html>Delete the <b>selected</b> Insurance Company</html>"); clearSearchButton = new InsuranceCompanyButton("x", 40, 35); clearSearchButton.setToolTipText("<html>Click to <b>clear</b> the search field</html>"); String[] sortStrategies = {"ID", "Company Name", "Percentage"}; sortComboBox = new JComboBox(sortStrategies); tableData = new InsuranceCompanyTableModel(model.getInsuranceCompanies()); insuranceCompaniesTable = new JTable(); insuranceCompanyScrollPane = new JScrollPane(insuranceCompaniesTable); // Set layout and add components to panels setLayout(new BorderLayout()); add(mainPanel, BorderLayout.CENTER); mainPanel.setLayout(new BorderLayout()); mainPanel.add(editPanel, BorderLayout.NORTH); editPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); editPanel.setLayout(new BorderLayout()); editPanel.add(editPanelLeft, BorderLayout.CENTER); editPanelLeft.setBorder(new EmptyBorder(0, 0, 5, 15)); editPanelLeft.setLayout(new GridLayout(4, 4, 5, 0)); editPanelLeft.add(companyIdLabel); editPanelLeft.add(companyNameLabel); editPanelLeft.add(urlLabel); editPanelLeft.add(telephoneLabel); editPanelLeft.add(companyIdTextField); editPanelLeft.add(companyNameTextField); editPanelLeft.add(urlTextField); editPanelLeft.add(telephoneTextField); editPanelLeft.add(percentageLabel); editPanelLeft.add(searchLabel); editPanelLeft.add(new JLabel()); editPanelLeft.add(sortLabel); editPanelLeft.add(percentageTextField); editPanelLeft.add(searchTextField); Container searchBox = Box.createVerticalBox(); searchBox.add(clearSearchButton); editPanelLeft.add(searchBox); editPanelLeft.add(sortComboBox); editPanel.add(editPanelRight, BorderLayout.EAST); Container box = Box.createVerticalBox(); box.add(saveInsuranceCompanyButton); box.add(Box.createVerticalStrut(5)); box.add(addInsuranceCompanyButton); box.add(Box.createVerticalStrut(5)); box.add(deleteInsuranceCompanyButton); editPanelRight.add(box); editPanel.add(editPanelCenter, BorderLayout.SOUTH); editPanelCenter.setLayout(new GridLayout(4, 1)); editPanelCenter.add(insuranceTypesLabel); editPanelCenter.add(insuranceTypesTextField); editPanelCenter.add(generalDescriptionLabel); editPanelCenter.add(generalDescriptionTextField); mainPanel.add(tablePanel, BorderLayout.CENTER); tablePanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10), "Insurance Companies Overview")); tablePanel.setLayout(new BorderLayout()); tablePanel.add(insuranceCompanyScrollPane, BorderLayout.CENTER); setMinimumSize(new Dimension(800, 600)); setPreferredSize(new Dimension(900, 600)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); }
private void setupUI() { JPanel batchInputPanel = new JPanel(); batchInputPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); batchInputPanel.setEnabled(true); this.add( batchInputPanel, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); batchInputPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null)); final Spacer spacer3 = new Spacer(); batchInputPanel.add( spacer3, new GridConstraints( 6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(195, 14), null, 0, false)); dpiXLabel = new JLabel("DPI X: "); batchInputPanel.add( dpiXLabel, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); dpiYLabel = new JLabel("DPI Y: "); batchInputPanel.add( dpiYLabel, new GridConstraints( 3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); startDepthLabel = new JLabel("Start Depth (meter): "); batchInputPanel.add( startDepthLabel, new GridConstraints( 4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); depthIncLabel = new JLabel("Depth Increment (meter): "); batchInputPanel.add( depthIncLabel, new GridConstraints( 5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); dpiXField = new JTextField(); dpiXField.setEnabled(false); dpiXField.setHorizontalAlignment(11); dpiYField = new JTextField(); dpiYField.setEnabled(false); dpiYField.setHorizontalAlignment(11); batchInputPanel.add( dpiXField, new GridConstraints( 2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); batchInputPanel.add( dpiYField, new GridConstraints( 3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); startDepthField = new JTextField(); startDepthField.setEnabled(false); startDepthField.setHorizontalAlignment(11); batchInputPanel.add( startDepthField, new GridConstraints( 4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); depthIncField = new JTextField(); depthIncField.setEnabled(false); depthIncField.setHorizontalAlignment(11); batchInputPanel.add( depthIncField, new GridConstraints( 5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); final JPanel applyPanel = new JPanel(); applyPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); batchInputPanel.add( applyPanel, new GridConstraints( 6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); applyToAllButton = new JButton("Apply to All Rows"); applyToAllButton.setEnabled(false); applyPanel.add( applyToAllButton, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); applyToSelectedButton = new JButton("Apply to Selected Rows"); applyToSelectedButton.setEnabled(false); applyPanel.add( applyToSelectedButton, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); // final Spacer spacer4 = new Spacer(); // applyPanel.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, // GridConstraints.FILL_HORIZONTAL, // GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); orientationComboBox = new JComboBox(); orientationComboBox.setEnabled(false); final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); defaultComboBoxModel1.addElement("Horizontal"); defaultComboBoxModel1.addElement("Vertical"); defaultComboBoxModel1.addElement("[Blank]"); orientationComboBox.setModel(defaultComboBoxModel1); orientationComboBox.setSelectedIndex(2); // [Blank] batchInputPanel.add( orientationComboBox, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); lengthLabel = new JLabel("Length (meter): "); batchInputPanel.add( lengthLabel, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); lengthField = new JTextField(); lengthField.setEnabled(false); lengthField.setHorizontalAlignment(11); batchInputPanel.add( lengthField, new GridConstraints( 1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); orientationLabel = new JLabel("Orientation: "); batchInputPanel.add( orientationLabel, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); useBatchInputCheckbox = new JCheckBox(); useBatchInputCheckbox.setText("Batch input: blank fields will not be applied"); this.add( useBatchInputCheckbox, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); onBatch(); }
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