List of usage examples for javax.swing JScrollPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java
protected void setTable(XYDataset ds) { convertor.Power2Table(ds);//from w w w .j a v a 2 s . c om //convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount()); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); } columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); } dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // don't bring graph to the front if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) { // tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel)); } else { dataPanel2.removeAll(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Data")); JScrollPane dt = new JScrollPane(dataTable); dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8)); dataPanel2.add(dt); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6)); dataPanel2.add(st); st.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Mapping")); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2)); dataPanel2.add(mapPanel); dataPanel2.validate(); } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private final JPanel getMainPanel() { final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final ServerList linkedServerList = new ServerList(linkedServerListModel); linkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane linkedServerScrollPane = new JScrollPane(linkedServerList); linkedServerScrollPane/* w w w . j av a 2s. c o m*/ .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Linked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane linkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(linkedServerScrollPane, c); final ServerList unlinkedServerList = new ServerList(unlinkedServerListModel); unlinkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane unlinkedServerScrollPane = new JScrollPane(unlinkedServerList); unlinkedServerScrollPane .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Unlinked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane unlinkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final JPanel middlePanel = new JPanel(); middlePanel.setLayout(new BoxLayout(middlePanel, BoxLayout.Y_AXIS)); middlePanel.add(Box.createVerticalGlue()); final JButton linkSelectionButton = new JButton("<"); final JButton unlinkSelectionButton = new JButton(">"); linkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from unlinked to linked list final int selection = unlinkedServerList.getSelectedIndex(); if (selection < 0) { return; } final Server server = unlinkedServerListModel.getVisibleServerAtIndex(selection); unlinkedServerListModel.removeServer(server); linkedServerListModel.addServer(server); } }); unlinkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from linked to unlinked list final int selection = linkedServerList.getSelectedIndex(); if (selection < 0) { return; } final int answer = JOptionPane.showOptionDialog(LinkUnlinkWindow.this, "You are about to unlink a server. " + "Unlinking a server will permanently remove \nall data associated with " + "this server, but the server will keep running. " + "\n\nAre you sure you wish to continue?", "Unlink Server", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); if (answer != JOptionPane.YES_OPTION) { return; } final Server server = linkedServerListModel.getVisibleServerAtIndex(selection); linkedServerListModel.removeServer(server); unlinkedServerListModel.addServer(server); } }); middlePanel.add(unlinkSelectionButton); middlePanel.add(Box.createVerticalStrut(10)); middlePanel.add(linkSelectionButton); middlePanel.add(Box.createVerticalGlue()); c.gridx = 1; c.gridy = 0; c.weightx = 0.0; c.weighty = 0.0; mainPanel.add(middlePanel, c); c.gridx = 2; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(unlinkedServerScrollPane, c); return mainPanel; }
From source file:coreferenceresolver.gui.MarkupGUI.java
public MarkupGUI() throws IOException { highlightPainters = new ArrayList<>(); for (int i = 0; i < COLORS.length; ++i) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( COLORS[i]);// w w w . j av a 2s . c om highlightPainters.add(highlightPainter); } defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new BorderLayout()); this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); //create menu items JMenuItem importMenuItem = new JMenuItem("Import"); JMenuItem exportMenuItem = new JMenuItem("Export"); fileMenu.add(importMenuItem); fileMenu.add(exportMenuItem); menuBar.add(fileMenu); this.setJMenuBar(menuBar); ScrollablePanel mainPanel = new ScrollablePanel(); mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //IMPORT BUTTON importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // MarkupGUI.reviewElements.clear(); // MarkupGUI.markupReviews.clear(); JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose your markup file"); markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException, BadLocationException { readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath()); for (int i = 0; i < markupReviews.size(); ++i) { mainPanel.add(newReviewPanel(markupReviews.get(i), i)); } return null; } protected void done() { MarkupGUI.this.revalidate(); d.dispose(); } }; worker.execute(); d.setVisible(true); } else { return; } } }); //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose where your markup file saved"); markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException { for (Review review : markupReviews) { generateNPsRef(review); } int i = 0; for (ReviewElement reviewElement : reviewElements) { int j = 0; for (Element element : reviewElement.elements) { String newType = element.typeSpinner.getValue().toString(); if (newType.equals("Object")) { markupReviews.get(i).getNounPhrases().get(j).setType(0); } else if (newType.equals("Attribute")) { markupReviews.get(i).getNounPhrases().get(j).setType(3); } else if (newType.equals("Other")) { markupReviews.get(i).getNounPhrases().get(j).setType(1); } else if (newType.equals("Candidate")) { markupReviews.get(i).getNounPhrases().get(j).setType(2); } ++j; } ++i; } initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "markup.out.txt"); return null; } protected void done() { d.dispose(); try { Desktop.getDesktop() .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath())); } catch (IOException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }; worker.execute(); d.setVisible(true); } else { return; } } }); JScrollPane scrollMainPane = new JScrollPane(mainPanel); scrollMainPane.getVerticalScrollBar().setUnitIncrement(16); scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); scrollMainPane.setSize(this.getWidth(), this.getHeight()); this.setResizable(false); this.add(scrollMainPane, BorderLayout.CENTER); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.pack(); }
From source file:Visuals.RingChart.java
public JPanel addAVCharts() { JPanel thisPanel = new JPanel(); thisPanel.setLayout(new BorderLayout()); int tempCriticalCount = 0, tempUpdatedCount = 0; String[][] criticalList = new String[critical][4]; String[][] updatedList = new String[low][4]; for (int i = 0; i < riskCount; i++) { if (risks[i][2].equals("Critical")) { criticalList[tempCriticalCount][0] = risks[i][0]; criticalList[tempCriticalCount][1] = risks[i][1]; criticalList[tempCriticalCount][3] = risks[i][3]; tempCriticalCount++;/* www . jav a 2 s .c o m*/ } if (risks[i][2].equals("Low")) { updatedList[tempUpdatedCount][0] = risks[i][0]; updatedList[tempUpdatedCount][1] = risks[i][1]; tempUpdatedCount++; } } JTable criticalTable = new JTable(criticalList, criticalColumns); JTable updatedTable = new JTable(updatedList, updatedColumns); TableColumn tcol = criticalTable.getColumnModel().getColumn(2); criticalTable.removeColumn(tcol); TableColumn tcol2 = updatedTable.getColumnModel().getColumn(2); updatedTable.removeColumn(tcol2); criticalTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); updatedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); criticalTable.setEnabled(false); updatedTable.setEnabled(false); int width = 0; for (int i = 0; i < 3; i++) { for (int row = 0; row < criticalTable.getRowCount(); row++) { TableCellRenderer renderer = criticalTable.getCellRenderer(row, i); Component comp = criticalTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } criticalTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } for (int i = 0; i < 2; i++) { for (int row = 0; row < updatedTable.getRowCount(); row++) { TableCellRenderer renderer = updatedTable.getCellRenderer(row, i); Component comp = updatedTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } updatedTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } criticalTable.setShowHorizontalLines(true); criticalTable.setRowHeight(40); updatedTable.setShowHorizontalLines(true); updatedTable.setRowHeight(40); JScrollPane criticalTableScrollPane = new JScrollPane(criticalTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane updatedTableScrollPane = new JScrollPane(updatedTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = criticalTable.getPreferredSize(); criticalTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (criticalTable.getRowHeight() + 1) * (tempCriticalCount + 1))); Dimension d2 = updatedTable.getPreferredSize(); updatedTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (updatedTable.getRowHeight() + 1) * (tempUpdatedCount + 1))); Font titleFonts = new Font("Calibri", Font.BOLD, 30); JLabel criticalLabel = new JLabel(" Critical "); criticalLabel.setFont(titleFonts); criticalLabel.setForeground(new Color(230, 27, 27)); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BorderLayout()); leftPanel.add(criticalLabel, BorderLayout.WEST); leftPanel.add(criticalTableScrollPane, BorderLayout.CENTER); JLabel updatedLabel = new JLabel(" Updated "); updatedLabel.setFont(titleFonts); updatedLabel.setForeground(new Color(47, 196, 6)); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(updatedLabel, BorderLayout.WEST); rightPanel.add(updatedTableScrollPane, BorderLayout.CENTER); if (tempCriticalCount != 0) thisPanel.add(leftPanel, BorderLayout.NORTH); if (tempUpdatedCount != 0) thisPanel.add(rightPanel, BorderLayout.SOUTH); return thisPanel; }
From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(List<Action> quickOpenActionList, List<File> fileList, String title) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); if (fileList.isEmpty()) { JLabel noneLabel = new JLabel("None"); noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); panel.add(noneLabel);//www . ja v a 2s.co m } else { for (File file : fileList) { Action quickOpenAction = new QuickOpenAction(file); quickOpenActionList.add(quickOpenAction); JButton quickOpenButton = new JButton(quickOpenAction); quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT); quickOpenButton.setMargin(new Insets(0, 0, 0, 0)); panel.add(quickOpenButton); } } JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:view.App.java
private void initGUI() { try {/* ww w . j a va2s .c om*/ { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.setPreferredSize(new java.awt.Dimension(901, 398)); { jPanel2 = new JPanel(); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); jPanel1.add(jPanel2, BorderLayout.WEST); jPanel2.setPreferredSize(new java.awt.Dimension(292, 446)); { jPanel5 = new JPanel(); jPanel2.add(jPanel5); jPanel5.setPreferredSize(new java.awt.Dimension(292, 109)); { { jTextArea1 = new JTextArea(); jTextArea1.setWrapStyleWord(true); jTextArea1.setLineWrap(true); DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); jTextArea1.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { if (jTable1.getModel().getRowCount() == 0 && !jButton1.isEnabled()) { jButton1.setEnabled(true); jTextArea1.setText(""); } } }); JScrollPane sp = new JScrollPane(); sp.setPreferredSize(new java.awt.Dimension(281, 97)); sp.setViewportView(jTextArea1); jPanel5.add(sp, BorderLayout.CENTER); } } } { jPanel4 = new JPanel(); jPanel2.add(jPanel4); FlowLayout jPanel4Layout = new FlowLayout(); jPanel4Layout.setAlignment(FlowLayout.RIGHT); jPanel4.setPreferredSize(new java.awt.Dimension(292, 45)); jPanel4.setSize(102, 51); jPanel4.setLayout(jPanel4Layout); { jButton1 = new JButton(); jPanel4.add(jButton1); jButton1.setText("Get Quotes"); jButton1.setSize(100, 50); jButton1.setPreferredSize(new java.awt.Dimension(100, 26)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // String tickerStr = jTextArea1.getText(); if (tickerStr.equals("") || tickerStr.equals(null) || tickerStr.equals(" ")) { jTextArea1.setText(" "); return; } StringTokenizer tokenizer = new StringTokenizer(tickerStr, " "); String[] tickers = new String[tokenizer.countTokens()]; int i = 0; while (tokenizer.hasMoreTokens()) { tickers[i] = tokenizer.nextToken(); i++; } try { Controller.getQuotes(tickers); } catch (CloneNotSupportedException e) { JOptionPane.showMessageDialog(jPanel1, " "); } jButton1.setEnabled(false); } }); } } { jPanel6 = new JPanel(); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); jPanel2.add(jPanel6); { jScrollPane1 = new JScrollPane(); jPanel6.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(292, 341)); { TableModel jTable1Model = new DefaultTableModel(null, new String[] { "", "MA Value", "", "MA Value" }); jTable1 = new JTable(); jScrollPane1.setViewportView(jTable1); jTable1.setModel(jTable1Model); jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel1.add(jPanel3, BorderLayout.CENTER); { // chart = ChartFactory.createLineChart(" ", "dates", "correlation ratio", null, // PlotOrientation.VERTICAL, true, true, false); // ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) ); // jPanel3.add(chartPanel); } { } } } this.setSize(966, 531); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { // newFileMenuItem = new JMenuItem(); // jMenu3.add(newFileMenuItem); // newFileMenuItem.setText("New"); // newFileMenuItem.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent evt) { //// jTextArea1.setText(""); //// DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); //// model.setRowCount(0); //// Controller.clearPortfolio(); // } // }); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int action = JOptionPane.showConfirmDialog(jPanel1, " ?", "Confirm Exit", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); cutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); jTextArea1.setText(""); } }); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); copyMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); } }); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); pasteMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); try { String data = (String) clp.getData(DataFlavor.stringFlavor); jTextArea1.setText(data); } catch (UnsupportedFlavorException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("About"); helpMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(jPanel1, " . r.zhumagulov@gmail.com", "About", JOptionPane.PLAIN_MESSAGE); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:is.iclt.jcorpald.CorpaldView.java
public void createAndShowGUI() { CorpaldSettings settings = CorpaldSettings.getInstance(); //Create and set up the window. JFrame frame = new JFrame(settings.getProperty("corpus.acronym") + " " + settings.getProperty("corpus.version") + " - " + settings.getProperty("corpus.longname")); frame.setIconImage((new ImageIcon("icons/corpald.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setBounds(50, 50, 700, 450); frame.setPreferredSize(new Dimension(750, 720)); // Create the panel that has the query and the result JPanel panMainArea = new JPanel(new BorderLayout()); JPanel panQuery = new JPanel(new BorderLayout()); txtQuery = new JHighlightPane(); txtQuery.addKeyListener(this); txtQuery.setFont(new Font("Monospaced", Font.BOLD, 16)); this.updateHighlighting(); txtQuery.setPreferredSize(new Dimension(700, 150)); panQuery.add(labQuery, BorderLayout.NORTH); panQuery.add(new JScrollPane(txtQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER); panQuery.setBorder(new EmptyBorder(0, 10, 10, 10)); String welcomeMessage = ""; try {/*from w ww. ja v a 2 s. c om*/ welcomeMessage = FileUtils.readFileToString(new File(settings.getProperty("corpus.welcome")), "utf-8"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } JPanel panResult = new JPanel(new BorderLayout()); txtResult = new JTextArea(welcomeMessage); txtResult.setEditable(false); txtResult.setFont(new Font("Monospaced", Font.BOLD, 14)); JScrollPane scrResult = new JScrollPane(txtResult, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrResult.setPreferredSize(new Dimension(700, 400)); panResult.add(new JLabel("Result:"), BorderLayout.NORTH); panResult.add(scrResult, BorderLayout.CENTER); panResult.setBorder(new EmptyBorder(0, 10, 0, 10)); panMainArea.add(panQuery, BorderLayout.NORTH); panMainArea.add(panResult, BorderLayout.CENTER); // Create panel at top with buttons JPanel panToolbar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // New, Open, Save // New ImageIcon icoNewQuery = new ImageIcon("icons/page_white.png"); butNewQuery = new JButton(icoNewQuery); butNewQuery.addActionListener(this); butNewQuery.setPreferredSize(new Dimension(26, 26)); butNewQuery.setToolTipText("Create a new empty query"); panToolbar.add(butNewQuery); // Open ImageIcon icoOpenQuery = new ImageIcon("icons/folder.png"); butOpenQuery = new JButton(icoOpenQuery); butOpenQuery.addActionListener(this); butOpenQuery.setPreferredSize(new Dimension(26, 26)); butOpenQuery.setToolTipText("Open a query file"); panToolbar.add(butOpenQuery); // Save ImageIcon icoSaveQuery = new ImageIcon("icons/page_save.png"); butSaveQuery = new JButton(icoSaveQuery); butSaveQuery.addActionListener(this); butSaveQuery.setPreferredSize(new Dimension(26, 26)); butSaveQuery.setToolTipText("Save current query"); panToolbar.add(butSaveQuery); // Save as ImageIcon icoSaveQueryAs = new ImageIcon("icons/page_save_as.png"); butSaveQueryAs = new JButton(icoSaveQueryAs); butSaveQueryAs.addActionListener(this); butSaveQueryAs.setPreferredSize(new Dimension(26, 26)); butSaveQueryAs.setToolTipText("Save current query under a new file name"); panToolbar.add(butSaveQueryAs); // Open definitions file ImageIcon icoOpenDef = new ImageIcon("icons/folder_table.png"); butOpenDef = new JButton(icoOpenDef); butOpenDef.addActionListener(this); butOpenDef.setPreferredSize(new Dimension(26, 26)); butOpenDef.setToolTipText("Select a new definitions file"); panToolbar.add(butOpenDef); // Run Query button ImageIcon icoRunQuery = new ImageIcon("icons/control_play_blue.png"); butRunQuery = new JButton("Run Query", icoRunQuery); butRunQuery.setPreferredSize(new Dimension(130, 26)); butRunQuery.addActionListener(this); butRunQuery.setToolTipText("Run the current query using CorpusSearch"); panToolbar.add(butRunQuery); // TextField for root node label JLabel labRootNode = new JLabel("Root:"); panToolbar.add(labRootNode); txtRootNode = new JTextField("", 12); txtRootNode.setPreferredSize(new Dimension(50, 26)); txtRootNode.addKeyListener(this); txtRootNode.setMargin(new Insets(3, 3, 3, 3)); txtRootNode.setToolTipText("<html>Search within instances of a particular type of node,<br/>" + "such as IP-*, IP-SUB, NP-*, etc. $ROOT matches<br/>" + "the root node of every tree in the corpus.</html>"); panToolbar.add(txtRootNode); chkNodesOnly = new JCheckBox("Nodes only"); chkNodesOnly.addItemListener(this); chkNodesOnly.setToolTipText("<html>If checked, CorpusSearch prints out only the nodes that<br/>" + "contain the structure described in \"Query\". If not checked,<br/>" + "CorpusSearch prints out the entire sentence that contains the<br/>" + "structure described in \"Query\".</html>"); panToolbar.add(chkNodesOnly); chkRemoveNodes = new JCheckBox("Remove nodes"); chkRemoveNodes.addItemListener(this); chkRemoveNodes.setToolTipText("<html>Remove subtrees whose root is of the same syntactic category<br/>" + "as the node boundary embedded within a instance of that node<br/>" + "boundary. \"Remove nodes\" thus removes recursive structure.</html>"); panToolbar.add(chkRemoveNodes); // Create panel at top with buttons JPanel panBottombar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // panBottombar.setBorder(new EmptyBorder(0, 0, 10, 5)); ImageIcon icoOpenFolder = new ImageIcon("icons/folder.png"); butOpenFolder = new JButton("Show result in folder", icoOpenFolder); butOpenFolder.setEnabled(false); butOpenFolder.addActionListener(this); panBottombar.add(butOpenFolder); ImageIcon icoTextEditor = new ImageIcon("icons/page_white_go.png"); butTextEditor = new JButton("Open result in text editor", icoTextEditor); butTextEditor.setEnabled(false); butTextEditor.addActionListener(this); panBottombar.add(butTextEditor); ImageIcon icoCopyResults = new ImageIcon("icons/page_copy.png"); butCopyResults = new JButton("Copy result to clipboard", icoCopyResults); butCopyResults.setEnabled(false); butCopyResults.addActionListener(this); panBottombar.add(butCopyResults); // Add stuff to top level content pane frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(panToolbar, BorderLayout.NORTH); frame.getContentPane().add(panMainArea, BorderLayout.CENTER); frame.getContentPane().add(panBottombar, BorderLayout.SOUTH); this.configureFileFilters(); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(JPanel panel, String title, List<Action> quickOpenActionList, List<File> fileList) { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); refreshQuickOpenPanel(panel, quickOpenActionList, fileList); JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:net.pms.newgui.StatusTab.java
public JComponent build() { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec("pref, 30dlu, fill:pref:grow, 30dlu, pref", orientation); // 1 2 3 4 5 FormLayout layout = new FormLayout(colSpec, // 1 2 3 4 5 // ////////////////////////////////////////////////// "p," // Detected Media Renderers --------------------// 1 + "9dlu," // // + "fill:p:grow," // <renderers> // 3 + "3dlu," // // + "p," // ---------------------------------------------// 5 + "3dlu," // | | // + "p," // Connected | Memory Usage |<bitrate> // 7 + "3dlu," // | | // + "p," // <icon> | <statusbar> | // 9 ////////////////////////////////////////////////// );//from ww w. j av a 2 s .c o m PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.DIALOG); builder.opaque(true); CellConstraints cc = new CellConstraints(); // Renderers JComponent cmp = builder.addSeparator(Messages.getString("StatusTab.9"), FormLayoutUtil.flip(cc.xyw(1, 1, 5), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); Font bold = cmp.getFont().deriveFont(Font.BOLD); Color fgColor = new Color(68, 68, 68); cmp.setFont(bold); renderers = new JPanel(new GuiUtil.WrapLayout(FlowLayout.CENTER, 20, 10)); JScrollPane rsp = new JScrollPane(renderers, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); rsp.setBorder(BorderFactory.createEmptyBorder()); rsp.setPreferredSize(new Dimension(0, 260)); rsp.getHorizontalScrollBar().setLocation(0, 250); builder.add(rsp, cc.xyw(1, 3, 5)); cmp = builder.addSeparator(null, FormLayoutUtil.flip(cc.xyw(1, 5, 5), colSpec, orientation)); // Connected jl = new JLabel(Messages.getString("StatusTab.3")); builder.add(jl, FormLayoutUtil.flip(cc.xy(1, 7, "center, top"), colSpec, orientation)); jl.setFont(bold); jl.setForeground(fgColor); imagePanel = buildImagePanel("/resources/images/icon-status-connecting.png"); builder.add(imagePanel, FormLayoutUtil.flip(cc.xy(1, 9), colSpec, orientation)); // Memory memBarUI = new GuiUtil.SegmentedProgressBarUI(Color.white, Color.gray); memBarUI.setActiveLabel("{}", Color.white, 0); memBarUI.setActiveLabel("{}", Color.red, 90); memBarUI.addSegment("", memColor); memBarUI.addSegment("", bufColor); memBarUI.setTickMarks(getTickMarks(), "{}"); memoryProgressBar = new GuiUtil.CustomUIProgressBar(0, 100, memBarUI); memoryProgressBar.setStringPainted(true); memoryProgressBar.setForeground(new Color(75, 140, 181)); memoryProgressBar.setString(Messages.getString("StatusTab.5")); JLabel mem = builder .addLabel( "<html><b>" + Messages.getString("StatusTab.6") + "</b> (" + Messages.getString("StatusTab.12") + ")</html>", FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation)); mem.setForeground(fgColor); builder.add(memoryProgressBar, FormLayoutUtil.flip(cc.xyw(3, 9, 1), colSpec, orientation)); // Bitrate String bitColSpec = "left:pref, 3dlu, right:pref:grow"; PanelBuilder bitrateBuilder = new PanelBuilder(new FormLayout(bitColSpec, "p, 1dlu, p, 1dlu, p")); bitrateLabel = new JLabel("<html><b>" + Messages.getString("StatusTab.13") + "</b> (" + Messages.getString("StatusTab.11") + ")</html>"); bitrateLabel.setForeground(fgColor); bitrateBuilder.add(bitrateLabel, FormLayoutUtil.flip(cc.xy(1, 1), bitColSpec, orientation)); currentBitrateLabel = new JLabel(Messages.getString("StatusTab.14")); currentBitrateLabel.setForeground(fgColor); bitrateBuilder.add(currentBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 3), bitColSpec, orientation)); currentBitrate = new JLabel("0"); currentBitrate.setForeground(fgColor); bitrateBuilder.add(currentBitrate, FormLayoutUtil.flip(cc.xy(3, 3), bitColSpec, orientation)); peakBitrateLabel = new JLabel(Messages.getString("StatusTab.15")); peakBitrateLabel.setForeground(fgColor); bitrateBuilder.add(peakBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 5), bitColSpec, orientation)); peakBitrate = new JLabel("0"); peakBitrate.setForeground(fgColor); bitrateBuilder.add(peakBitrate, FormLayoutUtil.flip(cc.xy(3, 5), bitColSpec, orientation)); builder.add(bitrateBuilder.getPanel(), FormLayoutUtil.flip(cc.xywh(5, 7, 1, 3, "left, top"), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(BorderFactory.createEmptyBorder()); startMemoryUpdater(); return scrollPane; }
From source file:com.game.ui.views.CharacterEditor.java
/** * This method draws up the gui on the panel. *///from ww w .j a v a 2s . c o m public void doGui() { JPanel outerPane = new JPanel(); outerPane.setLayout(new GridBagLayout()); // setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel(lblContent); noteLbl.setAlignmentX(0); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 4; c.gridy = 0; c.gridx = 0; outerPane.add(noteLbl, c); System.out.println(c.gridy); c.gridy++; System.out.println(c.gridy); c.gridx = 0; c.gridwidth = 1; comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); outerPane.add(comboBox, c); c.gridy++; JLabel nameLbl = new JLabel("Name : "); outerPane.add(nameLbl, c); c.gridx++; name = new JTextField(); name.setColumns(20); outerPane.add(name, c); c.gridx = 0; c.gridy++; JLabel imageLbl = new JLabel("Image Path : "); outerPane.add(imageLbl, c); c.gridx++; imgPath = new JTextField(); imgPath.setColumns(20); outerPane.add(imgPath, c); c.gridx = 0; c.gridy++; JLabel hitPtsLbl = new JLabel("Hit Points : "); outerPane.add(hitPtsLbl, c); c.gridx++; hitPoints = new JTextField(); hitPoints.setColumns(20); outerPane.add(hitPoints, c); c.gridx = 0; c.gridy++; JLabel lvl = new JLabel("Level : "); outerPane.add(lvl, c); c.gridx++; level = new JTextField(); level.setColumns(20); /*if(!isEnemy){ level.setText("1"); level.setEnabled(false); }*/ outerPane.add(level, c); c.gridx = 0; c.gridy++; JLabel mlWpn = new JLabel("Melee Weapon : "); outerPane.add(mlWpn, c); c.gridx++; model = new DefaultComboBoxModel(); LinkedList<String> meleeWpnList = new LinkedList<String>(); LinkedList<String> rngdWpnList = new LinkedList<String>(); for (Item item : GameBean.weaponDetails) { Weapon wpn = (Weapon) item; if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) { meleeWpnList.add(wpn.getName()); } else { rngdWpnList.add(wpn.getName()); } weaponMap.put(wpn.getName(), wpn); } meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray())); meleeWeapon.setSelectedIndex(-1); meleeWeapon.setMaximumSize(new Dimension(100, 30)); outerPane.add(meleeWeapon, c); c.gridx++; JLabel rngdWpn = new JLabel("Ranged Weapon : "); outerPane.add(rngdWpn, c); c.gridx++; rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray())); rangedWeapon.setSelectedIndex(-1); rangedWeapon.setMaximumSize(new Dimension(100, 30)); outerPane.add(rangedWeapon, c); c.gridy++; c.gridx = 0; JLabel armourLbl = new JLabel("Armour : "); outerPane.add(armourLbl, c); c.gridx++; LinkedList<String> armourList = new LinkedList<String>(); LinkedList<String> shildList = new LinkedList<String>(); for (Item item : GameBean.armourDetails) { Armour temp = (Armour) item; if (temp.getArmourType() != null) { if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) { armourList.add(temp.getName()); } else { shildList.add(temp.getName()); } } else { armourList.add(temp.getName()); // else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2])) shildList.add(temp.getName()); } armorMap.put(temp.getName(), temp); } armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray())); armour.setSelectedIndex(-1); armour.setMaximumSize(new Dimension(100, 30)); outerPane.add(armour, c); c.gridx++; JLabel shieldLbl = new JLabel("Shield : "); outerPane.add(shieldLbl, c); c.gridx++; shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray())); shield.setSelectedIndex(-1); shield.setMaximumSize(new Dimension(100, 30)); outerPane.add(shield, c); ta = new JTextArea(10, 50); ta.setRows(40); ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); JScrollPane scrollPane = new JScrollPane(ta); scrollPane.setPreferredSize(new Dimension(600, 250)); c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.BOTH; c.gridwidth = 4; c.gridheight = 4; c.weightx = .5; c.weighty = 1; outerPane.add(scrollPane, c); c.gridy += 4; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridheight = 1; c.gridwidth = 1; JButton generate = new JButton("Generate"); JButton submit = new JButton("Submit"); outerPane.add(generate, c); submit.addActionListener(this); generate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ta.setText(""); HashSet<Integer> set = new HashSet<Integer>(); int strength = getUniqueVal(set); int constitution = getUniqueVal(set); int dext = getUniqueVal(set); int intel = getUniqueVal(set); int charisma = getUniqueVal(set); int wisdom = getUniqueVal(set); if (character == null) { builder = new CharacterBuilder(isEnemy); } else { builder = new CharacterBuilder(character); } builder.setStrength(strength); builder.setConstitution(constitution); builder.setDexterity(dext); builder.setIntelligence(intel); builder.setCharisma(charisma); builder.setWisdom(wisdom); int strModifier = GameUtils.calculateAbilityModifier(strength); int conModifier = GameUtils.calculateAbilityModifier(constitution); int dexModifier = GameUtils.calculateAbilityModifier(dext); int wisModifier = GameUtils.calculateAbilityModifier(wisdom); int intModifier = GameUtils.calculateAbilityModifier(intel); int chaModifier = GameUtils.calculateAbilityModifier(charisma); builder.setStrengthModifier(strModifier); builder.setConstitutionModifier(conModifier); builder.setCharismaModifier(chaModifier); builder.setWisdomModifier(wisModifier); builder.setIntelligenceModifier(intModifier); builder.setDexterityModifier(dexModifier); String type = null; if (constitution < strength && constitution > dext) { type = "Bully"; builder.setType("Bully"); } else if (dext > constitution && constitution > strength) { builder.setType("Nimble"); type = "Nimble"; } else { builder.setType("Tank"); type = "Tank"; } ta.append("Strength : " + strength); ta.append("\nDexterity : " + dexModifier); ta.append("\nConstitution : " + constitution); ta.append("\nIntelligence : " + intel); ta.append("\nCharisma: " + charisma); ta.append("\nWisdom : " + wisdom); ta.append("\nType :" + type); ta.append("\nStrength Modifier :" + strModifier); ta.append("\nConstitution Modifier :" + conModifier); ta.append("\nDexterity Modifier :" + dexModifier); generated = true; if (character != null) { character = builder.build(); } } }); c.gridx++; outerPane.add(submit, c); validationMess = new JLabel(); validationMess.setForeground(Color.red); // validationMess.setVisible(false); c.gridy++; c.gridx = 0; c.gridwidth = 4; outerPane.add(validationMess, c); JScrollPane outerScrollPane = new JScrollPane(outerPane); setLayout(new BorderLayout()); add(outerScrollPane, BorderLayout.CENTER); }