List of usage examples for java.awt BorderLayout PAGE_START
String PAGE_START
To view the source code for java.awt BorderLayout PAGE_START.
Click Source Link
From source file:DialogDemo.java
/** * Like createPane, but creates a pane with 2 columns of radio buttons. The * number of buttons passed in *must* be even. */// w w w.java2 s . c o m private JPanel create2ColPane(String description, JRadioButton[] radioButtons, JButton showButton) { JLabel label = new JLabel(description); int numPerColumn = radioButtons.length / 2; JPanel grid = new JPanel(new GridLayout(0, 2)); for (int i = 0; i < numPerColumn; i++) { grid.add(radioButtons[i]); grid.add(radioButtons[i + numPerColumn]); } JPanel box = new JPanel(); box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS)); box.add(label); grid.setAlignmentX(0.0f); box.add(grid); JPanel pane = new JPanel(new BorderLayout()); pane.add(box, BorderLayout.PAGE_START); pane.add(showButton, BorderLayout.PAGE_END); return pane; }
From source file:project16.Home16.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.// w w w.j a v a2 s .co m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { pnl_sidebar = new javax.swing.JPanel(); lbl_west = new javax.swing.JLabel(); lbl_north = new javax.swing.JLabel(); lbl_south = new javax.swing.JLabel(); lbl_east = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); pnl_chart = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); pnl_table = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(255, 255, 255)); setLocationByPlatform(true); setUndecorated(true); pnl_sidebar.setBackground(new java.awt.Color(34, 41, 50)); pnl_sidebar.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { pnl_sidebarMouseDragged(evt); } }); pnl_sidebar.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { pnl_sidebarMousePressed(evt); } }); lbl_west.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N lbl_west.setForeground(new java.awt.Color(166, 166, 166)); lbl_west.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project16/Icons/plus_18px_1.png"))); // NOI18N lbl_west.setText("Western Field"); lbl_west.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { lbl_westMousePressed(evt); } }); lbl_north.setBackground(new java.awt.Color(48, 201, 235)); lbl_north.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N lbl_north.setForeground(new java.awt.Color(48, 201, 235)); lbl_north.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project16/Icons/home_18px.png"))); // NOI18N lbl_north.setText("Northern Field"); lbl_north.setToolTipText(""); lbl_north.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { lbl_northMousePressed(evt); } }); lbl_south.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N lbl_south.setForeground(new java.awt.Color(166, 166, 166)); lbl_south.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project16/Icons/clock_18px.png"))); // NOI18N lbl_south.setText("Southern Field"); lbl_south.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { lbl_southMousePressed(evt); } }); lbl_east.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N lbl_east.setForeground(new java.awt.Color(166, 166, 166)); lbl_east.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project16/Icons/search_18px_2.png"))); // NOI18N lbl_east.setText("Eastern Field"); lbl_east.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { lbl_eastMousePressed(evt); } }); jPanel1.setBackground(new java.awt.Color(22, 27, 33)); jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N jLabel2.setForeground(new java.awt.Color(153, 153, 153)); jLabel2.setText("(c) KeepToo 2017"); 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(75, 75, 75).addComponent(jLabel2) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(30, Short.MAX_VALUE).addComponent(jLabel2).addGap(21, 21, 21))); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setIcon( new javax.swing.ImageIcon(getClass().getResource("/project16/Icons/speech_bubble_25px.png"))); // NOI18N javax.swing.GroupLayout pnl_sidebarLayout = new javax.swing.GroupLayout(pnl_sidebar); pnl_sidebar.setLayout(pnl_sidebarLayout); pnl_sidebarLayout.setHorizontalGroup(pnl_sidebarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnl_sidebarLayout.createSequentialGroup() .addContainerGap(53, Short.MAX_VALUE) .addGroup(pnl_sidebarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnl_sidebarLayout.createSequentialGroup().addGroup(pnl_sidebarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lbl_north, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lbl_south, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lbl_west, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lbl_east, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnl_sidebarLayout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(92, 92, 92))))); pnl_sidebarLayout.setVerticalGroup(pnl_sidebarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnl_sidebarLayout.createSequentialGroup().addGap(56, 56, 56) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(50, 50, 50) .addComponent(lbl_north, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lbl_south, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lbl_west, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lbl_east, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); pnl_chart.setBackground(new java.awt.Color(54, 63, 73)); pnl_chart.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { pnl_chartMouseDragged(evt); } }); pnl_chart.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { pnl_chartMousePressed(evt); } }); pnl_chart.setLayout(new java.awt.BorderLayout()); jLabel1.setBackground(new java.awt.Color(34, 41, 50)); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 255, 255)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1.setText("X "); jLabel1.setOpaque(true); jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { jLabel1MousePressed(evt); } }); pnl_chart.add(jLabel1, java.awt.BorderLayout.PAGE_START); jTextField1.setBackground(new java.awt.Color(54, 63, 73)); jTextField1.setForeground(new java.awt.Color(255, 255, 255)); jTextField1.setText(" Search"); jTextField1.setToolTipText(""); jTextField1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 2, 0)); jTextField1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jTextField1FocusGained(evt); } }); jTextField1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { jTextField1MouseEntered(evt); } }); pnl_chart.add(jTextField1, java.awt.BorderLayout.PAGE_END); pnl_table.setBackground(new java.awt.Color(255, 255, 255)); pnl_table.setLayout(new javax.swing.BoxLayout(pnl_table, javax.swing.BoxLayout.LINE_AXIS)); jScrollPane1.setBackground(new java.awt.Color(255, 255, 255)); jScrollPane1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, true)); jScrollPane1.setOpaque(false); jTable1.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N jTable1.setForeground(new java.awt.Color(51, 51, 51)); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { "1", "Lex Fontier", "EA", "TY" }, { "2", "Ryan Reynold", "US", "NY" }, { "3", "Jackie Wuan", "CH", "HK" }, { "4", "Monty Rattler", "UK", "LD" } }, new String[] { "ID", "NAME", "COUNTRY", "STATE" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } }); jTable1.setGridColor(new java.awt.Color(255, 255, 255)); jTable1.setRowHeight(20); jTable1.setSelectionBackground(new java.awt.Color(62, 226, 141)); jTable1.setShowHorizontalLines(false); jTable1.setShowVerticalLines(false); jScrollPane1.setViewportView(jTable1); pnl_table.add(jScrollPane1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(pnl_sidebar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnl_chart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnl_table, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnl_sidebar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(pnl_chart, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(pnl_table, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); pack(); }
From source file:JDAC.JDAC.java
public JDAC() { setTitle("JDAC"); ImageIcon img = new ImageIcon("logo.png"); setIconImage(img.getImage());/* ww w . j a va 2 s .co m*/ //setLayout(new FlowLayout()); mDataset = createDataset("A"); mChart = ChartFactory.createXYLineChart("Preview", "Time (ms)", "Value", mDataset, PlotOrientation.VERTICAL, false, true, false); mLastChart = ChartFactory.createXYLineChart("Last n values", "Time (ms)", "Value", createLastDataset("B"), PlotOrientation.VERTICAL, false, true, false); mChart.getXYPlot().getDomainAxis().setLowerMargin(0); mChart.getXYPlot().getDomainAxis().setUpperMargin(0); mLastChart.getXYPlot().getDomainAxis().setLowerMargin(0); mLastChart.getXYPlot().getDomainAxis().setUpperMargin(0); ChartPanel chartPanel = new ChartPanel(mChart); ChartPanel chartLastPanel = new ChartPanel(mLastChart); //chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) ); XYPlot plot = mChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesStroke(0, new BasicStroke(1.0f)); plot.setRenderer(renderer); XYPlot lastPlot = mLastChart.getXYPlot(); XYLineAndShapeRenderer lastRenderer = new XYLineAndShapeRenderer(); lastRenderer.setSeriesPaint(0, Color.RED); lastRenderer.setSeriesStroke(0, new BasicStroke(1.0f)); lastPlot.setRenderer(lastRenderer); resetChartButton = new JButton("Reset"); resetChartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetChart(); } }); mMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu sensorMenu = new JMenu("Sensor"); JMenu deviceMenu = new JMenu("Device"); portSubMenu = new JMenu("Port"); JMenu helpMenu = new JMenu("Help"); serialStatusLabel = new JLabel("Disconnected"); statusLabel = new JLabel("Ready"); clearStatus = new LabelClear(statusLabel); clearStatus.resetTime(); connectButton = new JMenuItem("Connect"); disconnectButton = new JMenuItem("Disconnect"); startButton = new JButton("Start"); stopButton = new JButton("Stop"); scanButton = new JMenuItem("Refresh port list"); exportCSVButton = new JMenuItem("Export data to CSV"); exportCSVButton.setAccelerator(KeyStroke.getKeyStroke("control S")); exportCSVButton.setMnemonic(KeyEvent.VK_S); exportPNGButton = new JMenuItem("Export chart to PNG"); JPanel optionsPanel = new JPanel(new BorderLayout()); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.setAccelerator(KeyStroke.getKeyStroke("control X")); exitItem.setMnemonic(KeyEvent.VK_X); JMenuItem aboutItem = new JMenuItem("About"); JMenuItem helpItem = new JMenuItem("Help"); JMenuItem quickStartItem = new JMenuItem("Quick start"); lastSpinner = new JSpinner(new SpinnerNumberModel(10, 0, 1000, 1)); ActionListener mSensorListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSensor(e.getActionCommand()); } }; ButtonGroup sensorGroup = new ButtonGroup(); JRadioButtonMenuItem tmpRadioButton = new JRadioButtonMenuItem("Temperature"); sensorGroup.add(tmpRadioButton); sensorMenu.add(tmpRadioButton); tmpRadioButton.addActionListener(mSensorListener); tmpRadioButton = new JRadioButtonMenuItem("Distance"); sensorGroup.add(tmpRadioButton); sensorMenu.add(tmpRadioButton); tmpRadioButton.addActionListener(mSensorListener); tmpRadioButton = new JRadioButtonMenuItem("Voltage"); sensorGroup.add(tmpRadioButton); sensorMenu.add(tmpRadioButton); tmpRadioButton.addActionListener(mSensorListener); tmpRadioButton = new JRadioButtonMenuItem("Generic"); tmpRadioButton.setSelected(true); setSensor("Generic"); sensorGroup.add(tmpRadioButton); sensorMenu.add(tmpRadioButton); tmpRadioButton.addActionListener(mSensorListener); connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (selectedPortName == null) { setStatus("No port selected"); return; } connect(selectedPortName); } }); disconnectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { serialStatusLabel.setText("Disconnecting..."); if (serialPort == null) { serialStatusLabel.setText("Disconnected"); serialConnected = false; return; } stopCollect(); disconnect(); } }); scanButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { searchForPorts(); } }); exportCSVButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveData(); } }); exportPNGButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportPNG(); } }); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startCollect(); } }); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stopCollect(); } }); lastSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { numLastValues = (Integer) lastSpinner.getValue(); updateLastTitle(); } }); updateLastTitle(); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); helpItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new HelpFrame(); } }); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new AboutFrame(); } }); quickStartItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new StartFrame(); } }); fileMenu.add(exportCSVButton); fileMenu.add(exportPNGButton); fileMenu.addSeparator(); fileMenu.add(exitItem); deviceMenu.add(connectButton); deviceMenu.add(disconnectButton); deviceMenu.addSeparator(); deviceMenu.add(portSubMenu); deviceMenu.add(scanButton); helpMenu.add(quickStartItem); helpMenu.add(helpItem); helpMenu.add(aboutItem); mMenuBar.add(fileMenu); mMenuBar.add(sensorMenu); mMenuBar.add(deviceMenu); mMenuBar.add(helpMenu); JPanel controlsPanel = new JPanel(); controlsPanel.add(startButton); controlsPanel.add(stopButton); controlsPanel.add(resetChartButton); optionsPanel.add(controlsPanel, BorderLayout.LINE_START); JPanel lastPanel = new JPanel(new FlowLayout()); lastPanel.add(new JLabel("Shown values: ")); lastPanel.add(lastSpinner); optionsPanel.add(lastPanel); JPanel serialPanel = new JPanel(new FlowLayout()); serialPanel.add(serialStatusLabel); optionsPanel.add(serialPanel, BorderLayout.LINE_END); add(optionsPanel, BorderLayout.PAGE_START); JPanel mainPanel = new JPanel(new GridLayout(0, 2)); mainPanel.add(chartPanel); mainPanel.add(chartLastPanel); add(mainPanel); add(statusLabel, BorderLayout.PAGE_END); setJMenuBar(mMenuBar); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { dispose(); } }); setSize(800, 800); pack(); new StartFrame(); //center on screen Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - getWidth()) / 2); int y = (int) ((dimension.getHeight() - getHeight()) / 2); setLocation(x, y); setVisible(true); }
From source file:com.ficeto.esp.EspExceptionDecoder.java
private void createAndUpload() { if (!PreferencesData.get("target_platform").contentEquals("esp8266") && !PreferencesData.get("target_platform").contentEquals("esp32") && !PreferencesData.get("target_platform").contentEquals("ESP31B")) { System.err.println();/*from w w w.ja v a 2s . c o m*/ editor.statusError("Not Supported on " + PreferencesData.get("target_platform")); return; } String tc = "esp32"; if (PreferencesData.get("target_platform").contentEquals("esp8266")) { tc = "lx106"; } TargetPlatform platform = BaseNoGui.getTargetPlatform(); String gccPath = PreferencesData.get("runtime.tools.xtensa-" + tc + "-elf-gcc.path"); if (gccPath == null) { gccPath = platform.getFolder() + "/tools/xtensa-" + tc + "-elf"; } String addr2line; if (PreferencesData.get("runtime.os").contentEquals("windows")) addr2line = "xtensa-" + tc + "-elf-addr2line.exe"; else addr2line = "xtensa-" + tc + "-elf-addr2line"; tool = new File(gccPath + "/bin", addr2line); if (!tool.exists() || !tool.isFile()) { System.err.println(); editor.statusError("ERROR: " + addr2line + " not found!"); return; } elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".ino.elf"); if (!elf.exists() || !elf.isFile()) { elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".cpp.elf"); if (!elf.exists() || !elf.isFile()) { //lets give the user a chance to select the elf final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ElfFilter()); fc.setAcceptAllFileFilterUsed(false); int returnVal = fc.showDialog(editor, "Select ELF"); if (returnVal == JFileChooser.APPROVE_OPTION) { elf = fc.getSelectedFile(); } else { editor.statusError("ERROR: elf was not found!"); System.err.println("Open command cancelled by user."); return; } } } JFrame.setDefaultLookAndFeelDecorated(true); frame = new JFrame("Exception Decoder"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); inputArea = new JTextArea("Paste your stack trace here", 16, 60); inputArea.setLineWrap(true); inputArea.setWrapStyleWord(true); inputArea.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "commit"); inputArea.getActionMap().put("commit", new CommitAction()); inputArea.getDocument().addDocumentListener(this); frame.getContentPane().add(new JScrollPane(inputArea), BorderLayout.PAGE_START); outputText = ""; outputArea = new JTextPane(); outputArea.setContentType("text/html"); outputArea.setEditable(false); outputArea.setBackground(null); outputArea.setBorder(null); outputArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); outputArea.setText(outputText); JScrollPane outputScrollPane = new JScrollPane(outputArea); outputScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); outputScrollPane.setPreferredSize(new Dimension(640, 200)); outputScrollPane.setMinimumSize(new Dimension(10, 10)); frame.getContentPane().add(outputScrollPane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:com.igormaznitsa.nbmindmap.nb.swing.PlainTextEditor.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.// ww w. ja va2s.c om */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { mainToolBar = new javax.swing.JToolBar(); buttonLoad = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); buttonCopy = new javax.swing.JButton(); buttonPaste = new javax.swing.JButton(); buttonClearAll = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); labelCursorPos = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); labelWrapMode = new javax.swing.JLabel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(16, 0), new java.awt.Dimension(16, 0), new java.awt.Dimension(16, 32767)); setLayout(new java.awt.BorderLayout()); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); buttonLoad.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/disk16.png"))); // NOI18N java.util.ResourceBundle bundle = java.util.ResourceBundle .getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle"); // NOI18N buttonLoad.setText(bundle.getString("PlainTextEditor.buttonImport")); // NOI18N buttonLoad.setToolTipText(bundle.getString("PlainTextEditor.buttonLoad.toolTipText")); // NOI18N buttonLoad.setFocusable(false); buttonLoad.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonLoad.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonLoadActionPerformed(evt); } }); mainToolBar.add(buttonLoad); buttonSave.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/file_save16.png"))); // NOI18N buttonSave.setText(bundle.getString("PlaintextEditor.buttonExport")); // NOI18N buttonSave.setToolTipText(bundle.getString("PlainTextEditor.buttonSave.toolTipText")); // NOI18N buttonSave.setFocusable(false); buttonSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonSaveActionPerformed(evt); } }); mainToolBar.add(buttonSave); buttonCopy.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/page_copy16.png"))); // NOI18N buttonCopy.setText(bundle.getString("PlainTextEditor.buttonCopy.text")); // NOI18N buttonCopy.setToolTipText(bundle.getString("PlainTextEditor.buttonCopy.toolTipText")); // NOI18N buttonCopy.setFocusable(false); buttonCopy.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonCopy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonCopy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonCopyActionPerformed(evt); } }); mainToolBar.add(buttonCopy); buttonPaste.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/nbmindmap/icons/paste_plain16.png"))); // NOI18N buttonPaste.setText(bundle.getString("PlainTextEditor.buttonPaste.text")); // NOI18N buttonPaste.setToolTipText(bundle.getString("PlainTextEditor.buttonPaste.toolTipText")); // NOI18N buttonPaste.setFocusable(false); buttonPaste.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonPaste.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonPaste.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonPasteActionPerformed(evt); } }); mainToolBar.add(buttonPaste); buttonClearAll.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/cross16.png"))); // NOI18N buttonClearAll.setText(bundle.getString("PlainTextEditor.buttonClearAll.text")); // NOI18N buttonClearAll.setToolTipText(bundle.getString("PlainTextEditor.buttonClearAll.toolTipText")); // NOI18N buttonClearAll.setFocusable(false); buttonClearAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); buttonClearAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); buttonClearAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonClearAllActionPerformed(evt); } }); mainToolBar.add(buttonClearAll); add(mainToolBar, java.awt.BorderLayout.PAGE_START); jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); labelCursorPos.setText("...:..."); // NOI18N jPanel1.add(labelCursorPos); jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL); jSeparator2.setPreferredSize(new java.awt.Dimension(8, 16)); jPanel1.add(jSeparator2); labelWrapMode.setText("..."); // NOI18N labelWrapMode.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); labelWrapMode.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { labelWrapModeMouseClicked(evt); } }); jPanel1.add(labelWrapMode); jPanel1.add(filler1); add(jPanel1, java.awt.BorderLayout.PAGE_END); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override//from w w w . jav a2s . co m public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }
From source file:org.apache.pdfbox.debugger.PDFDebugger.java
/** * This method is called from within the constructor to initialize the form. *///from w w w. j a va 2 s . c o m private void initComponents() { jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane1 = new JScrollPane(); tree = new Tree(this); jScrollPane2 = new JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); tree.setCellRenderer(new PDFTreeCellRenderer()); tree.setModel(null); setTitle("Apache PDFBox Debugger"); addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowOpened(WindowEvent windowEvent) { tree.requestFocusInWindow(); super.windowOpened(windowEvent); } @Override public void windowClosing(WindowEvent evt) { exitForm(evt); } }); jScrollPane1.setBorder(new BevelBorder(BevelBorder.RAISED)); jScrollPane1.setPreferredSize(new Dimension(350, 500)); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent evt) { jTree1ValueChanged(evt); } }); jScrollPane1.setViewportView(tree); jSplitPane1.setRightComponent(jScrollPane2); jSplitPane1.setDividerSize(3); jScrollPane2.setPreferredSize(new Dimension(300, 500)); jScrollPane2.setViewportView(jTextPane1); jSplitPane1.setLeftComponent(jScrollPane1); JScrollPane documentScroller = new JScrollPane(); documentScroller.setViewportView(documentPanel); statusPane = new TreeStatusPane(tree); statusPane.getPanel().setBorder(new BevelBorder(BevelBorder.RAISED)); statusPane.getPanel().setPreferredSize(new Dimension(300, 25)); getContentPane().add(statusPane.getPanel(), BorderLayout.PAGE_START); getContentPane().add(jSplitPane1, BorderLayout.CENTER); statusBar = new ReaderBottomPanel(); getContentPane().add(statusBar, BorderLayout.SOUTH); // create menus JMenuBar menuBar = new JMenuBar(); menuBar.add(createFileMenu()); menuBar.add(createEditMenu()); menuBar.add(createViewMenu()); setJMenuBar(menuBar); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = 1000; int height = 970; setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height); // drag and drop to open files setTransferHandler(new TransferHandler() { @Override public boolean canImport(TransferSupport transferSupport) { return transferSupport.isDataFlavorSupported(DataFlavor.javaFileListFlavor); } @Override @SuppressWarnings("unchecked") public boolean importData(TransferSupport transferSupport) { try { Transferable transferable = transferSupport.getTransferable(); List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor); readPDFFile(files.get(0), ""); return true; } catch (IOException e) { new ErrorDialog(e).setVisible(true); return true; } catch (UnsupportedFlavorException e) { throw new RuntimeException(e); } } }); // Mac OS X file open/quit handler if (IS_MAC_OS) { try { Method osxOpenFiles = getClass().getDeclaredMethod("osxOpenFiles", String.class); osxOpenFiles.setAccessible(true); OSXAdapter.setFileHandler(this, osxOpenFiles); Method osxQuit = getClass().getDeclaredMethod("osxQuit"); osxQuit.setAccessible(true); OSXAdapter.setQuitHandler(this, osxQuit); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } }
From source file:net.technicpack.launcher.ui.InstallerFrame.java
private void initComponents() { setSize(DIALOG_WIDTH, DIALOG_HEIGHT); setIconImage(resources.getImage("icon.png")); setLayout(new BorderLayout()); JPanel header = new JPanel(); header.setBackground(Color.black); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8)); add(header, BorderLayout.PAGE_START); JLabel title = new JLabel(resources.getString("launcher.installer.title")); title.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 34)); title.setForeground(LauncherFrame.COLOR_WHITE_TEXT); title.setOpaque(false);/*from ww w. jav a 2s . co m*/ title.setIcon(resources.getIcon("options_cog.png")); header.add(title); header.add(Box.createHorizontalGlue()); JButton closeButton = new JButton(); closeButton.setIcon(resources.getIcon("close.png")); closeButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); closeButton.setContentAreaFilled(false); closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); closeButton.setFocusPainted(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainFrame.setVisible(true); dispose(); } }); header.add(closeButton); SimpleTabPane centerPanel = new SimpleTabPane(); centerPanel.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL); centerPanel.setForeground(LauncherFrame.COLOR_GREY_TEXT); centerPanel.setSelectedBackground(LauncherFrame.COLOR_BLUE); centerPanel.setSelectedForeground(LauncherFrame.COLOR_WHITE_TEXT); centerPanel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); centerPanel.setOpaque(true); add(centerPanel, BorderLayout.CENTER); JPanel standardInstallPanel = new JPanel(); standardInstallPanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE); setupStandardInstall(standardInstallPanel); JPanel portableModePanel = new JPanel(); portableModePanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE); setupPortableMode(portableModePanel); centerPanel.addTab(resources.getString("launcher.installer.standard").toUpperCase(), standardInstallPanel); centerPanel.addTab(resources.getString("launcher.installer.portable").toUpperCase(), portableModePanel); if (settings.isPortable()) { centerPanel.setSelectedIndex(1); } else centerPanel.setSelectedIndex(0); setLocationRelativeTo(null); }
From source file:edu.umich.robot.GuiApplication.java
/** * Entry point./*ww w .j a va2s .co m*/ * * @param args Args from command line. */ public GuiApplication(Config config) { // Heavyweight is not desirable but it is the only thing that will // render in front of the Viewer on all platforms. Blame OpenGL JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); // must have config //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame); if (config == null) System.exit(1); // Add more stuff to the config file that doesn't change between runs. Application.setupSimulatorConfig(config); setupViewerConfig(config); Configs.toLog(logger, config); controller = new Controller(config, new Gamepad()); controller.initializeGamepad(); viewer = new Viewer(config, frame); // This puts us in full 3d mode by default. The Viewer GUI doesn't // reflect this in its right click drop-down, a bug. viewer.getVisCanvas().getViewManager().setInterfaceMode(3); controller.addListener(RobotAddedEvent.class, listener); controller.addListener(RobotRemovedEvent.class, listener); controller.addListener(AfterResetEvent.class, listener); controller.addListener(ControllerActivatedEvent.class, listener); controller.addListener(ControllerDeactivatedEvent.class, listener); actionManager = new ActionManager(this); initActions(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { controller.shutdown(); System.exit(0); } }); frame.setLayout(new BorderLayout()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class)); fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ResetPreferencesAction.class)); /* fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(TextMessageAction.class)); */ fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(SaveMapAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ExitAction.class)); menuBar.add(fileMenu); JMenu cameraMenu = new JMenu("Camera"); cameraMenu.add(actionManager.getAction(DisableFollowAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class)); cameraMenu.add(new JSeparator()); cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class)); cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class)); menuBar.add(cameraMenu); JMenu objectMenu = new JMenu("Objects"); boolean added = false; for (String objectName : controller.getObjectNames()) { added = true; objectMenu.add(new AddObjectAction(this, objectName)); } if (!added) objectMenu.add(new JLabel("No objects available")); menuBar.add(objectMenu); menuBar.revalidate(); frame.setJMenuBar(menuBar); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); toolBar.add(actionManager.getAction(SoarParametersAction.class)); toolBar.add(actionManager.getAction(SoarDataAction.class)); toolBar.add(actionManager.getAction(ResetAction.class)); toolBar.add(actionManager.getAction(SoarToggleAction.class)); toolBar.add(actionManager.getAction(SoarStepAction.class)); toolBar.add(actionManager.getAction(SimSpeedAction.class)); frame.add(toolBar, BorderLayout.PAGE_START); viewerView = new ViewerView(viewer.getVisCanvas()); robotsView = new RobotsView(this, actionManager); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView); splitPane.setDividerLocation(0.75); // TODO SoarApril /* viewer.addRobotSelectionChangedListener(robotsView); viewer.getVisCanvas().setDrawGround(true); */ viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() { public String getName() { return "Place Object"; } @Override public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) { boolean ret = false; synchronized (GuiApplication.this) { if (objectToAdd != null && controller != null) { controller.addObject(objectToAdd, ray.intersectPlaneXY()); objectToAdd = null; ret = true; } else { double[] click = ray.intersectPlaneXY(); chatView.setClick(new Point2D.Double(click[0], click[1])); } } status.setMessage( String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1])); return ret; } }); consoleView = new ConsoleView(); chatView = new ChatView(this); controller.getRadio().addRadioHandler(chatView); final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView); bottomPane.setDividerLocation(200); final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane); splitPane2.setDividerLocation(0.75); frame.add(splitPane2, BorderLayout.CENTER); status = new StatusBar(); frame.add(status, BorderLayout.SOUTH); /* frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { final Preferences windowPrefs = getWindowPreferences(); final Rectangle r = frame.getBounds(); if(frame.getExtendedState() == JFrame.NORMAL) { windowPrefs.putInt("x", r.x); windowPrefs.putInt("y", r.y); windowPrefs.putInt("width", r.width); windowPrefs.putInt("height", r.height); windowPrefs.putInt("divider", splitPane.getDividerLocation()); } exit(); }}); Preferences windowPrefs = getWindowPreferences(); if (windowPrefs.get("x", null) != null) { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(windowPrefs.getInt("divider", 500)); } else { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(0.75); frame.setLocationRelativeTo(null); // center } */ frame.getRootPane().setBounds(0, 0, 1600, 1200); frame.getRootPane().registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); frame.pack(); frame.setVisible(true); for (String s : config.getStrings("splinters", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Splinter indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSplinterRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSplinter(s); else controller.createRealSplinter(s); controller.createSimLaser(s); if (prods != null) { controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } for (String s : config.getStrings("superdroids", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Superdroid indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSuperdroidRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSuperdroid(s); else { try { controller.createRealSuperdroid(s, "192.168.1.165", 3192); } catch (UnknownHostException e1) { e1.printStackTrace(); } catch (SocketException e1) { e1.printStackTrace(); } } controller.createSimLaser(s); if (prods != null) { // wait a sec try { Thread.sleep(1000); } catch (InterruptedException ex) { } controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } }
From source file:com.xmage.launcher.XMageLauncher.java
private void createToolbar() { toolBar = new JToolBar(); toolBar.setFloatable(false);// w w w.ja va2s. c o m Border emptyBorder = BorderFactory.createEmptyBorder(); JButton toolbarButton = new JButton("Settings"); toolbarButton.setBorder(emptyBorder); toolbarButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SettingsDialog settings = new SettingsDialog(); settings.setVisible(true); } }); toolBar.add(toolbarButton); toolBar.addSeparator(); toolbarButton = new JButton("About"); toolbarButton.setBorder(emptyBorder); toolbarButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AboutDialog about = new AboutDialog(); about.setVisible(true); } }); toolBar.add(toolbarButton); toolBar.addSeparator(); toolbarButton = new JButton("Forum"); toolbarButton.setBorder(emptyBorder); toolbarButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openWebpage("http://www.slightlymagic.net/forum/viewforum.php?f=70"); } }); toolBar.add(toolbarButton); toolBar.addSeparator(); toolbarButton = new JButton("Website"); toolbarButton.setBorder(emptyBorder); toolbarButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openWebpage("http://xmage.info"); } }); toolBar.add(toolbarButton); frame.add(toolBar, BorderLayout.PAGE_START); }