List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:CombineApp.java
public CombineApp() { super("TBandCombineOp"); Container container = getContentPane(); displayPanel = new CombinePanel(); container.add(displayPanel);// w w w . java2 s .c o m JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 2)); panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset...")); redBandButton = new JButton("Show Red Band"); redBandButton.addActionListener(new ButtonListener()); greenBandButton = new JButton("Show Green Band"); greenBandButton.addActionListener(new ButtonListener()); blueBandButton = new JButton("Show Blue Band"); blueBandButton.addActionListener(new ButtonListener()); inverseBandButton = new JButton("Invert All Bands"); inverseBandButton.addActionListener(new ButtonListener()); middleBandButton = new JButton("Average Each Band"); middleBandButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(redBandButton); panel.add(blueBandButton); panel.add(greenBandButton); panel.add(inverseBandButton); panel.add(middleBandButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(displayPanel.getWidth(), displayPanel.getHeight()); setVisible(true); }
From source file:org.jfree.chart.demo.selection.SelectionDemo6Pie.java
public SelectionDemo6Pie(String title) { super(title); JPanel chartPanel = createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(700, 500)); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel);/* w w w . j a va 2s . c o m*/ this.model = new DefaultTableModel(new String[] { "section", "value:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:com.orthancserver.OrthancConfigurationDialog.java
public OrthancConfigurationDialog() { final JPanel contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(20, 5, 5, 5)); contentPanel.setLayout(new GridLayout2(0, 2, 20, 5)); JLabel label = new JLabel("Name:"); label.setHorizontalAlignment(JLabel.RIGHT); contentPanel.add(label);/*from w w w.ja v a 2 s .co m*/ contentPanel.add(name_); label = new JLabel("URL:"); label.setHorizontalAlignment(JLabel.RIGHT); contentPanel.add(label); contentPanel.add(url_); label = new JLabel("Username:"); label.setHorizontalAlignment(JLabel.RIGHT); contentPanel.add(label); contentPanel.add(username_); label = new JLabel("Password:"); label.setHorizontalAlignment(JLabel.RIGHT); contentPanel.add(label); contentPanel.add(password_); getContentPane().setLayout(new BorderLayout()); getContentPane().add(contentPanel, BorderLayout.NORTH); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { { JButton test = new JButton("Test connection"); test.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { OrthancConnection orthanc = CreateConnection(); try { JSONObject system = (JSONObject) orthanc.ReadJson("system"); JOptionPane.showMessageDialog(null, "Successfully connected to this Orthanc server " + "(version: " + (String) system.get("Version") + ")!", "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Cannot connect to this Orthanc server!", "Error", JOptionPane.ERROR_MESSAGE); } } }); buttonPane.add(test); } { JButton okButton = new JButton("Add"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { isSuccess_ = true; setVisible(false); } }); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { setVisible(false); } }); buttonPane.add(cancelButton); } } setUndecorated(false); setSize(500, 500); setTitle("Add new server"); setModal(true); }
From source file:de.tbuchloh.kiskis.gui.dialogs.ImportDialog.java
/** * Overridden!//ww w.jav a 2s. c om * * @see de.tbuchloh.kiskis.gui.dialogs.KisKisDialog#createMainPanel() */ @Override protected Component createMainPanel() { final SimpleInternalFrame settings = createSettingsPanel(); final JPanel root = new JPanel(new BorderLayout()); root.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); root.add(settings, BorderLayout.NORTH); final SimpleInternalFrame note = createNotePanel(); root.add(note, BorderLayout.SOUTH); return root; }
From source file:LabelDnD.java
public LabelDnD() { super(new GridLayout(2, 1)); textField = new JTextField(40); textField.setDragEnabled(true);//from w w w. j ava 2 s. c om JPanel tfpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t1 = BorderFactory.createTitledBorder("JTextField: drag and drop is enabled"); tfpanel.add(textField); tfpanel.setBorder(t1); label = new JLabel("I'm a Label!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("text")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drag from or drop to this label"); lpanel.add(label); lpanel.setBorder(t2); add(tfpanel); add(lpanel); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:uk.co.petertribble.solview.explorer.CpuInfoPanel.java
private void addAggregateAccessory(KstatAggregate ksa) { kap = new AggregateCpuPanel(ksa, 1, jkstat); JPanel jp = new JPanel(new BorderLayout()); jp.add(kap);/*from w w w .ja v a2s .c om*/ jp.setBorder(BorderFactory.createTitledBorder("Aggregate CPU activity")); jvp.add(jp); kbc = new KstatAggregateAreaChart(jkstat, ksa, mystats, true); kbc.setColors(mycolors); jvp.add(new ChartPanel(kbc.getChart())); }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);//from w w w .ja va 2s.c o m message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:eu.delving.sip.actions.ImportAction.java
private void prepareDialog() { JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { @Override// w ww . j a va 2s .c om public void actionPerformed(ActionEvent actionEvent) { dialog.setVisible(false); } }); JPanel bp = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bp.add(cancel); JPanel p = new JPanel(new GridLayout(1, 0, 15, 15)); p.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); p.add(new JButton(chooseFileAction)); p.add(new JButton(harvestAction)); dialog.getContentPane().add(p, BorderLayout.CENTER); dialog.getContentPane().add(bp, BorderLayout.SOUTH); dialog.pack(); }
From source file:hermes.browser.dialog.GeneralRendererConfigPanel.java
private void init() { Border border = BorderFactory.createBevelBorder(BevelBorder.RAISED); JPanel topPanel = new JPanel(); topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); topPanel.setLayout(new GridLayout(1, 2)); infoLabel1.setText("Message Renderers"); setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder(border, "Renderers")); topPanel.add(infoLabel1);/* w w w. j a v a 2 s. c o m*/ topSP.setViewportView(classTable); classTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); add(topPanel, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); splitPane.add(topSP, "top"); splitPane.add(bottomSP, "bottom"); splitPane.setDividerLocation(200); // splitPane.setShowGripper(true) ; classTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { doRendererSelected(e); } }); }
From source file:fuel.gui.stats.StationStatsPanel.java
private void refreshGraphs() { graphContainer.removeAll();//from www . j av a 2s .c o m DefaultPieDataset usageDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet thisStation = database .Query("SELECT SUM(liter) FROM fuelrecords WHERE stationId = " + station.getId(), true); thisStation.next(); usageDataset.setValue(station.toString(), thisStation.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("Tankstation verhouding"))); usagePieChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); 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") + "'", true); thisStation.next(); fuelDataset.setValue(numberResults.getString("typeOfGas"), thisStation.getInt("1")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) fuelPieChart.getPlot(); plot2.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(320, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database.Query("SELECT cost/liter,date FROM fuelrecords ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("date"), "Prijs per liter"); } } 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("Prijs per liter")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); JPanel piePanel = new JPanel(new GridLayout(0, 2)); piePanel.add(usagePieChartPanel); piePanel.add(fuelPieChartPanel); graphContainer.add(piePanel); graphContainer.add(barChartPanel); revalidate(); repaint(); }