List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:QandE.LunarPhasesRB.java
private void addWidgets() { /*/*from ww w.j a v a 2 s. co m*/ * Create a label for displaying the moon phase images and * put a border around it. */ phaseIconLabel = new JLabel(); phaseIconLabel.setHorizontalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalTextPosition(JLabel.CENTER); phaseIconLabel.setHorizontalTextPosition(JLabel.CENTER); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), phaseIconLabel.getBorder())); //Create radio buttons with lunar phase choices. JRadioButton newButton = new JRadioButton("New"); newButton.setActionCommand("0"); newButton.setSelected(true); JRadioButton waxingCrescentButton = new JRadioButton("Waxing Crescent"); waxingCrescentButton.setActionCommand("1"); JRadioButton firstQuarterButton = new JRadioButton("First Quarter"); firstQuarterButton.setActionCommand("2"); JRadioButton waxingGibbousButton = new JRadioButton("Waxing Gibbous"); waxingGibbousButton.setActionCommand("3"); JRadioButton fullButton = new JRadioButton("Full"); fullButton.setActionCommand("4"); JRadioButton waningGibbousButton = new JRadioButton("Waning Gibbous"); waningGibbousButton.setActionCommand("5"); JRadioButton thirdQuarterButton = new JRadioButton("Third Quarter"); thirdQuarterButton.setActionCommand("6"); JRadioButton waningCrescentButton = new JRadioButton("Waning Crescent"); waningCrescentButton.setActionCommand("7"); // Create a button group and add the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(newButton); group.add(waxingCrescentButton); group.add(firstQuarterButton); group.add(waxingGibbousButton); group.add(fullButton); group.add(waningGibbousButton); group.add(thirdQuarterButton); group.add(waningCrescentButton); // Display the first image. phaseIconLabel.setIcon(new ImageIcon("images/image0.jpg")); phaseIconLabel.setText(""); //Make the radio buttons appear in a center-aligned column. selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.PAGE_AXIS)); selectPanel.setAlignmentX(Component.CENTER_ALIGNMENT); //Add a border around the select panel. selectPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Select Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add a border around the display panel. displayPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Display Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add image and moon phases radio buttons to select panel. displayPanel.add(phaseIconLabel); selectPanel.add(newButton); selectPanel.add(waxingCrescentButton); selectPanel.add(firstQuarterButton); selectPanel.add(waxingGibbousButton); selectPanel.add(fullButton); selectPanel.add(waningGibbousButton); selectPanel.add(thirdQuarterButton); selectPanel.add(waningCrescentButton); //Listen to events from the radio buttons. newButton.addActionListener(this); waxingCrescentButton.addActionListener(this); firstQuarterButton.addActionListener(this); waxingGibbousButton.addActionListener(this); fullButton.addActionListener(this); waningGibbousButton.addActionListener(this); thirdQuarterButton.addActionListener(this); waningCrescentButton.addActionListener(this); }
From source file:components.LayeredPaneDemo.java
private JPanel createControlPanel() { onTop = new JCheckBox("Top Position in Layer"); onTop.setSelected(true);//from w w w . j av a2 s .co m onTop.setActionCommand(ON_TOP_COMMAND); onTop.addActionListener(this); layerList = new JComboBox(layerStrings); layerList.setSelectedIndex(2); //cyan layer layerList.setActionCommand(LAYER_COMMAND); layerList.addActionListener(this); JPanel controls = new JPanel(); controls.add(layerList); controls.add(onTop); controls.setBorder(BorderFactory.createTitledBorder("Choose Duke's Layer and Position")); return controls; }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public COSMOSACDialog() { super("JCOSMO Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); db = COSMOSACDataBase.getInstance(); COSMOSAC models[] = new COSMOSAC[5]; models[0] = new COSMOSAC(); models[1] = new COSMOPAC(); models[2] = new COSMOSAC_SVP(); models[3] = new COSMOSAC_G(); models[4] = new PCMSAC(); modelBox = new JComboBox(models); modelBox.addActionListener(this); JPanel north = new JPanel(new GridLayout(0, 2)); add(north, BorderLayout.NORTH); JPanel northAba1 = new JPanel(new GridLayout(0, 4)); JPanel northAba2 = new JPanel(new GridLayout(0, 2)); //Where the GUI is created: JMenuBar menuBar;/*from w w w. j a v a2 s .c o m*/ JMenu file, help; JMenuItem menuItem; //Create the menu bar. menuBar = new JMenuBar(); // the file menu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); menuBar.add(file); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.setActionCommand(QUIT); menuItem.addActionListener(this); file.add(menuItem); // the help menu help = new JMenu("Help"); file.setMnemonic(KeyEvent.VK_H); menuBar.add(help); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItem.setActionCommand(ABOUT); menuItem.addActionListener(this); help.add(menuItem); setJMenuBar(menuBar); listModel = new DefaultListModel(); list = new JList(listModel); list.setBorder(BorderFactory.createTitledBorder("compounds")); list.setVisibleRowCount(2); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listScrollPane = new JScrollPane(list); JButton addButton = new JButton("Add"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddCompoundDialog(COSMOSACDialog.this); } }); removeButton = new JButton("Remove"); removeButton.addActionListener(this); visibRemove(false); JButton calcButton = new JButton("Calculate"); calcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildChart(); rebuildSigmaProfiles(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildSigmaProfiles(); } }); ignoreSGButton = new JCheckBox("Ignore SG"); ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term"); ignoreSGButton.addActionListener(this); JPanel but = new JPanel(new GridLayout(0, 1)); but.add(addButton, BorderLayout.EAST); but.add(removeButton, BorderLayout.EAST); but.add(modelBox); north.add(listScrollPane); north.add(but); northAba1.add(new JLabel("Temperature [K]")); northAba1.add(temperature = new JTextField(10)); temperature.setText("298"); northAba1.add(new JLabel("Sigma HB")); northAba1.add(sigmaHB = new JTextField(10)); northAba1.add(new JLabel("Sigma HB2")); northAba1.add(sigmaHB2 = new JTextField(10)); northAba1.add(new JLabel("Sigma HB3")); northAba1.add(sigmaHB3 = new JTextField(10)); northAba1.add(new JLabel("Charge HB")); northAba1.add(chargeHB = new JTextField(10)); northAba1.add(new JLabel("Sigma Disp")); northAba1.add(sigmaDisp = new JTextField(10)); northAba1.add(new JLabel("Charge Disp")); northAba1.add(chargeDisp = new JTextField(10)); northAba1.add(new JLabel("Beta")); northAba1.add(beta = new JTextField(10)); northAba1.add(new JLabel("fpol")); northAba1.add(fpol = new JTextField(10)); northAba1.add(new JLabel("Anorm")); northAba1.add(anorm = new JTextField(10)); northAba1.add(ignoreSGButton); northAba1.add(calcButton); northAba2.add(new JLabel("")); northAba2.add(refreshButton); // chart = new JLineChart(); // add(chart, BorderLayout.CENTER); // chart.setTitle("Gamma Plot"); // chart.setSubtitle(""); // chart.setXAxisLabel("Mole Fraction, x_1"); // chart.setYAxisLabel("ln gamma, gE/RT"); // chart.setSource(getTitle()); // chart.setLegendPosition(LegendPosition.BOTTOM); // chart.setShapesVisible(true); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(new Range(0.0, 1.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setUseFillPaint(true); r.setBaseFillPaint(Color.white); r.setBaseShapesVisible(true); JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null, PlotOrientation.VERTICAL, true, true, false); sigmaProfilePlot = sigmaProfileChart.getXYPlot(); sigmaProfilePlot.getDomainAxis().setAutoRange(false); sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025)); // sigmaProfilePlot.setBackgroundPaint(Color.lightGray); // sigmaProfilePlot.setDomainGridlinePaint(Color.white); // sigmaProfilePlot.setRangeGridlinePaint(Color.white); JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null, PlotOrientation.VERTICAL, true, true, false); plotSegGamma = (XYPlot) chartSegGamma.getPlot(); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(lnGammaInf1Label = new JLabel()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(lnGammaInf2Label = new JLabel()); south.add(Box.createHorizontalStrut(20)); south.add(new JLabel("<html>γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(gammaInf1Label = new JLabel()); south.add(new JLabel("<html>γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(gammaInf2Label = new JLabel()); JPanel aba1 = new JPanel(new BorderLayout()); aba1.add(northAba1, BorderLayout.NORTH); JPanel chartsPanel = new JPanel(new GridLayout(0, 2)); aba1.add(chartsPanel, BorderLayout.CENTER); chartsPanel.add(new ChartPanel(chart)); chartsPanel.add(new ChartPanel(chartSegGamma)); aba1.add(south, BorderLayout.SOUTH); JPanel aba2 = new JPanel(new BorderLayout()); aba2.add(northAba2, BorderLayout.NORTH); aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("gamma", aba1); tabbedPane.addTab("sigma", aba2); add(tabbedPane, BorderLayout.CENTER); // cosmosac.setAEffPrime(6.596176570595075); // cosmosac.setCoord(11.614599507917934); // cosmosac.setVnorm(56.36966406129967); // cosmosac.setAnorm(41.56058649432742); // cosmosac.setCHB(65330.19484947528); // cosmosac.setSigmaHB(0.008292411048046008); //Display the window. setSize(800, 600); setLocationRelativeTo(null); modelBox.setSelectedIndex(0); setVisible(true); // test for a mixture // addList("WATER"); // addList("H3O+1"); // addList("OH-1"); // addList("CL-1"); // addList("OXYGEN"); // addList("sec-butylamine"); // addList("hydrogen-fluoride"); // addList("ACETONE"); // addList("METHANOL"); // addList("ACETONE.opt"); // addList("METHANOL.opt"); // addList("METHYL-ETHYL-KETONE"); // addList("ETHANOL"); // addList("N-HEPTANE"); // addList("PROPIONIC-ACID"); // addList("EMIM"); // addList("NTF2"); // addList("DCA"); // addList("N-OCTANE"); addList("ETHYLENE CARBONATE"); addList("BENZENE"); addList("TOLUENE"); removeButton.setEnabled(true); }
From source file:net.mitnet.tools.pdf.book.publisher.ui.gui.BookPublisherGUI2.java
/** * Initialise widgets.// w w w . j a va 2 s. c o m */ protected void initComponents() { // frame this.frame = new JFrame(); this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.frame.setTitle(FRAME_TITLE); // input dir panel inputDirLabel = new JLabel(); inputDirLabel.setText("Input Folder:"); inputDirField = new JTextField(); inputDirField.setColumns(FILE_TEXTFIELD_WIDTH); inputDirButton = new JButton(); inputDirButton.setText("Browse ..."); inputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { inputDirButtonActionHandler(event); } }); JPanel inputDirPanel = new JPanel(); // inputDirPanel.setLayout( new BoxLayout( inputDirPanel, BoxLayout.X_AXIS ) ); inputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); inputDirPanel.add(inputDirLabel); inputDirPanel.add(inputDirField); inputDirPanel.add(inputDirButton); // output dir panel outputDirLabel = new JLabel(); outputDirLabel.setText("Output Folder:"); outputDirField = new JTextField(); outputDirField.setColumns(FILE_TEXTFIELD_WIDTH); outputDirButton = new JButton(); outputDirButton.setText("Browse ..."); outputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { outputDirButtonActionHandler(event); } }); JPanel outputDirPanel = new JPanel(); // outputDirPanel.setLayout( new BoxLayout( outputDirPanel, BoxLayout.X_AXIS ) ); outputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); outputDirPanel.add(outputDirLabel); outputDirPanel.add(outputDirField); outputDirPanel.add(outputDirButton); // document control panel docControlPanel = new JPanel(); docControlPanel.setLayout(new BoxLayout(docControlPanel, BoxLayout.Y_AXIS)); docControlPanel.add(inputDirPanel); docControlPanel.add(outputDirPanel); // Border docControlPanelBorder = BorderFactory.createTitledBorder("Documents"); Border docControlPanelBorder = BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Documents"), BorderFactory.createEmptyBorder(5, 5, 5, 5)); docControlPanel.setBorder(docControlPanelBorder); // publish button publishButton = new JButton(); publishButton.setText("Publish"); publishButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { publishButtonActionHandler(event); } }); // status message label statusMessageLabel = new JLabel(); // String statusMessageText = "Press " + publishButton.getText() + " to start."; String statusMessageText = ""; statusMessageLabel.setText(statusMessageText); // statusMessageLabel.setVisible(false); // progress bar progressBar = new JProgressBar(); // exit button exitButton = new JButton(); exitButton.setText("Exit"); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { exitButtonActionHandler(event); } }); // build main panel JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(docControlPanel); // mainPanel.add(new Spacer()); mainPanel.add(publishButton); // mainPanel.add(new Spacer()); mainPanel.add(progressBar); // mainPanel.add(new Spacer()); mainPanel.add(statusMessageLabel); // mainPanel.add(new Spacer()); mainPanel.add(exitButton); // add main panel to frame this.frame.getContentPane().setLayout(new BoxLayout(this.frame.getContentPane(), BoxLayout.Y_AXIS)); this.frame.getContentPane().add(mainPanel); // this.frame.setSize(800,600); this.frame.pack(); }
From source file:fuel.gui.stats.MotorStatsPanel.java
private void refreshGraphs(Motorcycle motor) { graphContainer.removeAll();//w w w . jav a 2 s . c o m if (motor != null) { DefaultPieDataset usageDataset = new DefaultPieDataset(); try { ResultSet thisMotor = database .Query("SELECT SUM(distance) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); ResultSet otherMotors = database.Query( "SELECT SUM(distance) FROM fuelrecords WHERE NOT motorcycleId = " + motor.getId(), true); thisMotor.next(); otherMotors.next(); usageDataset.setValue(motor.toString(), thisMotor.getInt("1")); usageDataset.setValue("Andere motoren", otherMotors.getInt("1")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart usagePiechart = ChartFactory.createPieChart3D("", usageDataset, true, true, false); PiePlot3D plot3 = (PiePlot3D) usagePiechart.getPlot(); plot3.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel usagePiechartPanel = new ChartPanel(usagePiechart); usagePiechartPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Motorgebruik"))); usagePiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); usagePiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset stationDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet numberStations = database.Query( "SELECT DISTINCT stationId FROM fuelrecords WHERE stationId = " + station.getId(), true); if (numberStations.next()) { ResultSet otherMotors = database.Query("SELECT COUNT(*) FROM fuelrecords WHERE stationId = " + station.getId() + " AND motorcycleId = " + motor.getId(), true); otherMotors.next(); if (otherMotors.getInt("1") > 0) { stationDataset.setValue(station.toString(), otherMotors.getInt("1")); } } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart stationPiechart = ChartFactory.createPieChart3D("", stationDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) stationPiechart.getPlot(); plot2.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel stationPiechartPanel = new ChartPanel(stationPiechart); stationPiechartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Tankstation verhouding"))); stationPiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); stationPiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset fuelDataset = new DefaultPieDataset(); try { ResultSet numberResults = database.Query("SELECT DISTINCT typeOfGas FROM fuelrecords", true); while (numberResults.next()) { ResultSet thisStation = database.Query( "SELECT SUM(liter) FROM fuelrecords WHERE typeOfGas = '" + numberResults.getString("typeOfGas") + "'AND motorcycleId = " + motor.getId(), true); thisStation.next(); if (thisStation.getDouble("1") > 0) { fuelDataset.setValue(numberResults.getString("TYPEOFGAS"), thisStation.getDouble("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot1 = (PiePlot3D) fuelPieChart.getPlot(); plot1.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel fuelPieChartPanel = new ChartPanel(fuelPieChart); fuelPieChartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Brandstof verhouding"))); fuelPieChartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database .Query("SELECT distance/liter,date FROM fuelrecords WHERE motorcycleId = " + motor.getId() + " ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("DATE"), "Verbruik"); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart barChart = ChartFactory.createBarChart3D("", // chart title "", // domain axis label "Aantal", // range axis label barDataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = barChart.getCategoryPlot(); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); ChartPanel barChartPanel = new ChartPanel(barChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder("Verbruik")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); barChartPanel.setLayout(new BorderLayout()); JPanel piePanel = new JPanel(new GridLayout(0, 3)); piePanel.add(usagePiechartPanel); piePanel.add(stationPiechartPanel); piePanel.add(fuelPieChartPanel); //uitgaven DefaultPieDataset expensesDataset = new DefaultPieDataset(); try { Map<String, ResultSet> allCosts = new HashMap<String, ResultSet>(); ResultSet fuelCosts = database .Query("SELECT SUM(cost) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); allCosts.put("Brandstof", fuelCosts); ResultSet expenses = database.Query("SELECT DISTINCT categoryid FROM expenses", true); while (expenses.next()) { ResultSet set = database.Query("SELECT SUM(costs) FROM expenses WHERE categoryid = " + expenses.getInt("categoryid") + " AND motorcycleid = " + motor.getId(), true); ResultSet set2 = database .Query("SELECT name FROM categories WHERE id = " + expenses.getInt("categoryid"), true); set2.next(); allCosts.put(set2.getString("name"), set); } for (Map.Entry<String, ResultSet> element : allCosts.entrySet()) { element.getValue().next(); if (element.getValue().getInt("1") > 0) { expensesDataset.setValue(element.getKey(), element.getValue().getInt("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart expensesPiechart = ChartFactory.createPieChart3D("", expensesDataset, true, true, false); PiePlot3D plot4 = (PiePlot3D) expensesPiechart.getPlot(); plot4.setForegroundAlpha(0.6f); JPanel expensesPiePanel = new ChartPanel(expensesPiechart); expensesPiePanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Uitgaven"))); expensesPiePanel.setPreferredSize(new java.awt.Dimension(240, 240)); expensesPiePanel.setLayout(new BorderLayout()); graphContainer.add(piePanel); graphContainer.add(barChartPanel); graphContainer.add(expensesPiePanel); } revalidate(); repaint(); }
From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern")); this.add(patternLabel); filenamePattern = new JTextField(); filenamePattern.setPreferredSize(/*from w w w . ja v a 2 s. c o m*/ new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); filenamePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory findUndoManager = new UndoHistory(); findUndoManager.registerUndoHistory(filenamePattern); findUndoManager.registerSnapshotHistory(filenamePattern); componentRepository.getReplaceCommand().addResetable(findUndoManager); filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setPatternString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(filenamePattern); this.add(filenamePattern); JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case")); caseBox.setSelected(true); caseBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseBox); JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression")); regexBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(regexBox); JPanel extensionPanel = new JPanel(); extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension"))); extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60)); extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100)); ButtonGroup extensionGroup = new ButtonGroup(); JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension")); protectButton.setSelected(true); protectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setProtectExtension(true); updateFileTable(); } }); extensionGroup.add(protectButton); extensionPanel.add(protectButton); JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension")); includeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(false); dataModel.setProtectExtension(false); updateFileTable(); } }); extensionGroup.add(includeButton); extensionPanel.add(includeButton); JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension")); onlyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(true); updateFileTable(); } }); extensionGroup.add(onlyButton); extensionPanel.add(onlyButton); this.add(extensionPanel); this.add(Box.createVerticalGlue()); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // replace JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern")); this.add(replaceLabel); replacePattern = new JTextField(); replacePattern.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); replacePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory undoManager = new UndoHistory(); undoManager.registerUndoHistory(replacePattern); undoManager.registerSnapshotHistory(replacePattern); componentRepository.getReplaceCommand().addResetable(undoManager); replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setReplacementString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(replacePattern); this.add(replacePattern); // treat case JPanel modifyCasePanel = new JPanel(); modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case"))); modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS)); modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT); modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100)); modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200)); ButtonGroup modifyCaseGroup = new ButtonGroup(); ActionListener radioButtonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd)); updateFileTable(); } }; JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case")); lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name()); lowerButton.addActionListener(radioButtonListener); modifyCaseGroup.add(lowerButton); modifyCasePanel.add(lowerButton); JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case")); upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name()); upperButton.addActionListener(radioButtonListener); modifyCaseGroup.add(upperButton); modifyCasePanel.add(upperButton); JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case")); keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name()); keepButton.setSelected(true); keepButton.addActionListener(radioButtonListener); modifyCaseGroup.add(keepButton); modifyCasePanel.add(keepButton); this.add(modifyCasePanel); // prevent case conflict JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict")); caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT); caseConflictBox.setSelected(true); caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows caseConflictBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseConflictBox); this.add(Box.createVerticalGlue()); }
From source file:mulavito.gui.components.GraphPanel.java
private void addLayer(L layer) { // Create and add the vv. LV vv = createLayerViewer(layer);/*from w ww . j av a 2 s. c o m*/ vvs.add(vv); // Do all settings for the vv. configViewerTransform(vv); for (ViewerContext<L, LV> ctx : contexts) ctx.configVisualizationViewer(vv); // Do GUI stuff from here on. MyGraphZoomScrollPane zsp = new MyGraphZoomScrollPane(vv); zsp.setBorder(BorderFactory.createTitledBorder(layer.getLabel())); // zsp.setPreferredSize(getGraphSize()); // zsp.setMaximumSize(getGraphSize()); contentPane.add(zsp); firePropertyChange("Viewers", null, vv); }
From source file:org.nees.rpi.vis.ui.ProfilePlotFrame.java
private void initSliderArea() { JPanel sliderArea = new JPanel(); sliderArea.setOpaque(false);//w w w. j a v a 2 s . c o m sliderArea.setLayout(new BorderLayout()); sliderArea.setBorder(BorderFactory.createTitledBorder("Time")); contentPane.add(sliderArea, BorderLayout.SOUTH); timeSlider = new JSlider(); timeSlider.setOpaque(false); timeSlider.addChangeListener(new ProfileSliderChangeListener()); timeSlider.addMouseListener(new ProfileSliderMouseListener()); timeLabel = new JLabel(); styleTimeLabel(); JPanel buttonArea = new JPanel(); buttonArea.setOpaque(false); BoxLayout buttonAreaLayout = new BoxLayout(buttonArea, BoxLayout.Y_AXIS); buttonArea.setLayout(buttonAreaLayout); playButton = new VisLinkButton("Play", getClass().getResource("/images/profile-plot/plotplay.png")); playButton.setToolTipText("Display a timed incremental sequence of the profiles"); playButton.addActionListener(new PlayProfilesMovie()); pauseButton = new VisLinkButton("Pause", getClass().getResource("/images/profile-plot/plotpause.png")); pauseButton.setToolTipText("Pause the playback of the profiles sequence"); pauseButton.addActionListener(new PauseProfilesMovie()); pauseButton.setVisible(false); nextButton = new VisLinkButton("Forward", getClass().getResource("/images/profile-plot/plotnext.png")); nextButton.setToolTipText("Plot the profile for the next time increment"); nextButton.addActionListener(new MoveToNextTimeIncrement()); previousButton = new VisLinkButton("Back", getClass().getResource("/images/profile-plot/plotprevious.png")); previousButton.setToolTipText("Plot the profile for the previous time increment"); previousButton.addActionListener(new MoveToPreviousTimeIncrement()); buttonArea.add(playButton); buttonArea.add(pauseButton); buttonArea.add(nextButton); buttonArea.add(previousButton); sliderArea.add(timeSlider, BorderLayout.CENTER); sliderArea.add(timeLabel, BorderLayout.SOUTH); sliderArea.add(buttonArea, BorderLayout.WEST); }
From source file:edu.pdi2.visual.ThresholdSignature.java
private void initGUI(int cantBands) { try {//from w w w .java 2 s.c o m { getContentPane().setLayout(null); this.setPreferredSize(new java.awt.Dimension(359, 457)); { for (int i = 0; i < cantBands; ++i) { scrollbars[i] = new JScrollBar(); getContentPane().add(scrollbars[i]); scrollbars[i].setBounds(50 * i + 20, 42, 17, 71); scrollbars[i].setValue(INITIAL_DEVIATION); final Integer index = new Integer(i); scrollbars[i].addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent evt) { evt.setSource(new Integer(index)); scrollBarAdjustmentValueChanged(evt); } }); } } // { // jScrollBar1 = new JScrollBar(); // getContentPane().add(jScrollBar1); // jScrollBar1.setBounds(20, 42, 17, 71); // jScrollBar1.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar1AdjustmentValueChanged(evt); // } // }); // } { for (int i = 0; i < cantBands; ++i) { bandLabels[i] = new JLabel(); getContentPane().add(bandLabels[i]); bandLabels[i].setText("Band " + i); bandLabels[i].setBounds(50 * i + 12, 23, 33, 14); } } // { // jLabel1 = new JLabel(); // getContentPane().add(jLabel1); // jLabel1.setText("Band 1"); // jLabel1.setBounds(12, 23, 33, 14); // } { signatureG = ChartFactory.createXYLineChart("Signature ", "Bands", "Valory", null, PlotOrientation.VERTICAL, true, true, false); chartpanel = new ChartPanel(signatureG); getContentPane().add(chartpanel); chartpanel.setBorder(BorderFactory.createTitledBorder("")); chartpanel.setBounds(20, 157, 45 * cantBands + 20, 210); } // { // jLabel2 = new JLabel(); // getContentPane().add(jLabel2); // jLabel2.setText("Band 2"); // jLabel2.setBounds(62, 23, 33, 14); // } // { // jScrollBar2 = new JScrollBar(); // getContentPane().add(jScrollBar2); // jScrollBar2.setBounds(70, 42, 17, 71); // jScrollBar2.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar2AdjustmentValueChanged(evt); // } // }); // } // { // jLabel3 = new JLabel(); // getContentPane().add(jLabel3); // jLabel3.setText("Band 3"); // jLabel3.setBounds(112, 23, 33, 14); // } // { // jScrollBar3 = new JScrollBar(); // getContentPane().add(jScrollBar3); // jScrollBar3.setBounds(120, 42, 17, 71); // jScrollBar3.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar3AdjustmentValueChanged(evt); // } // }); // } // { // jLabel4 = new JLabel(); // getContentPane().add(jLabel4); // jLabel4.setText("Band 4"); // jLabel4.setBounds(162, 23, 33, 14); // } // { // jScrollBar4 = new JScrollBar(); // getContentPane().add(jScrollBar4); // jScrollBar4.setBounds(170, 42, 17, 71); // jScrollBar4.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar4AdjustmentValueChanged(evt); // } // }); // } // { // jLabel5 = new JLabel(); // getContentPane().add(jLabel5); // jLabel5.setText("Band 5"); // jLabel5.setBounds(212, 23, 33, 14); // } // { // jScrollBar5 = new JScrollBar(); // getContentPane().add(jScrollBar5); // jScrollBar5.setBounds(220, 42, 17, 71); // jScrollBar5.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar5AdjustmentValueChanged(evt); // } // }); // } // { // jLabel6 = new JLabel(); // getContentPane().add(jLabel6); // jLabel6.setText("Band 6"); // jLabel6.setBounds(262, 23, 33, 14); // } // { // jScrollBar6 = new JScrollBar(); // getContentPane().add(jScrollBar6); // jScrollBar6.setBounds(270, 42, 17, 71); // jScrollBar6.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar6AdjustmentValueChanged(evt); // } // }); // } // { // jLabel7 = new JLabel(); // getContentPane().add(jLabel7); // jLabel7.setText("Band 7"); // jLabel7.setBounds(312, 23, 33, 14); // } // { // jScrollBar7 = new JScrollBar(); // getContentPane().add(jScrollBar7); // jScrollBar7.setBounds(320, 42, 17, 71); // jScrollBar7.addAdjustmentListener(new AdjustmentListener() { // public void adjustmentValueChanged(AdjustmentEvent evt) { // jScrollBar7AdjustmentValueChanged(evt); // } // }); // } { for (int i = 0; i < cantBands; ++i) { valueLabels[i] = new JLabel(); getContentPane().add(valueLabels[i]); valueLabels[i].setText(String.valueOf(INITIAL_DEVIATION)); valueLabels[i].setBounds(50 * i + 20, 119, 33, 19); } } // { // jLabel8 = new JLabel(); // getContentPane().add(jLabel8); // jLabel8.setBounds(20, 119, 33, 19); // jLabel8.setText("0"); // } // { // jLabel9 = new JLabel(); // getContentPane().add(jLabel9); // jLabel9.setText("0"); // jLabel9.setBounds(70, 119, 33, 19); // } // { // jLabel10 = new JLabel(); // getContentPane().add(jLabel10); // jLabel10.setText("0"); // jLabel10.setBounds(120, 119, 33, 19); // } // { // jLabel11 = new JLabel(); // getContentPane().add(jLabel11); // jLabel11.setText("0"); // jLabel11.setBounds(170, 119, 33, 19); // } // { // jLabel12 = new JLabel(); // getContentPane().add(jLabel12); // jLabel12.setText("0"); // jLabel12.setBounds(220, 119, 33, 19); // } // { // jLabel13 = new JLabel(); // getContentPane().add(jLabel13); // jLabel13.setText("0"); // jLabel13.setBounds(270, 119, 33, 19); // } // { // jLabel14 = new JLabel(); // getContentPane().add(jLabel14); // jLabel14.setText("0"); // jLabel14.setBounds(320, 119, 33, 19); // } { btCancel = new JButton(); getContentPane().add(btCancel); btCancel.setText("Cancel"); btCancel.setBounds(51 * cantBands - 75, 379, 75, 25); btCancel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { btCancelMouseClicked(evt); } }); } { btOk = new JButton(); getContentPane().add(btOk); btOk.setText("Generate"); btOk.setBounds(51 * cantBands - 155, 379, 75, 25); btOk.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { btOkMouseClicked(evt); } }); } } this.setSize(51 * cantBands + 40, 457); this.setResizable(false); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java
/** * Description://from w ww . ja va 2 s . com * * @param name */ protected void initComponent() { setLayout(new BorderLayout(0, 0)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.weighty = 0; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = 2; // gc.gridheight = 3; // Should change to 3 if we add Route typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(12, 2, 2, 2); gc.weightx = 0; gc.gridheight = 1; swNumberLabel = createNumberLabel(); mainPanel.add(swNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue()); mainPanel.add(swNameLabel, gc); gc.insets = new Insets(2, 2, 6, 2); gc.gridwidth = 1; fiNumberLabel = createNumberLabel(); mainPanel.add(fiNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue()); mainPanel.add(fiNameLabel, gc); // gc.gridwidth = 1; // rtNumberLabel = ComponentFactory.getH4Label( // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER); // mainPanel.add(rtNumberLabel, gc); // // gc.gridwidth = GridBagConstraints.REMAINDER; // rtNameLabel = ComponentFactory.getH5Label( // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN); // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM); // mainPanel.add(rtNameLabel, gc); add(mainPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridBagLayout()); bottomPanel.setOpaque(false); bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY)); gc = new GridBagConstraints(); gc.insets = new Insets(0, 5, 1, 5); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridheight = 2; otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); otherPortsLabel.setForeground(UIConstants.INTEL_GRAY); otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT); bottomPanel.add(otherPortsLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; gc.weightx = 0; gc.weighty = 1; JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); gc.weighty = 0; label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); add(bottomPanel, BorderLayout.SOUTH); }