List of usage examples for javax.swing JScrollPane getViewport
public JViewport getViewport()
JViewport
. From source file:StocksTable5.java
public StocksTable5() { super("Stocks Table"); setSize(600, 300);/*from w w w . j a va 2 s . c o m*/ m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(true); header.addMouseListener(m_data.new ColumnListener(m_table)); header.setReorderingAllowed(true); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:DefaultsDisplay.java
protected JComponent createFilterControl() { onlyVisualsCheckBox = new JCheckBox("Show Only Visual Defaults"); onlyVisualsCheckBox.setSelected(true); onlyVisualsCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { boolean showOnlyVisuals = onlyVisualsCheckBox.isSelected(); for (int i = 0; i < tabPane.getTabCount(); i++) { JScrollPane scrollpane = (JScrollPane) tabPane.getComponentAt(i); JTable table = (JTable) scrollpane.getViewport().getView(); TableRowSorter sorter = (TableRowSorter) table.getRowSorter(); sorter.setRowFilter(showOnlyVisuals ? visualsFilter : null); }//from w w w . j ava2s . c o m } }); return onlyVisualsCheckBox; }
From source file:mendeley2kindle.MainUIFrame.java
public MainUIFrame(Properties config, Mendeley2Kindle core) { super("Mendeley2Kindle"); setDefaultCloseOperation(EXIT_ON_CLOSE); this.core = core; core.addStateListener(new UISyncStateListener()); components = new ArrayList<JComponent>(); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMenuItem = new JMenuItem("Open Mendeley database"); openMenuItem.addActionListener(new OpenMendeleyListener()); JMenuItem selectKindleMenuItem = new JMenuItem("Select Kindle device path"); selectKindleMenuItem.addActionListener(new SelectKindleListener()); JMenuItem exitMenuItem = new JMenuItem("Quit"); exitMenuItem.addActionListener(new QuitListener()); fileMenu.add(openMenuItem);//from www . j av a 2 s . co m fileMenu.add(selectKindleMenuItem); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); JMenu helpMenu = new JMenu("Help"); JMenuItem aboutMenuItem = new JMenuItem("About"); aboutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = "Mendeley2Kindle 0.3.2\n" + " (c) Copyright Yukinari Toyota, 2013. All rights reserved.\n" + " Contact: Yukinari Toyota <xxseyxx@gmail.com>\n" + " Site: http://sites.google.com/site/xxseyxx/\n" + "Some Icons by Yusuke Kamiyamane\n" + " Site: http://p.yusukekamiyamane.com/\n" + "sqlite-jdbc-3.7.2.jar is provided by xerial.org\n" + " under Apache License version 2.0 (http://www.apache.org/licenses/ )\n" + " Site: https://bitbucket.org/xerial/sqlite-jdbc\n"; JOptionPane.showMessageDialog(MainUIFrame.this, text); } }); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); setJMenuBar(menuBar); getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); getContentPane().add(new JLabel("Select Mendeley collections")); collectionsJList = new JList(); DragSelectionListener mil = new DragSelectionListener(); collectionsJList.addMouseMotionListener(mil); collectionsJList.addMouseListener(mil); collectionsJList.setCellRenderer(new MyCellRenderer()); // collectionsJList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); JScrollPane scroll = new JScrollPane(); scroll.setPreferredSize(new Dimension(200, 300)); scroll.getViewport().setView(collectionsJList); getContentPane().add(scroll); mainButton = new JButton("Open Mendeley database"); mainButton.addActionListener(new OpenMendeleyListener()); getContentPane().add(mainButton); components.add(collectionsJList); for (JComponent c : components) c.setEnabled(false); pack(); }
From source file:JavaXWin.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JTextArea text = new JTextArea(); JScrollPane scroller = new JScrollPane(); scroller.getViewport().add(text); try {// w ww .ja va 2 s . co m FileReader fileStream = new FileReader(""); text.read(fileStream, "JavaLinux.txt"); } catch (Exception e) { text.setText("* Could not read JavaLinux.txt *"); } jif.getContentPane().add(scroller); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:edu.ku.brc.specify.config.init.TreeDefSetupPanel.java
/** * @param classType the class of the TreeDef * @param classTitle the already localized title of the actual tree * @param panelName the name of the panel * @param descKey L10N key to label description above the table * @param nextBtn the next button/*from w w w. j a v a2 s. c om*/ * @param dbPanel the */ public TreeDefSetupPanel(final Class<?> classType, final String classTitle, final String panelName, final String helpContext, final String descKey, final JButton nextBtn, final JButton prevBtn, final DisciplinePanel disciplinePanel) { super(panelName, helpContext, nextBtn, prevBtn); this.classType = classType; this.classTitle = classTitle; this.disciplinePanel = disciplinePanel; if (classType == TaxonTreeDef.class || classType == GeographyTreeDef.class || classType == StorageTreeDef.class) { model = new TreeDefTableModel(); if (classType != TaxonTreeDef.class) { loadTree(disciplinePanel != null && disciplinePanel.getDisciplineType() != null ? disciplinePanel.getDisciplineType().getDisciplineType() : null); } table = new JTable(model); directionCBX = UIHelper .createComboBox(new String[] { getResourceString("FORWARD"), getResourceString("REVERSE") }); fullnameDisplayTxt = new JEditorPane(); fullnameDisplayTxt.setBackground(Color.WHITE); fullnameDisplayTxt.setOpaque(true); fullnameDisplayTxt.setContentType("text/html"); fullnameDisplayTxt.setEditable(false); table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); //table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); model.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateBtnUI(); } }); JScrollPane spex = new JScrollPane(fullnameDisplayTxt, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder( new FormLayout("p,2px,p,250px,f:p:g", "p,4px,min(p;250px),4px,p,4px,65px,2px,p"), this); JScrollPane sp = createScrollPane(table); sp.getViewport().setBackground(Color.WHITE); String lbl = getLocalizedMessage(descKey, classTitle); pb.add(createLabel(lbl, SwingConstants.CENTER), cc.xyw(1, 1, 4)); pb.add(sp, cc.xyw(1, 3, 5)); pb.add(createI18NFormLabel("DIRECTION"), cc.xy(1, 5)); pb.add(directionCBX, cc.xy(3, 5)); pb.add(createI18NFormLabel("EXAMPLE"), cc.xy(1, 7)); pb.add(spex, cc.xywh(3, 7, 2, 3)); makeTableHeadersCentered(table, true); directionCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateBtnUI(); } }); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateBtnUI(); int inx = table.getSelectedColumn(); if (inx > -1) { TreeDefRow row = treeDefList.get(table.getSelectedRow()); String msgKey = null; if (row.isRequired() && (inx == 1 || inx == 3)) { msgKey = inx == 1 ? "NO_CHANGE_INCL" : "NO_CHANGE_REQ"; } else if (inx == 4 && !row.isIncluded()) { msgKey = "NO_CHANGE_INFN"; } if (msgKey != null) { final String mk = msgKey; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showLocalizedMsg(mk); } }); } } } } }); updateBtnUI(); } }
From source file:BeanContainer.java
public BeanEditor(Component bean) { m_bean = bean;/*from w w w . j a v a2 s .com*/ m_bean.addPropertyChangeListener(this); Point pt = m_bean.getLocationOnScreen(); setBounds(pt.x + 50, pt.y + 10, 400, 300); getContentPane().setLayout(new BorderLayout()); m_data = new PropertyTableData(m_bean); m_table = new JTable(m_data); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); setDefaultCloseOperation(HIDE_ON_CLOSE); setVisible(true); }
From source file:com.sshtools.common.ui.SshToolsApplication.java
public void openChangelog(Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); String changelog = ""; try {/*from w w w . jav a 2 s . c o m*/ BufferedReader br = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/changelog"))); String line = br.readLine(); while (line != null) { changelog += line + "\n"; line = br.readLine(); } br.close(); } catch (Exception e) { changelog = "<Error opening changelog>\n"; } javax.swing.JTextArea message = new javax.swing.JTextArea(changelog); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); // MultilineLabel x = new MultilineLabel(changelog); // x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); // x.setFont(x.getFont().deriveFont(12f)); javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.getViewport().add(message); scrollPane.setSize(400, 200); scrollPane.setPreferredSize(new java.awt.Dimension(400, 200)); UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "Change log", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDoseResponseController.java
/** * Initialize main view//from w w w . ja v a 2 s . c om */ @Override protected void initMainView() { dRPanel = new DRPanel(); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup mainDRRadioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected mainDRRadioButtonGroup.add(dRPanel.getInputDRButton()); mainDRRadioButtonGroup.add(dRPanel.getInitialPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getNormalizedPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getResultsDRButton()); //select as default first button dRPanel.getInputDRButton().setSelected(true); //init dataTable dataTable = new JTable(); JScrollPane scrollPane = new JScrollPane(dataTable); //the table will take all the viewport height available dataTable.setFillsViewportHeight(true); scrollPane.getViewport().setBackground(Color.white); dataTable.getTableHeader().setReorderingAllowed(false); //row and column selection must be false //dataTable.setColumnSelectionAllowed(false); //dataTable.setRowSelectionAllowed(false); dRPanel.getDatatableDRPanel().add(scrollPane, BorderLayout.CENTER); /** * When button is selected, switch view to corresponding subview */ dRPanel.getInputDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //switch shared table view updateModelInTable(dRInputController.getTableModel()); updateTableInfoMessage("This table contains all conditions and their respective slopes"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); //add panel to view dRPanel.getGraphicsDRParentPanel().add(dRInputController.getdRInputPanel(), gridBagConstraints); } }); dRPanel.getInitialPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRInitialController.getTableModel()); updateTableInfoMessage( "Concentrations of conditions selected previously have been log-transformed, slopes have not been changed"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRInitialController.getDRInitialPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRInitialController.getInitialChartPanel(), dRInitialController.getDRInitialPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(false), getdRAnalysisGroup(), false); } } }); dRPanel.getNormalizedPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //in case user skips "initial" subview and goes straight to normalization if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRNormalizedController.getTableModel()); updateTableInfoMessage( "Log-transformed concentrations with their normalized responses per replicate"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRNormalizedController.getDRNormalizedPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRNormalizedController.getNormalizedChartPanel(), dRNormalizedController.getDRNormalizedPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(true), getdRAnalysisGroup(), true); } } }); dRPanel.getResultsDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //switch shared table view: create and set new table model with most recent statistical values // (these values get recalculated after each new fitting) dRResultsController.setTableModel(dRResultsController.reCreateTableModel(dRAnalysisGroup)); updateModelInTable(dRResultsController.getTableModel()); updateTableInfoMessage( "Statistical values from the curve fit of the initial and normalized data."); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRResultsController.getdRResultsPanel(), gridBagConstraints); //plot curves dRResultsController.plotCharts(); } } }); //add view to parent panel areaMainController.getAreaAnalysisPanel().getDoseResponseParentPanel().add(dRPanel, gridBagConstraints); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * /* ww w . jav a2 s . c o m*/ */ protected void buildUI() { SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr); localizableIO = slxh; localizableIO.load(false); //stripToSingleLocale("pt", slxh); LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() { public LocalizableStrIFace create() { SpLocaleItemStr str = new SpLocaleItemStr(); str.initialize(); return str; } public LocalizableStrIFace create(String text, Locale locale) { return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor } }; LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory); SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory); schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, webLinkMgrCache, schemaType); schemaLocPanel.setLocalizableIO(localizableIO); schemaLocPanel.setStatusBar(statusBar); boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false); schemaLocPanel.setUseDisciplines(useDisciplines); // rods - for now //schemaLocPanel.setIncludeHiddenUI(true); schemaLocPanel.buildUI(); schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad()); statusBar.setSectionText(1, schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$ : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$ UIRegistry.setStatusBar(statusBar); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); String title = "File"; //$NON-NLS-1$ String mneu = "F"; //$NON-NLS-1$ JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "Save"; //$NON-NLS-1$ mneu = "S"; //$NON-NLS-1$ JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$ new ActionListener() { public void actionPerformed(ActionEvent e) { write(); } }); saveMenuItem.setEnabled(false); title = "Export"; //$NON-NLS-1$ mneu = "E"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { export(); } }); title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$ mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { exportSingleLocale(); } }); title = "Exit"; //$NON-NLS-1$ mneu = "x"; //$NON-NLS-1$ if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } /* JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T"); UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener() { public void actionPerformed(ActionEvent e) { createResourceFiles(); } }); */ menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$ { schemaLocPanel.localeChanged((Locale) evt.getNewValue()); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); } } })); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setSize(800, 600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(schemaLocPanel, BorderLayout.CENTER); mainPanel.add(statusBar, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setContentPane(mainPanel); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); schemaLocPanel.setSaveMenuItem(saveMenuItem); schemaLocPanel.getContainerList().setEnabled(true); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.loadColorAndFormatPrefs(); if (localizableIO.didModelChangeDuringLoad()) { saveMenuItem.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); tp.setContentType("text/html"); tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer()); frame.setContentPane(js); frame.pack(); frame.setSize(400, 500); frame.setVisible(true); } }); } }
From source file:gui.DownloadPanel.java
public DownloadPanel(JFrame parent, String databasePath, int connectionTimeout, int readTimeout) { this.parent = parent; setLayout(new BorderLayout()); this.connectionTimeout = connectionTimeout; this.readTimeout = readTimeout; downloadDialogs = new ArrayList<>(); String connectionUrl = "jdbc:sqlite:" + databasePath + File.separator + "cheetah.db"; databaseController = new DatabaseControllerImpl("org.sqlite.JDBC", connectionUrl, 0, "", ""); try {/* w w w. j a v a2 s. c o m*/ databaseController.createTablesIfNotExist(); } catch (SQLException e) { e.printStackTrace(); } // Set up Downloads table. downloadsTableModel = new DownloadsTableModel(); downloadTable = new JTable(downloadsTableModel); popup = initPopupMenu(); downloadTable.getSelectionModel().addListSelectionListener(e -> { tableSelectionChanged(); if (downloadPanelListener != null) downloadPanelListener.downloadSelected(selectedDownload); }); // Allow only one row at a time to be selected. downloadTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set up ProgressBar as renderer for progress column. ProgressRenderer renderer = new ProgressRenderer(0, 100); renderer.setStringPainted(true); // show progress text downloadTable.setDefaultRenderer(JProgressBar.class, renderer); // Set table's row height large enough to fit JProgressBar. downloadTable.setRowHeight((int) renderer.getPreferredSize().getHeight()); downloadTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); int row = downloadTable.rowAtPoint(e.getPoint()); downloadTable.getSelectionModel().setSelectionInterval(row, row); DownloadDialog downloadDialog = getDownloadDialogByDownload(selectedDownload); if (e.getButton() == MouseEvent.BUTTON3) { // TODO right click popup.show(downloadTable, e.getX(), e.getY()); } else if (e.getClickCount() == 2) { // double click if (!downloadDialog.isVisible()) { downloadDialog.setVisible(true); } } } }); JScrollPane scrollPane = new JScrollPane(downloadTable); scrollPane.getViewport().setBackground(Color.WHITE); add(scrollPane, BorderLayout.CENTER); try { downloadList = databaseController.load(); } catch (Exception e) { e.printStackTrace(); } DownloadDialog downloadDialog; for (Download download : downloadList) { calculateDownloaded(download); download.setDownloadInfoListener(this); download.addDownloadStatusListener(this); downloadDialog = new DownloadDialog(parent, download); downloadDialog.setDownloadInfoListener(this); downloadDialogs.add(downloadDialog); downloadsTableModel.addDownload(download); downloadDialog.setDownloadRanges(download.getDownloadRangeList()); } setColumnWidths(); }