List of usage examples for javax.swing JTabbedPane JTabbedPane
public JTabbedPane()
TabbedPane
with a default tab placement of JTabbedPane.TOP
. From source file:gtu._work.ui.DirectoryCompareUI.java
private void initGUI() { try {/*ww w. j a va 2s . c om*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("jPanel1", null, jPanel1, null); { jPanel2 = new JPanel(); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS); jPanel2.setLayout(jPanel2Layout); jPanel1.add(jPanel2, BorderLayout.NORTH); jPanel2.setPreferredSize(new java.awt.Dimension(660, 36)); { leftDirText = new JTextArea(); leftDirText.setPreferredSize(leftDirText.getPreferredSize()); leftDirText.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); JCommonUtil.jTextFieldSetFilePathMouseEvent(leftDirText, true); leftDirText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { } })); jPanel2.add(leftDirText); JTextFieldUtil.setupDragDropFilePath(leftDirText, null); } { rightDirText = new JTextArea(); rightDirText.setPreferredSize(rightDirText.getPreferredSize()); rightDirText.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); JCommonUtil.jTextFieldSetFilePathMouseEvent(rightDirText, true); rightDirText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { } })); jPanel2.add(rightDirText); JTextFieldUtil.setupDragDropFilePath(rightDirText, null); } { executeBtn = new JButton(); jPanel2.add(executeBtn); jPanel2.add(getResetBtn()); executeBtn.setText("\u958b\u59cb\u6bd4\u5c0d"); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { compareStart(); } }); } } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(660, 362)); { dirCompareTable = new JTable(); // JTableUtil.defaultSetting(dirCompareTable); JTableUtil.defaultSetting_AutoResize(dirCompareTable); jScrollPane1.setViewportView(dirCompareTable); dirCompareTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { dirCompareTableMouseClicked(evt); } }); dirCompareTable.setModel(getDefaultTableModel()); } } { jPanel3 = new JPanel(); FlowLayout jPanel3Layout = new FlowLayout(); jPanel3Layout.setAlignOnBaseline(true); jPanel1.add(jPanel3, BorderLayout.SOUTH); jPanel3.setLayout(jPanel3Layout); jPanel3.setPreferredSize(new java.awt.Dimension(843, 62)); { jLabel1 = new JLabel(); jPanel3.add(jLabel1); jLabel1.setText("\u526f\u6a94\u540d"); } { DefaultComboBoxModel extensionNameComboBoxModel = new DefaultComboBoxModel(); extensionNameComboBox = new JComboBox(); jPanel3.add(extensionNameComboBox); jPanel3.add(getDiffToolComboBox()); jPanel3.add(getJLabel2()); jPanel3.add(getSearchText()); jPanel3.add(getCompareStyleComboBox()); jPanel3.add(getResetQueryBtn()); addDiffMergeChkBox(); extensionNameComboBox.setModel(extensionNameComboBoxModel); { panel = new JPanel(); jTabbedPane1.addTab("New tab", null, panel, null); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { lblCustomCommand = new JLabel("custom command"); panel.add(lblCustomCommand, "2, 2, right, default"); } { customCompareText = new JTextField(); customCompareText.setText( "\"C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" /base:\"%s\" /theirs:\"%s\""); panel.add(customCompareText, "4, 2, fill, default"); customCompareText.setColumns(10); } { configSaveBtn = new JButton(""); configSaveBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { boolean configChange = false; String customCompareUrl = customCompareText.getText(); if (StringUtils.isNotBlank(customCompareUrl)) { configBean.getConfigProp().setProperty(CUSTOM_COMPARE_URL_KEY, customCompareUrl); configChange = true; } if (configChange) { configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info( "?!"); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); panel.add(configSaveBtn, "2, 36"); } } extensionNameComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { totalScanFiles(null); } }); } } } } pack(); this.setSize(864, 563); JCommonUtil.setJFrameIcon(getOwner(), "images/ico/file_merge.ico"); initConfigBean(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
private void initializeComponent() { if (!this.initialized) { logger.info("Initializing the main window."); if (AssuranceUtils.getPlatform() == Platform.MAC) { System.setProperty("apple.laf.useScreenMenuBar", "true"); com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication(); MacApplicationAdapter macAdapter = new MacApplicationAdapter(this); macApplication.addApplicationListener(macAdapter); macApplication.setEnabledPreferencesMenu(true); }/*from w ww. j a v a 2 s. c om*/ this.setTitle(Application.applicationShortName); this.setDefaultCloseOperation(EXIT_ON_CLOSE); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.topArea = new JTabbedPane(); this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150)); this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150)); this.topArea.addTab("Scan", this.scanLaunchPanel); this.topArea.addTab("History", this.scanHistoryPanel); this.resultsPanel.setPreferredSize(new Dimension(600, 400)); this.topArea.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { resultsPanel.resetPanel(); // NOTE: This isn't ideal. It feels brittle. if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) { viewHistoryMenuItem.setSelected(true); } else { viewScanMenuItem.setSelected(true); } } }); GridBagConstraints topPanelConstraints = new GridBagConstraints(); topPanelConstraints.anchor = GridBagConstraints.NORTH; topPanelConstraints.fill = GridBagConstraints.BOTH; topPanelConstraints.gridx = 0; topPanelConstraints.gridy = 0; topPanelConstraints.weightx = 1.0; topPanelConstraints.weighty = 0.33; topPanelConstraints.gridheight = 1; topPanelConstraints.gridwidth = 1; topPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.topArea, topPanelConstraints); GridBagConstraints resultsPanelConstraints = new GridBagConstraints(); resultsPanelConstraints.anchor = GridBagConstraints.SOUTH; resultsPanelConstraints.fill = GridBagConstraints.BOTH; resultsPanelConstraints.gridx = 0; resultsPanelConstraints.gridy = 1; resultsPanelConstraints.weightx = 1.0; resultsPanelConstraints.weighty = 0.67; resultsPanelConstraints.gridheight = 1; resultsPanelConstraints.gridwidth = 1; resultsPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.resultsPanel, resultsPanelConstraints); this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this); this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this); this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this); JMenu menu; JMenuItem menuItem; menuBar = new JMenuBar(); StringBuilder accessiblityLabel = new StringBuilder(128); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu(Application.applicationShortName); menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.quitApplicationAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Display information about this version of ") .append(Application.applicationShortName).append(".").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.aboutApplicationAction); menu.add(menuItem); } menu = new JMenu("Scan"); menu.setMnemonic(KeyEvent.VK_S); menu.getAccessibleContext().setAccessibleDescription("Actions for file scans"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Launch a scan using the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription( "Launch a scan using the selected scan definition and merge the results"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAndMergeAction); menu.add(menuItem); menu = new JMenu("Results"); menu.setMnemonic(KeyEvent.VK_R); menu.getAccessibleContext().setAccessibleDescription("Actions for scan results"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the source file with the target file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceSourceAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the target file with the source file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceTargetAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.sourceAttributesAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.targetAttributesAction); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString()); accessiblityLabel.setLength(0); menuBar.add(menu); ButtonGroup group = new ButtonGroup(); this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel); this.viewScanMenuItem.addActionListener(this); this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction); this.viewScanMenuItem.setSelected(true); group.add(this.viewScanMenuItem); menu.add(this.viewScanMenuItem); this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel); this.viewHistoryMenuItem.addActionListener(this); this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction); this.viewHistoryMenuItem.setSelected(true); group.add(this.viewHistoryMenuItem); menu.add(this.viewHistoryMenuItem); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu("Tools"); menu.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Additional actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Change settings for the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.displaySettingsAction); menu.add(menuItem); } this.setJMenuBar(menuBar); this.initialized = true; } }
From source file:edu.ucla.stat.SOCR.applications.demo.BinomialTradingApplication.java
/** * This method initializes the application. *//* w w w .j av a 2 s .c om*/ public void init() { tabbedPanelContainer = new JTabbedPane(); initJGraphPanel(); initGraphPanel2(); addTabbedPane(GRAPH, jgraphPanel); //addTabbedPane("GRAPH2", graphPanel2); tabbedPanelContainer.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) { jgraphPanel.removeAll(); //setChart(); } /*else if( tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex())==GRAPH2) { // //setInputPanel(); }*/ } }); /* The following components need to be set * 1. Control JPanel * 1.a Floating-point Text-Field for So = Price of the stock at time zero, So>=0. * 1.b Floating-Point Text-Field for EP = Exercise price (it is exercised at the end if price of stock at the end > EP), EP>=0. * 1.c Integer Slider for t = Time until expiration in years, 0<=t<=365. * 1.d Floating-Point Text-Field for r = Interest rate per year (0.000<=r). * 1.e Floating Point Text-Field for sigma = Annual volatility (0.000<=sigma). * 1.f Integer Slider for n = Number of periods that we divide the time to expiration (0<=n<=1000). * * 2. Graph JPanel * 2.a For now, make this Graph panel just include a JTextArea where we will print out results * for debugging the calculator. Later, we'll replace this by a (Node, Edge)-Graph object * */ /*masterPanel = new JPanel(); masterPanel.setSize(new Dimension (500,500)); controlPanel.add(new JTextArea("Control Panel")); graphPanel.add(new JTextArea("Graph Panel")); vSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(controlPanel), new JScrollPane(graphPanel)); vSplitPane.setOneTouchExpandable(true); vSplitPane.setDividerLocation(150); //add(vSplitPane); // What should this be - how/where can we attach this pane to the main Panel? masterPanel.add(vSplitPane); masterPanel.validate(); getDisplayPane().removeAll(); getDisplayPane().add(masterPanel, BorderLayout.CENTER);*/ upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel), new JScrollPane(tabbedPanelContainer)); this.getMainPanel().removeAll(); this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER); this.getMainPanel().validate(); //initGraph(); updateAllNodes(); }
From source file:net.sf.jabref.EntryEditor.java
public EntryEditor(JabRefFrame frame, BasePanel panel, BibtexEntry entry) { this.frame = frame; this.panel = panel; this.entry = entry; prefs = Globals.prefs;// ww w. j a v a 2 s . c o m type = entry.getType(); entry.addPropertyChangeListener(this); helpAction = new HelpAction(frame.helpDiag, GUIGlobals.entryEditorHelp, "Help"); tabbed = new JTabbedPane(); BorderLayout bl = new BorderLayout(); setLayout(bl); setupToolBar(); setupFieldPanels(); setupSourcePanel(); add(tabbed, BorderLayout.CENTER); tabbed.addChangeListener(tabListener); updateAllFields(); }
From source file:BorderDemo.java
public BorderDemo() { super("BorderDemo"); Border blackline, etched, raisedbevel, loweredbevel, empty; //A border that puts 10 extra pixels at the sides and //bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); etched = BorderFactory.createEtchedBorder(); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);/* w ww . j a v a 2 s . c o m*/ simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(etched, "etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); //Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); //XXX: We *should* size the component so that the //XXX: icons tile OK. Without that, the icons are //XXX: likely to be cut off and look bad. ImageIcon icon = new ImageIcon("images/left.gif"); //20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); //Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(etched, "title"); addCompForTitledBorder(titled, "titled etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); //Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); getContentPane().add(tabbedPane, BorderLayout.CENTER); }
From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java
/** * Creates a new monitor panel./*ww w. j a va2 s . c om*/ * * @return the monitor panel */ public JPanel createPanel() { JPanel mainPanel = new JPanel(new BorderLayout()); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[4]; this.datasets[0] = addSubPlot(plot, "#Tiles"); this.datasets[1] = addSubPlot(plot, "#Hits"); this.datasets[2] = addSubPlot(plot, "#Misses"); this.datasets[3] = addSubPlot(plot, "Mem (kB)"); JFreeChart chart = new JFreeChart(plot); LegendTitle legend = (LegendTitle) chart.getSubtitle(0); legend.setPosition(RectangleEdge.RIGHT); legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4)); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds textarea = new JTextArea(); tableModel = new TileCacheTableModel(); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tabbedPane = new JTabbedPane(); tabbedPane.add(CACHE_INFO_TAB, new JScrollPane(textarea)); tabbedPane.add(CACHE_CHART_TAB, chartPanel); tabbedPane.add(IMAGES_TAB, new JScrollPane(new JTable(tableModel))); tabbedPane.setSelectedIndex(0); mainPanel.add(tabbedPane); return mainPanel; }
From source file:mekhq.gui.FinancesTab.java
@Override public void initTab() { resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$ GridBagConstraints gridBagConstraints; setLayout(new GridBagLayout()); ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT); ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES); financeModel = new FinanceTableModel(); financeTable = new JTable(financeModel); financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel)); financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableColumn column = null;/*from w w w .ja v a2s. c o m*/ for (int i = 0; i < FinanceTableModel.N_COL; i++) { column = financeTable.getColumnModel().getColumn(i); column.setPreferredWidth(financeModel.getColumnWidth(i)); column.setCellRenderer(financeModel.getRenderer()); } financeTable.setIntercellSpacing(new Dimension(0, 0)); financeTable.setShowGrid(false); loanModel = new LoanTableModel(); loanTable = new JTable(loanModel); loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel)); loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); column = null; for (int i = 0; i < LoanTableModel.N_COL; i++) { column = loanTable.getColumnModel().getColumn(i); column.setPreferredWidth(loanModel.getColumnWidth(i)); column.setCellRenderer(loanModel.getRenderer()); } loanTable.setIntercellSpacing(new Dimension(0, 0)); loanTable.setShowGrid(false); JScrollPane scrollLoanTable = new JScrollPane(loanTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; JPanel panBalance = new JPanel(new GridBagLayout()); panBalance.add(new JScrollPane(financeTable), gridBagConstraints); panBalance.setMinimumSize(new java.awt.Dimension(350, 100)); panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet")); JPanel panLoan = new JPanel(new GridBagLayout()); panLoan.add(scrollLoanTable, gridBagConstraints); JTabbedPane financeTab = new JTabbedPane(); financeTab.setMinimumSize(new java.awt.Dimension(450, 300)); financeTab.setPreferredSize(new java.awt.Dimension(450, 300)); JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab); splitFinances.setOneTouchExpandable(true); splitFinances.setContinuousLayout(true); splitFinances.setResizeWeight(1.0); splitFinances.setName("splitFinances"); financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan); financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel); financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(splitFinances, gridBagConstraints); JPanel panelFinanceRight = new JPanel(new BorderLayout()); JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2)); btnAddFunds = new JButton("Add Funds (GM)"); btnAddFunds.addActionListener(ev -> addFundsActionPerformed()); btnAddFunds.setEnabled(getCampaign().isGM()); pnlFinanceBtns.add(btnAddFunds); JButton btnGetLoan = new JButton("Get Loan"); btnGetLoan.addActionListener(e -> showNewLoanDialog()); pnlFinanceBtns.add(btnGetLoan); btnManageAssets = new JButton("Manage Assets (GM)"); btnManageAssets.addActionListener(e -> manageAssets()); btnManageAssets.setEnabled(getCampaign().isGM()); pnlFinanceBtns.add(btnManageAssets); panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH); areaNetWorth = new JTextArea(); areaNetWorth.setLineWrap(true); areaNetWorth.setWrapStyleWord(true); areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12)); areaNetWorth.setText(getCampaign().getFinancialReport()); areaNetWorth.setEditable(false); JScrollPane descriptionScroll = new JScrollPane(areaNetWorth); panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER); areaNetWorth.setCaretPosition(0); descriptionScroll.setMinimumSize(new Dimension(300, 200)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.0; gridBagConstraints.weighty = 1.0; add(panelFinanceRight, gridBagConstraints); }
From source file:com.xtructure.xevolution.gui.XEvolutionGui.java
/** * Creates a new {@link XEvolutionGui}./*from w ww .j ava2s .c o m*/ * * @param title * the base string for the title of the gui * @param visualizeData * the visualize data * @param dataTracker * the data tracker */ public XEvolutionGui(String title, VisualizeData visualizeData, DataTracker<?, ?> dataTracker) { this.title = title; frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); populationFiles = new ArrayList<File>(); menuBar = new MenuBar(this, frame, title); frame.setJMenuBar(menuBar); tabbedPane = new JTabbedPane(); tabbedPane.setPreferredSize(new Dimension(600, 400)); frame.getContentPane().add(tabbedPane); statusBar = new StatusBar(); frame.add(statusBar, BorderLayout.PAGE_END); graphPanel = new JPanel(); graphPanel.setLayout(new GridLayout(0, 1)); bufferSize = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); bufferCount = 3; // max,avg,min graphsMap = new HashMap<XValId<?>, Graph>(); tabbedPane.addTab("Graphs", graphPanel); generationsPanel = new JPanel(); generationsPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5; c.weighty = 0.5; populationPanel = new PopulationPanel(popLock); genomePanel = new GenomePanel(); genomePanel.addSortByAttributeId(Genome.FITNESS_ATTRIBUTE_ID); genomePanel.addSortByAttributeId(Genome.COMPLEXITY_ATTRIBUTE_ID); genomePanel.getSortComboBox().setSelectedItem(Genome.FITNESS_ATTRIBUTE_ID); c.gridx = 0; c.gridy = 0; generationsPanel.add(populationPanel, c); c.gridx = 1; c.gridy = 0; generationsPanel.add(genomePanel, c); tabbedPane.addTab("Generations", generationsPanel); genealogyPanel = new GenealogyPanel(dataTracker); tabbedPane.addTab("Genealogy", genealogyPanel); addGraph(Genome.FITNESS_ATTRIBUTE_ID); addGraph(Genome.COMPLEXITY_ATTRIBUTE_ID); this.dataTracker = dataTracker; new GuiListener(populationPanel, genomePanel, genealogyPanel, visualizeData, dataTracker); frame.setResizable(true); frame.pack(); frame.setVisible(true); catchUp(); }
From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java
/** * Creates new form JTicketsBagRestaurant *//*from w ww .j av a2s . c o m*/ public JRetailTicketsBagRestaurantMap(AppView app, RetailTicketsEditor panelticket, String businessType) { super(app, panelticket); this.m_App = app; dlReceipts = (DataLogicReceipts) app.getBean("com.openbravo.pos.sales.DataLogicReceipts"); dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales"); dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem"); m_restaurantmap = new JRetailTicketsBagRestaurant(app, this); m_PlaceCurrent = null; m_PlaceClipboard = null; customer = null; //Select all the floor details from db for showing the floor name in screen try { SentenceList sent = new StaticSentence(app.getSession(), "SELECT ID, NAME, IMAGE FROM FLOORS ORDER BY NAME", null, new SerializerReadClass(Floor.class)); m_afloors = sent.list(); } catch (BasicException eD) { m_afloors = new ArrayList<Floor>(); } //Select all the tables details from db for showing the table names in screen try { SentenceList sent = new StaticSentence(app.getSession(), "SELECT ID, NAME, X, Y, FLOOR FROM PLACES WHERE NAME NOT LIKE 'takeaway' ORDER BY FLOOR", null, new SerializerReadClass(Place.class)); m_aplaces = sent.list(); } catch (BasicException eD) { m_aplaces = new ArrayList<Place>(); } //Initialise the components initComponents(); // add the Floors containers if (m_afloors.size() > 1) { // A tab container for 2 or more floors JTabbedPane jTabFloors = new JTabbedPane(); jTabFloors.applyComponentOrientation(getComponentOrientation()); jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); jTabFloors.setFocusable(false); jTabFloors.setRequestFocusEnabled(false); m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); for (Floor f : m_afloors) { f.getContainer().applyComponentOrientation(getComponentOrientation()); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } } else if (m_afloors.size() == 1) { // Just a frame for 1 floor Floor f = m_afloors.get(0); f.getContainer().applyComponentOrientation(getComponentOrientation()); JPanel jPlaces = new JPanel(); jPlaces.applyComponentOrientation(getComponentOrientation()); jPlaces.setLayout(new BorderLayout()); jPlaces.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), new javax.swing.border.TitledBorder(f.getName()))); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); m_jPanelMap.add(jPlaces, BorderLayout.CENTER); jPlaces.add(jScrCont, BorderLayout.CENTER); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } // Add all the Table buttons. Floor currfloor = null; for (Place pl : m_aplaces) { int iFloor = 0; if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) { // Look for a new floor do { currfloor = m_afloors.get(iFloor++); } while (!currfloor.getID().equals(pl.getFloor())); } currfloor.getContainer().add(pl.getButton()); pl.setButtonBounds(); pl.getButton().addActionListener(new MyActionListener(pl)); } // Add the reservations panel m_jreservations = new JRetailTicketsBagRestaurantRes(app, this); add(m_jreservations, "res"); }
From source file:components.BorderDemo.java
public BorderDemo() { super(new GridLayout(1, 0)); //Keep references to the next few borders, //for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; //A border that puts 10 extra pixels at the sides and //bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);// w w w. jav a 2s . c o m simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(raisedetched, "raised etched border", simpleBorders); addCompForBorder(loweredetched, "lowered etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); //Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); if (icon != null) { addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); } else { addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders); } border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); if (icon != null) { addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); } else { addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders); } //Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredetched, "title"); addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); //Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = new String( "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"); tabbedPane.setToolTipTextAt(1, toolTip); add(tabbedPane); }