List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java
protected void doGraph() { graphPanel.removeAll();//from ww w .j ava2 s . c o m ////////System.out.println("in doGraph"); //graphPanel.add(description, BorderLayout.SOUTH); JFreeChart scatterChart = null; ChartPanel chartPanel1 = null; ChartPanel chartPanel2 = null; Chart chartFactory = new Chart(); String lineType = "excludesZeroNoShape"; /* double[] survivalTimePlot = new double[plotSize]; double[] survivalRatePlot = new double[plotSize]; //////////System.out.println("doGraph survivalTimePlot.length = " + survivalTimePlot.length); //////////System.out.println("doGraph survivalRatePlot.length = " + survivalRatePlot.length); int newIndex = 0; for (int i = 0; i < survivalRate.length; i++) { for (int j = 0; j < survivalRate[i].length; j++) { survivalTimePlot[newIndex] = survivalTime[i][j]; survivalRatePlot[newIndex] = survivalRate[i][j]; newIndex++; } } */ /* double[][] survivalTimePlot = new double[survivalTime.length][]; double[][] survivalRatePlot = new double[survivalRate.length][]; // create the first point (time = 0, rate = 1) for (int i = 0; i < survivalTime.length; i++) { survivalTimePlot[i] = new double[survivalTime[i].length + 1]; survivalRatePlot[i] = new double[survivalRate[i].length + 1]; survivalTimePlot[i][0] = 0; survivalRatePlot[i][0] = 1; for (int j = 1; j < survivalTimePlot[i].length; j++) { survivalTimePlot[i][j] = survivalTime[i][j - 1]; survivalRatePlot[i][j] = survivalRate[i][j - 1]; } } */ boolean useCI = true; // whether to plot the confidence interval. ////////System.out.println("useCI = " + useCI); double[][] survivalTimePlot = new double[survivalTime.length][]; double[][] survivalRatePlot = new double[survivalRate.length][]; double[][] survivalRateUpperCIPlot = new double[survivalRate.length][]; double[][] survivalRateLowerCIPlot = new double[survivalRate.length][]; // create the first point (time = 0, rate = 1) double tempTime = 0, tempRate = 0, tempRateUpperCI = 0, tempRateLowerCI = 0; int increment = 2; int arrayLength = 0; int k = 0; // index for survivalTime array, not for survivalTimePlot. for (int i = 0; i < survivalTime.length; i++) { arrayLength = 2 * survivalRate[i].length + increment; k = 0; // why add 2? one for the initial point, one for the last point. survivalTimePlot[i] = new double[arrayLength]; survivalRatePlot[i] = new double[arrayLength]; survivalRateUpperCIPlot[i] = new double[arrayLength]; survivalRateLowerCIPlot[i] = new double[arrayLength]; survivalTimePlot[i][0] = 0; survivalRatePlot[i][0] = 1; survivalRateUpperCIPlot[i][0] = 1; survivalRateLowerCIPlot[i][0] = 1; int j = 1; ////////System.out.println(" before loop survivalTimePlot["+i+"].length= " +survivalTimePlot[i].length); for (j = 1; j < survivalTimePlot[i].length - 1; j++) { //////////System.out.println("j = " + j + " survivalTimePlot["+i+"].length = " + survivalTimePlot[i].length + ", k = " + k); ////////System.out.println("in loop j = " + j); if (j % 2 == 1) { ////////System.out.println("in if j = " + j + ", k = " + k); survivalTimePlot[i][j] = survivalTime[i][k]; survivalRatePlot[i][j] = survivalRatePlot[i][j - 1]; survivalRateUpperCIPlot[i][j] = survivalRateUpperCIPlot[i][j - 1]; survivalRateLowerCIPlot[i][j] = survivalRateLowerCIPlot[i][j - 1]; tempTime = survivalTimePlot[i][j]; tempRate = survivalRatePlot[i][j]; tempRateUpperCI = survivalRateUpperCIPlot[i][j]; tempRateLowerCI = survivalRateLowerCIPlot[i][j]; } else { //////////System.out.println("in elsej = " + j); survivalTimePlot[i][j] = tempTime; survivalRatePlot[i][j] = survivalRate[i][k]; survivalRateUpperCIPlot[i][j] = upperCI[i][k]; survivalRateLowerCIPlot[i][j] = lowerCI[i][k]; k++; } ////////System.out.println("i = " + i + ", j = " + j + ", k = " + k + ", time["+i+"]["+j+"] = " + survivalTimePlot[i][j] + ". rate["+i+"]["+j+"] = " + survivalRatePlot[i][j]); } int index = j;//survivalTimePlot[i].length-1;//survivalTimePlot[i].length; ////////System.out.println("index = " + index); ////////System.out.println("maxTime["+i+"] = " + maxTime[i]); survivalTimePlot[i][index] = maxTime[i]; ////////System.out.println("survivalTimePlot["+i+"]["+index+"] = " + survivalTimePlot[i][index]); survivalRatePlot[i][index] = survivalRatePlot[i][index - 1]; survivalRateUpperCIPlot[i][index] = survivalRateUpperCIPlot[i][index - 1]; survivalRateLowerCIPlot[i][index] = survivalRateLowerCIPlot[i][index - 1]; } int numberGroups = 0, lineSetCount = 0, tempIndex = 0; double[][] finalTimeArray = null; double[][] finalRateArray = null; String[] finalGroupNames = null; int numberOfLines = 0; //lineSetCount * groupNames.length; Color[] colorArray = null;//new Color[numberOfLines]; ////////System.out.println("lineSetCount = " + lineSetCount); if (useCI) { numberGroups = groupNames.length; lineSetCount = 3; // use 4 if using censor points. tempIndex = 0; numberOfLines = lineSetCount * numberGroups; finalTimeArray = new double[numberOfLines][]; finalRateArray = new double[numberOfLines][]; finalGroupNames = new String[numberOfLines]; ////////System.out.println("numberOfLines = " + numberOfLines); colorArray = new Color[numberOfLines]; // why 3? one for rate, one for upper CI, one for lower CI. for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray[tempIndex] = survivalTimePlot[i]; finalTimeArray[tempIndex + 1] = survivalTimePlot[i]; finalTimeArray[tempIndex + 2] = survivalTimePlot[i]; //finalTimeArray[tempIndex+3] = censoredTime[i]; finalRateArray[tempIndex] = survivalRatePlot[i]; finalRateArray[tempIndex + 1] = survivalRateUpperCIPlot[i]; finalRateArray[tempIndex + 2] = survivalRateLowerCIPlot[i]; //finalRateArray[tempIndex+3] = censoredRate[i]; finalGroupNames[tempIndex] = groupNames[i]; finalGroupNames[tempIndex + 1] = groupNames[i] + " Upper CI"; finalGroupNames[tempIndex + 2] = groupNames[i] + " Lower CI"; //finalGroupNames[tempIndex+3] = groupNames[i] + " Censored"; if (i % 5 == 0) { colorArray[tempIndex] = Color.RED; colorArray[tempIndex + 1] = Color.PINK; colorArray[tempIndex + 2] = Color.PINK; } else if (i % 5 == 1) { colorArray[tempIndex] = Color.BLUE; colorArray[tempIndex + 1] = Color.CYAN; colorArray[tempIndex + 2] = Color.CYAN; } else if (i % 5 == 2) { colorArray[tempIndex] = Color.GRAY; colorArray[tempIndex + 1] = Color.LIGHT_GRAY; colorArray[tempIndex + 2] = Color.LIGHT_GRAY; } else if (i % 5 == 3) { colorArray[tempIndex] = Color.MAGENTA; colorArray[tempIndex + 1] = Color.PINK; colorArray[tempIndex + 2] = Color.PINK; } else { colorArray[tempIndex] = Color.GREEN; colorArray[tempIndex + 1] = Color.YELLOW; colorArray[tempIndex + 2] = Color.YELLOW; } tempIndex += lineSetCount; } } else { numberGroups = groupNames.length; lineSetCount = 2; tempIndex = 0; finalTimeArray = new double[lineSetCount * numberGroups][]; finalRateArray = new double[lineSetCount * numberGroups][]; finalGroupNames = new String[lineSetCount * numberGroups]; // why 3? one for rate, one for upper CI, one for lower CI. for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray[tempIndex] = survivalTimePlot[i]; finalTimeArray[tempIndex + 1] = censoredTime[i]; finalRateArray[tempIndex] = survivalRatePlot[i]; finalRateArray[tempIndex + 1] = censoredRate[i]; finalGroupNames[tempIndex] = groupNames[i]; //finalGroupNames[tempIndex+1] = groupNames[i] + " Censored"; tempIndex += lineSetCount; } } //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", groupNames.length, groupNames, survivalTimePlot, survivalRatePlot, lineType); //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length, finalGroupNames, finalTimeArray, finalRateArray, lineType); // this one has color. //public JFreeChart getLineChart(String title, String xLabel, String yLabel, double[] x, double[] y, Color[] colors, String other) //public JFreeChart getLineChart(String title, String xLabel, String yLabel, int numberOfLines, String[] lineNames, double[][] x, double[][] y, Color[] colors, String other) //int numberOfLines = lineSetCount * groupNames.length; //Color[] colors = new Color[numberOfLines]; //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", numberOfLines, finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType); scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length, finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType); // this one has color. //for (int i = 0; i < survivalTime.length; i++) { //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", survivalTimePlot, survivalRatePlot, lineType); //} scatterChart.setTitle("Expected Survival Times with 95% Confidence Limits"); chartPanel1 = new ChartPanel(scatterChart, false); chartPanel1.setPreferredSize(new Dimension(plotWidth, plotHeight)); JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); innerPanel.add(chartPanel1); // Add a second plot without the confidence intervals (confidence limits) int lineSetCount1 = lineSetCount - 2; int tempIndex1 = 0; double[][] finalTimeArray1 = new double[lineSetCount1 * numberGroups][]; double[][] finalRateArray1 = new double[lineSetCount1 * numberGroups][]; String[] finalGroupNames1 = new String[lineSetCount1 * numberGroups]; for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray1[tempIndex1] = survivalTimePlot[i]; //finalTimeArray1[tempIndex1+1] = censoredTime[i]; finalRateArray1[tempIndex1] = survivalRatePlot[i]; //finalRateArray1[tempIndex1+1] = censoredRate[i]; finalGroupNames1[tempIndex1] = groupNames[i]; tempIndex1 += lineSetCount1; } JFreeChart scatterChart1 = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", (lineSetCount1) * groupNames.length, finalGroupNames1, finalTimeArray1, finalRateArray1, colorArray, lineType); // this one has color. scatterChart1.setTitle("Expected Survival Times (Only)"); chartPanel2 = new ChartPanel(scatterChart1, false); chartPanel2.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel2); graphPanel.validate(); }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel pciInfo() { JPanel pciSystemPanel = new JPanel(); pciSystemPanel.setLayout(new BoxLayout(pciSystemPanel, BoxLayout.Y_AXIS)); JPanel topPanel = new JPanel(new GridLayout(1, 2)); topPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("PCIe Settings"), BorderFactory.createRaisedBevelBorder())); JPanel sPanel = new JPanel(new FlowLayout()); sPanel.add(new JLabel("Link Speed: ")); Object[] speeds = { "2.5 Gbps", "5.0 Gbps" }; final PartialDisableComboBox lspeed = new PartialDisableComboBox(); lspeed.addItems(speeds);// w ww . jav a 2 s.c o m lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); sPanel.add(lspeed); JButton setSpeed = new JButton("Go"); setSpeed.setToolTipText("This enables directed PCIe link speed change"); setSpeed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lspeed.isItemEnabled(lspeed.getSelectedIndex())) { int ret = di.setLinkSpeed(lspeed.getSelectedIndex() + 1); if (ret == 0) { //update pcie information di.get_PCIstate(); lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); } else { updateLog("Unable to set Link Speed " + lspeed.getSelectedItem(), keyWord); } } } }); sPanel.add(setSpeed); topPanel.add(sPanel); JPanel sPanel1 = new JPanel(new FlowLayout()); sPanel1.add(new JLabel("Link Width: ")); Object[] widths = { "x1", "x2", "x4", "x8" }; final PartialDisableComboBox lwidths = new PartialDisableComboBox(); lwidths.addItems(widths); lwidths.setSelectedItem("x" + di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); sPanel1.add(lwidths); JButton setWidth = new JButton("Go"); setWidth.setToolTipText("This enables directed PCIe link width change"); setWidth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lwidths.isItemEnabled(lwidths.getSelectedIndex())) { int ret = di.setLinkWidth(lwidths.getSelectedIndex() + 1); if (ret == 0) { //update pcie information // some times width change affect link speed so // enable the same in lspeedd also di.get_PCIstate(); lwidths.setItemEnabled(0, true); lwidths.setItemEnabled(1, true); lwidths.setItemEnabled(2, true); lwidths.setItemEnabled(3, true); lwidths.setSelectedItem("x" + di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); // some times width change affect link speed so // enable the same in lspeed also lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); } else { di.get_PCIstate(); int upCap = di.getPCIInfo().LinkUpCap; if (upCap == 0) updateLog("Unable to set Link Width " + lwidths.getSelectedItem() + ". PCIe link not upconfigurable", keyWord); else updateLog("Unable to set Link Width " + lwidths.getSelectedItem(), keyWord); } } } }); sPanel1.add(setWidth); topPanel.add(sPanel1); pciSystemPanel.add(topPanel); JPanel panel = new JPanel(new GridLayout(1, 2)); JPanel pciPanel = new JPanel(new BorderLayout()); pciPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("PCIe Endpoint Status"), BorderFactory.createRaisedBevelBorder())); ptable = new MyTableModel(di.getPCIInfo().getPCIData(), pcieColumnNames); pcieTable = new JTable(ptable); try { pcieTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader pcieHeader = pcieTable.getTableHeader(); pcieHeader.setForeground(new Color(92, 25, 25)); pciPanel.add(pcieHeader, BorderLayout.PAGE_START); pciPanel.add(pcieTable, BorderLayout.CENTER); panel.add(pciPanel); JPanel hostPanel = new JPanel(new BorderLayout()); hostPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Host System's Initial Credits"), BorderFactory.createRaisedBevelBorder())); htable = new MyTableModel(di.getPCIInfo().getHostedData(), pcieColumnNames); hostTable = new JTable(htable); try { hostTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader hostHeader = hostTable.getTableHeader(); hostHeader.setForeground(new Color(92, 25, 25)); hostPanel.add(hostHeader, BorderLayout.PAGE_START); hostPanel.add(hostTable, BorderLayout.CENTER); panel.add(hostPanel); pciSystemPanel.add(panel); pciSystemPanel.add(dialChart(pciSystemPanel.getWidth())); return pciSystemPanel; }
From source file:com.view.TradeWindow.java
private void TraderBlockOrdersActionPerformed(java.awt.event.ActionEvent evt) { TableModel dtm = (TableModel) TraderIncomingRequestsTable.getModel(); int nRow = dtm.getRowCount(); int nCol = dtm.getColumnCount(); Object[][] tableData = new Object[nRow][nCol]; ArrayList<SingleOrder> parsedOrders = new ArrayList(); ControllerBlockOrders control = new ControllerBlockOrders(); for (int i = 0; i < nRow; i++) { for (int j = 0; j < nCol; j++) { tableData[i][j] = dtm.getValueAt(i, j); }//from w w w. j ava2 s. c o m SingleOrder o = new SingleOrder(); o.SingleOrderMakeBlocks(tableData[i]); parsedOrders.add(o); } singleOrderLists = control.MakeBlock(parsedOrders); showMessageDialog(null, "Blocks have been successfully completed."); //dtm.setRowCount(0); TraderPlatformBlockedRequests.setLayout(new BorderLayout()); int count = 1; ArrayList<JScrollPane> paneList = new ArrayList<JScrollPane>(); for (ArrayList<SingleOrder> b : singleOrderLists) { JTable jTable = new JTable(); jTable.setModel(CTraderBlockOrder.getTableModel(b)); Dimension d = jTable.getPreferredSize(); // System.out.println(d); int rows = jTable.getRowCount(); // System.out.println(rows); JScrollPane jPane = new JScrollPane(); jPane.setPreferredSize(new Dimension(d.width, jTable.getRowHeight() * rows + 50)); jPane.add(jTable); jPane.setViewportView(jTable); paneList.add(jPane); count++; } test.add(blockOptions); int i = 0; for (final JScrollPane j : paneList) { // JButton btn = new JButton(); // btn.setText("Split Block"); // btn.setName(""+i); JPanel cPanel = new JPanel(); /* btn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { JViewport viewport = j.getViewport(); final JTable mytable = (JTable)viewport.getView(); final ArrayList<Integer> index = new ArrayList<Integer>(); for(int row = 0;row<mytable.getRowCount();row++){ if((boolean)mytable.getValueAt(row, 11)){ index.add(row); } } SplitBlockActionPerformed(evt,index,cPanel,test); } });*/ JCheckBox check = new JCheckBox(); JLabel label = new JLabel(); label.setText("Select Block"); check.setName("" + i); check.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SelectBlockActionPerformed(evt); } }); JPanel splitOptions = new JPanel(); splitOptions.add(label); splitOptions.add(check); splitOptions.setName("splitOpt"); // splitOptions.add(btn); cPanel.setName("cPanel" + i); cPanel.add(splitOptions); cPanel.add(j); cPanel.setLayout(new BoxLayout(cPanel, BoxLayout.Y_AXIS)); test.add(cPanel); cPanelList.add(cPanel); i++; } test.setLayout(new BoxLayout(test, BoxLayout.Y_AXIS)); JScrollPane p = new JScrollPane(test); p.setName("ParentP"); TraderPlatformBlockedRequests.add(p); TraderPlatformBlockedRequests.validate(); TraderPlatformTabbedPane.setSelectedIndex(TraderPlatformTabbedPane.getSelectedIndex() + 1); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * setup GUI layout for the data panel including datatable and summary textArea * *//*from w w w.j av a 2s . co m*/ protected void initTable() { tModel = new DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); dataTable = new JTable(tModel); /* System.out.println("here"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); dataTable.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.addKeyListener(this); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); headerTable.setEnabled(false); headerTable.setGridColor(Color.gray); headerTable.setShowGrid(true); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // 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) { } columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); hookTableAction(); dataPanel = new JPanel(); summaryPanel = new JTextArea(); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); Color bg = dataPanel.getBackground(); summaryPanel.setBackground(bg); summaryPanel.setEditable(false); summaryPanel.setForeground(Color.BLACK); dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }
From source file:homenetapp.HomeNetAppGui.java
/** This method is called from within the constructor to * initialize the form.//from w ww . j a va 2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { SendPacketFrame = new javax.swing.JFrame(); sendPacketButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); toNodeLabel = new javax.swing.JLabel(); toNodeSpinner = new javax.swing.JSpinner(); toDeviceLabel = new javax.swing.JLabel(); toDeviceSpinner = new javax.swing.JSpinner(); fromNodeLabel = new javax.swing.JLabel(); fromNodeSpinner = new javax.swing.JSpinner(); fromDeviceLabel = new javax.swing.JLabel(); commandLabel = new javax.swing.JLabel(); commandComboBox = new javax.swing.JComboBox(); payloadLabel = new javax.swing.JLabel(); payloadTextField = new javax.swing.JTextField(); fromDeviceSpinner = new javax.swing.JSpinner(); jSplitPane1 = new javax.swing.JSplitPane(); SettingsDialog = new javax.swing.JDialog(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel4 = new javax.swing.JPanel(); serverLabel = new javax.swing.JLabel(); apiKeyLabel = new javax.swing.JLabel(); serverTextField = new javax.swing.JTextField(); apiKeyTextField = new javax.swing.JTextField(); testButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); certPropertiesLabel = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jPanel5 = new javax.swing.JPanel(); serverPortLabel = new javax.swing.JLabel(); serverPortTextField = new javax.swing.JTextField(); enableUPnPCheckBox = new javax.swing.JCheckBox(); enableServerCheckBox = new javax.swing.JCheckBox(); jSeparator1 = new javax.swing.JSeparator(); jPanel6 = new javax.swing.JPanel(); checkForUpdatesCheckBox = new javax.swing.JCheckBox(); settingsSaveButton = new javax.swing.JButton(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)); cardPanel = new javax.swing.JPanel(); mainPanel = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jSplitPane2 = new javax.swing.JSplitPane(); jPanel2 = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); packetTextArea = new javax.swing.JTextArea(); jScrollPane3 = new javax.swing.JScrollPane(); packetListModel = new DefaultListModel(); jList1 = new javax.swing.JList(); autoUpdateToggleButton = new javax.swing.JToggleButton(); jScrollPane1 = new javax.swing.JScrollPane(); consoleTextPane = new javax.swing.JTextPane(); statusPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); localStatusLabel = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); remoteStatusLabel = new javax.swing.JLabel(); localSendingLabel = new javax.swing.JLabel(); localReceivingLabel = new javax.swing.JLabel(); remoteSendingLabel = new javax.swing.JLabel(); remoteReceivingLabel = new javax.swing.JLabel(); topMenuBar = new javax.swing.JMenuBar(); menuFile = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); menuTools = new javax.swing.JMenu(); menuToolsSendPacket = new javax.swing.JMenuItem(); menuToolsSettings = new javax.swing.JMenuItem(); menuSerialPorts = new javax.swing.JMenu(); menuHelp = new javax.swing.JMenu(); menuHelpOnline = new javax.swing.JMenuItem(); menuHelpAbout = new javax.swing.JMenuItem(); SendPacketFrame.setTitle("Send Packet"); SendPacketFrame.setMinimumSize(new java.awt.Dimension(380, 240)); SendPacketFrame.setResizable(false); SendPacketFrame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { SendPacketFrameWindowOpened(evt); } }); sendPacketButton.setText("Send"); sendPacketButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sendPacketButtonActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Packet")); toNodeLabel.setText("To Node: "); toNodeSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 4095, 1)); toDeviceLabel.setText("To Device:"); toDeviceSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 15, 1)); fromNodeLabel.setText("From Node:"); fromNodeSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 4095, 1)); fromDeviceLabel.setText("From Device:"); commandLabel.setText("Command:"); commandComboBox.setModel(new javax.swing.DefaultComboBoxModel(homenetapp.getCommandKeys())); commandComboBox.setRenderer(new CommandRenderer()); payloadLabel.setText("Payload:"); fromDeviceSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 15, 1)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(payloadLabel) .addComponent(commandLabel).addComponent(fromNodeLabel).addComponent(toNodeLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(commandComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(toNodeSpinner).addComponent(fromNodeSpinner)) .addGap(18, 18, 18) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(fromDeviceLabel).addComponent(toDeviceLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(toDeviceSpinner, 0, 0, Short.MAX_VALUE).addComponent( fromDeviceSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 37, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, Short.MAX_VALUE)) .addComponent(payloadTextField)) .addContainerGap(17, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(toNodeLabel) .addComponent(toNodeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(toDeviceLabel).addComponent(toDeviceSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(fromNodeLabel) .addComponent(fromNodeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(fromDeviceLabel).addComponent(fromDeviceSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(commandComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(commandLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(payloadTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(payloadLabel)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); javax.swing.GroupLayout SendPacketFrameLayout = new javax.swing.GroupLayout( SendPacketFrame.getContentPane()); SendPacketFrame.getContentPane().setLayout(SendPacketFrameLayout); SendPacketFrameLayout.setHorizontalGroup( SendPacketFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(SendPacketFrameLayout.createSequentialGroup().addContainerGap() .addGroup(SendPacketFrameLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(sendPacketButton).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); SendPacketFrameLayout.setVerticalGroup(SendPacketFrameLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(SendPacketFrameLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sendPacketButton) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); SettingsDialog.setTitle("HomeNet Settings"); SettingsDialog.setMinimumSize(new java.awt.Dimension(400, 300)); SettingsDialog.setResizable(false); SettingsDialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { SettingsDialogWindowOpened(evt); } }); serverLabel.setText("Server:"); apiKeyLabel.setText("API Key:"); serverTextField.setEditable(false); serverTextField.setText("homenet.me"); apiKeyTextField.setText("reallylongstringofchars"); testButton.setText("Test"); testButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { testButtonActionPerformed(evt); } }); jLabel1.setText("SSL Cert:"); certPropertiesLabel.setText("Loading..."); jButton1.setText("Paste"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(apiKeyLabel).addComponent(serverLabel)) .addComponent(jLabel1)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addComponent(certPropertiesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(testButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) .addComponent(apiKeyTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE) .addComponent(serverTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)) .addContainerGap())); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(serverTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(serverLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(apiKeyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(apiKeyLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(certPropertiesLabel).addComponent(testButton) .addComponent(jButton1)) .addContainerGap(81, Short.MAX_VALUE))); jTabbedPane1.addTab("Client", jPanel4); serverPortLabel.setText("Port:"); serverPortTextField.setEditable(false); serverPortTextField.setText("2443"); enableUPnPCheckBox.setText("Enable UPnP Portforwarding"); enableServerCheckBox.setSelected(true); enableServerCheckBox.setText("Enable Local Server"); enableServerCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { enableServerCheckBoxActionPerformed(evt); } }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(serverPortLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(serverPortTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(294, Short.MAX_VALUE)) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(enableServerCheckBox) .addContainerGap(250, Short.MAX_VALUE)) .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(enableUPnPCheckBox) .addContainerGap(208, Short.MAX_VALUE))); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(enableServerCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(serverPortTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(serverPortLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(enableUPnPCheckBox).addContainerGap(77, Short.MAX_VALUE))); jTabbedPane1.addTab("Server", jPanel5); checkForUpdatesCheckBox.setText("Check For Updates"); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout .setHorizontalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap() .addComponent(checkForUpdatesCheckBox).addContainerGap(252, Short.MAX_VALUE))); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap() .addComponent(checkForUpdatesCheckBox).addContainerGap(137, Short.MAX_VALUE))); jTabbedPane1.addTab("Preferences", jPanel6); settingsSaveButton.setText("Save"); settingsSaveButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { settingsSaveButtonActionPerformed(evt); } }); javax.swing.GroupLayout SettingsDialogLayout = new javax.swing.GroupLayout(SettingsDialog.getContentPane()); SettingsDialog.getContentPane().setLayout(SettingsDialogLayout); SettingsDialogLayout.setHorizontalGroup(SettingsDialogLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(SettingsDialogLayout.createSequentialGroup().addContainerGap().addGroup( SettingsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(settingsSaveButton, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)) .addContainerGap())); SettingsDialogLayout.setVerticalGroup(SettingsDialogLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SettingsDialogLayout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(settingsSaveButton).addContainerGap())); jTabbedPane1.getAccessibleContext().setAccessibleName("Server"); SettingsDialog.getAccessibleContext().setAccessibleName("HomeNet App Settings"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("HomeNet.me Desktop App"); cardPanel.setLayout(new java.awt.CardLayout()); mainPanel.setLayout(new javax.swing.BoxLayout(mainPanel, javax.swing.BoxLayout.Y_AXIS)); jSplitPane2.setDividerLocation(200); jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jLabel9.setText("Packets Received:"); packetTextArea.setColumns(20); packetTextArea.setFont(new java.awt.Font("Courier New", 0, 12)); packetTextArea.setRows(5); jScrollPane2.setViewportView(packetTextArea); jList1.setModel(packetListModel); jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jList1.setCellRenderer(new PacketListRenderer()); jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList1ValueChanged(evt); } }); jScrollPane3.setViewportView(jList1); autoUpdateToggleButton.setSelected(true); autoUpdateToggleButton.setText("Auto Update"); autoUpdateToggleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoUpdateToggleButtonActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9).addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(autoUpdateToggleButton).addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9).addComponent(autoUpdateToggleButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)) .addContainerGap())); jSplitPane2.setTopComponent(jPanel2); consoleTextPane.setBackground(new java.awt.Color(0, 0, 0)); consoleTextPane.setEditable(false); consoleTextPane.setFont(new java.awt.Font("Consolas", 0, 10)); consoleTextPane.setForeground(new java.awt.Color(255, 255, 255)); jScrollPane1.setViewportView(consoleTextPane); jSplitPane2.setRightComponent(jScrollPane1); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 530, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 320, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE))); mainPanel.add(jPanel3); statusPanel.setBackground(new java.awt.Color(204, 204, 204)); statusPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jLabel7.setText("Local:"); localStatusLabel.setText("Not Connected"); jLabel11.setText("Remote:"); remoteStatusLabel.setText("Not Connected"); localSendingLabel.setFont(new java.awt.Font("Courier New", 0, 11)); localSendingLabel.setText("( )"); localReceivingLabel.setFont(new java.awt.Font("Courier New", 0, 11)); localReceivingLabel.setText("( )"); remoteSendingLabel.setFont(new java.awt.Font("Courier New", 0, 11)); remoteSendingLabel.setText("( )"); remoteReceivingLabel.setFont(new java.awt.Font("Courier New", 0, 11)); remoteReceivingLabel.setText("( )"); javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel); statusPanel.setLayout(statusPanelLayout); statusPanelLayout.setHorizontalGroup(statusPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(statusPanelLayout.createSequentialGroup().addContainerGap().addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(localStatusLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(localSendingLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(localReceivingLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 177, Short.MAX_VALUE) .addComponent(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(remoteStatusLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(remoteSendingLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(remoteReceivingLabel).addContainerGap())); statusPanelLayout .setVerticalGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(localStatusLabel).addComponent(localSendingLabel) .addComponent(localReceivingLabel).addComponent(remoteSendingLabel) .addComponent(remoteReceivingLabel).addComponent(remoteStatusLabel) .addComponent(jLabel11))); mainPanel.add(statusPanel); cardPanel.add(mainPanel, "card2"); topMenuBar.setVisible(false); menuFile.setMnemonic('f'); menuFile.setText("File"); jMenuItem3.setMnemonic('e'); jMenuItem3.setText("Exit"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); menuFile.add(jMenuItem3); topMenuBar.add(menuFile); menuTools.setMnemonic('t'); menuTools.setText("Tools"); menuToolsSendPacket.setMnemonic('p'); menuToolsSendPacket.setText("Send Packet"); menuToolsSendPacket.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuToolsSendPacketActionPerformed(evt); } }); menuTools.add(menuToolsSendPacket); menuToolsSettings.setMnemonic('s'); menuToolsSettings.setText("Settings"); menuToolsSettings.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuToolsSettingsActionPerformed(evt); } }); menuTools.add(menuToolsSettings); menuSerialPorts.setMnemonic('e'); menuSerialPorts.setText("Select Ports"); menuSerialPorts.addMenuListener(new javax.swing.event.MenuListener() { public void menuCanceled(javax.swing.event.MenuEvent evt) { } public void menuDeselected(javax.swing.event.MenuEvent evt) { } public void menuSelected(javax.swing.event.MenuEvent evt) { menuSerialPortsMenuSelected(evt); } }); menuSerialPorts.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuSerialPortsActionPerformed(evt); } }); menuTools.add(menuSerialPorts); topMenuBar.add(menuTools); menuHelp.setMnemonic('h'); menuHelp.setText("Help"); menuHelpOnline.setText("Online Help"); menuHelpOnline.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuHelpOnlineActionPerformed(evt); } }); menuHelp.add(menuHelpOnline); menuHelpAbout.setText("About"); menuHelpAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuHelpAboutActionPerformed(evt); } }); menuHelp.add(menuHelpAbout); topMenuBar.add(menuHelp); setJMenuBar(topMenuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)); pack(); }
From source file:davmail.ui.SettingsFrame.java
/** * DavMail settings frame.// www . j a v a 2 s . c o m */ public SettingsFrame() { setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS")); try { setIconImage(DavGatewayTray.getFrameIcon()); } catch (NoSuchMethodError error) { DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE")); } JTabbedPane tabbedPane = new JTabbedPane(); // add help (F1 handler) tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F1"), "help"); tabbedPane.getActionMap().put("help", new AbstractAction() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { boolean isSslEnabled = isSslEnabled(); popNoSSLCheckBox.setEnabled(Settings.getProperty("davmail.popPort") != null && isSslEnabled); imapNoSSLCheckBox.setEnabled(imapPortCheckBox.isSelected() && isSslEnabled); smtpNoSSLCheckBox.setEnabled(smtpPortCheckBox.isSelected() && isSslEnabled); caldavNoSSLCheckBox.setEnabled(caldavPortCheckBox.isSelected() && isSslEnabled); ldapNoSSLCheckBox.setEnabled(ldapPortCheckBox.isSelected() && isSslEnabled); } }); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(getSettingsPanel()); mainPanel.add(getDelaysPanel()); mainPanel.add(Box.createVerticalGlue()); tabbedPane.add(BundleMessage.format("UI_TAB_MAIN"), mainPanel); JPanel proxyPanel = new JPanel(); proxyPanel.setLayout(new BoxLayout(proxyPanel, BoxLayout.Y_AXIS)); proxyPanel.add(getProxyPanel()); proxyPanel.add(getNetworkSettingsPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_NETWORK"), proxyPanel); JPanel encryptionPanel = new JPanel(); encryptionPanel.setLayout(new BoxLayout(encryptionPanel, BoxLayout.Y_AXIS)); encryptionPanel.add(getKeystorePanel()); encryptionPanel.add(getSmartCardPanel()); // empty panel encryptionPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ENCRYPTION"), encryptionPanel); JPanel loggingPanel = new JPanel(); loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS)); loggingPanel.add(getLoggingSettingsPanel()); // empty panel loggingPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_LOGGING"), loggingPanel); JPanel advancedPanel = new JPanel(); advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS)); advancedPanel.add(getOtherSettingsPanel()); // empty panel advancedPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ADVANCED"), advancedPanel); if (OSXInfoPlist.isOSX()) { JPanel osxPanel = new JPanel(); osxPanel.setLayout(new BoxLayout(osxPanel, BoxLayout.Y_AXIS)); osxPanel.add(getOSXPanel()); // empty panel osxPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_OSX"), osxPanel); } add(BorderLayout.CENTER, tabbedPane); JPanel buttonPanel = new JPanel(); JButton cancel = new JButton(BundleMessage.format("UI_BUTTON_CANCEL")); JButton ok = new JButton(BundleMessage.format("UI_BUTTON_SAVE")); JButton help = new JButton(BundleMessage.format("UI_BUTTON_HELP")); ActionListener save = new ActionListener() { public void actionPerformed(ActionEvent evt) { // save options Settings.setProperty("davmail.url", urlField.getText()); Settings.setProperty("davmail.popPort", popPortCheckBox.isSelected() ? popPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurepop", String.valueOf(popNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.imapPort", imapPortCheckBox.isSelected() ? imapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureimap", String.valueOf(imapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.smtpPort", smtpPortCheckBox.isSelected() ? smtpPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecuresmtp", String.valueOf(smtpNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.caldavPort", caldavPortCheckBox.isSelected() ? caldavPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurecaldav", String.valueOf(caldavNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.ldapPort", ldapPortCheckBox.isSelected() ? ldapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureldap", String.valueOf(ldapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.keepDelay", keepDelayField.getText()); Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText()); Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText()); Settings.setProperty("davmail.imapIdleDelay", imapIdleDelayField.getText()); Settings.setProperty("davmail.useSystemProxies", String.valueOf(useSystemProxiesField.isSelected())); Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected())); Settings.setProperty("davmail.proxyHost", httpProxyField.getText()); Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText()); Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText()); Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText()); Settings.setProperty("davmail.noProxyFor", noProxyForField.getText()); Settings.setProperty("davmail.bindAddress", bindAddressField.getText()); Settings.setProperty("davmail.clientSoTimeout", String.valueOf(clientSoTimeoutField.getText())); Settings.setProperty("davmail.allowRemote", String.valueOf(allowRemoteField.isSelected())); Settings.setProperty("davmail.server.certificate.hash", certHashField.getText()); Settings.setProperty("davmail.disableUpdateCheck", String.valueOf(disableUpdateCheck.isSelected())); Settings.setProperty("davmail.caldavEditNotifications", String.valueOf(caldavEditNotificationsField.isSelected())); Settings.setProperty("davmail.caldavAlarmSound", String.valueOf(caldavAlarmSoundField.getText())); Settings.setProperty("davmail.forceActiveSyncUpdate", String.valueOf(forceActiveSyncUpdateCheckBox.isSelected())); Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText())); Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected())); Settings.setProperty("davmail.disableGuiNotifications", String.valueOf(disableGuiNotificationsCheckBox.isSelected())); Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected())); Settings.setProperty("davmail.popMarkReadOnRetr", String.valueOf(popMarkReadOnRetrCheckBox.isSelected())); String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem(); String enableEws; if (EWS.equals(selectedEwsMode)) { enableEws = "true"; } else if (WEBDAV.equals(selectedEwsMode)) { enableEws = "false"; } else { enableEws = "auto"; } Settings.setProperty("davmail.enableEws", enableEws); Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected())); Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText()); Settings.setProperty("davmail.ssl.keystorePass", String.valueOf(keystorePassField.getPassword())); Settings.setProperty("davmail.ssl.keyPass", String.valueOf(keyPassField.getPassword())); Settings.setProperty("davmail.ssl.clientKeystoreType", (String) clientKeystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.clientKeystoreFile", clientKeystoreFileField.getText()); Settings.setProperty("davmail.ssl.clientKeystorePass", String.valueOf(clientKeystorePassField.getPassword())); Settings.setProperty("davmail.ssl.pkcs11Library", pkcs11LibraryField.getText()); Settings.setProperty("davmail.ssl.pkcs11Config", pkcs11ConfigField.getText()); Settings.setLoggingLevel("rootLogger", (Level) rootLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("davmail", (Level) davmailLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("org.apache.commons.httpclient", (Level) httpclientLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("httpclient.wire", (Level) wireLoggingLevelField.getSelectedItem()); Settings.setProperty("davmail.logFilePath", logFilePathField.getText()); Settings.setProperty("davmail.logFileSize", logFileSizeField.getText()); setVisible(false); Settings.save(); if (osxHideFromDockCheckBox != null) { OSXInfoPlist.setOSXHideFromDock(osxHideFromDockCheckBox.isSelected()); } // restart listeners with new config DavGateway.restart(); } }; ok.addActionListener(save); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { reload(); setVisible(false); } }); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); buttonPanel.add(ok); buttonPanel.add(cancel); buttonPanel.add(help); add(BorderLayout.SOUTH, buttonPanel); pack(); //setResizable(false); // center frame setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2, getToolkit().getScreenSize().height / 2 - getSize().height / 2); urlField.requestFocus(); }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;/*from www.jav a 2s.co m*/ JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:SuitaDetails.java
public ParamPanel() { setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153)), "Parameters", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(0, 0, 0))); setBackground(Color.WHITE);//from w ww . j av a2 s . c o m jPanel2 = new JPanel(); jPanel2.setBackground(Color.WHITE); JScrollPane jScrollPane3 = new JScrollPane(jPanel2); jScrollPane3.setBackground(Color.WHITE); jScrollPane3.setBorder(null); jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS)); addpanel = new JPanel(); addpanel.setMaximumSize(new Dimension(32767, 25)); addpanel.setMinimumSize(new Dimension(0, 25)); addpanel.setPreferredSize(new Dimension(50, 25)); addpanel.setLayout(new BorderLayout()); JButton add = new JButton("Add"); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { ArrayList<Integer> indexpos3 = (ArrayList<Integer>) parent.getPos().clone(); indexpos3.add(new Integer(parent.getSubItemsNr())); Item property = new Item("param", 0, -1, -1, 10, 20, indexpos3); property.setSubItemVisible(false); property.setValue(""); parent.addSubItem(property); Param prop = new Param(parent, property); jPanel2.remove(addpanel); jPanel2.add(prop); jPanel2.add(addpanel); jPanel2.revalidate(); jPanel2.repaint(); } }); addpanel.add(add, BorderLayout.EAST); addpanel.setBackground(Color.WHITE); GroupLayout paramLayout = new GroupLayout(this); this.setLayout(paramLayout); paramLayout.setHorizontalGroup( paramLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane3)); paramLayout.setVerticalGroup( paramLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane3)); }
From source file:com.xilinx.virtex7.MainScreen.java
private JPanel testAndStats() { JPanel tstats = new JPanel(); tstats.setLayout(new BoxLayout(tstats, BoxLayout.Y_AXIS)); JPanel tstats1 = new JPanel(); tstats1.setLayout(new BoxLayout(tstats1, BoxLayout.Y_AXIS)); tstats1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); tstats1.add(testPanelItems());// w ww.j a v a2s . co m JPanel dmaInner = new JPanel(new BorderLayout()); JPanel dmaPanel = new JPanel(new BorderLayout()); dmaPanel.setBackground(new Color(130, 170, 180)); table1 = new MyTableModel(dummy_data, dmaColumnNames0); dmaStats1 = new JTable(table1); try { dmaStats1.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader = dmaStats1.getTableHeader(); dmaHeader.setForeground(new Color(92, 25, 25)); dmaPanel.add(dmaHeader, BorderLayout.PAGE_START); dmaPanel.add(dmaStats1, BorderLayout.CENTER); dmaInner.add(dmaPanel, BorderLayout.CENTER); tstats1.add(dmaInner); tstats.add(tstats1); //tstats.add(trnPanel); JPanel tstats2 = new JPanel(); tstats2.setLayout(new BoxLayout(tstats2, BoxLayout.Y_AXIS)); tstats2.add(testPanelItems1()); tstats2.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); JPanel dmaPanel1 = new JPanel(new BorderLayout()); table2 = new MyTableModel(dummy_data, dmaColumnNames1); dmaStats2 = new JTable(table2); try { dmaStats2.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader1 = dmaStats2.getTableHeader(); dmaHeader1.setForeground(new Color(92, 25, 25)); dmaPanel1.add(dmaHeader1, BorderLayout.PAGE_START); dmaPanel1.add(dmaStats2, BorderLayout.CENTER); tstats2.add(dmaPanel1); tstats.add(tstats2); return tstats; }
From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java
protected JPanel layoutResults() { String serieName;/*from w ww . j ava 2 s.co m*/ if (independentHeaders != null && independentHeaders[0].lastIndexOf(":") != -1) serieName = independentHeaders[0].substring(0, independentHeaders[0].lastIndexOf(":")); else serieName = "Serie1"; JPanel j = new JPanel(); j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS)); j.add(new JLabel("ResultTable for " + serieName)); j.add(resultsTables[0]); //System.out.println("setTablePane: num_series="+num_series); for (int s = 1; s < num_series; s++) { if (independentHeaders != null && independentHeaders[s].lastIndexOf(":") != -1) serieName = independentHeaders[s].substring(0, independentHeaders[s].lastIndexOf(":")); else serieName = "Serie" + (s + 1); j.add(new JLabel("ResultTable for " + serieName)); j.add(resultsTables[s]); } return j; }