Java Code Examples for javax.swing.JFrame.setBounds()

The following are Jave code examples for showing how to use setBounds() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: JavaClass   File: InterfaceSéparateur.java   View Source Code Vote up 7 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	textFieldInput.setBounds(169, 15, 245, 26);
	textFieldInput.setColumns(10);
	frame = new JFrame();
	frame.setResizable(false);
	frame.setBounds(100, 100, 450, 195);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);
	lblTapezVotreChaine.setBounds(18, 20, 150, 16);
	
	frame.getContentPane().add(lblTapezVotreChaine);
	
	frame.getContentPane().add(textFieldInput);
	btnSeparation.addActionListener(new BtnSeparationActionListener());
	btnSeparation.setBounds(116, 68, 210, 29);
	
	frame.getContentPane().add(btnSeparation);
	lblOutput.setBounds(18, 131, 396, 16);
	
	frame.getContentPane().add(lblOutput);
}
 
Example 2
Project: burpextender-proxyhistory-webui   File: MainWindow.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setTitle("ProxyHistoryWebUI standalone mode");
    frame.setBounds(100, 100, 600, 450);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout(0, 0));
    frame.getContentPane().add(new DemoPanel(appContext), BorderLayout.CENTER);
}
 
Example 3
Project: bbm487s2017g1   File: CustomerMyBooksAndReservationsWindow.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame("Library Book Loan System - My Books and Reservations");
    frame.setResizable(false);
    frame.setBounds(100, 100, 700, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    
    JLabel label = new JLabel("Library Book Loan System");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
    label.setBounds(10, 11, 674, 30);
    frame.getContentPane().add(label);
    
    JLabel lblBookReservations = new JLabel("My Books and Reservations");
    lblBookReservations.setHorizontalAlignment(SwingConstants.CENTER);
    lblBookReservations.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
    lblBookReservations.setBounds(10, 42, 674, 22);
    frame.getContentPane().add(lblBookReservations);
        
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBackground(SystemColor.text);
    tabbedPane.setBounds(10, 75, 674, 228);
    frame.getContentPane().add(tabbedPane);
    
    initializeCurrentBooks(tabbedPane);
    initializeWaitlist(tabbedPane);
    initializeHistory(tabbedPane);
    
    frame.setVisible(true);
}
 
Example 4
Project: poe-ladder-tracker-java   File: GUIError.java   View Source Code Vote up 5 votes
/**
 * Initializes the GUI.
 */
private void initialize(){
	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	
	// error window
	windowError = new JFrame();	
	windowError.setBounds(100, 100, 300, 145);
	windowError.setLocation(dim.width/2-windowError.getSize().width/2, dim.height/2-windowError.getSize().height/2);
	windowError.setResizable(false);
	windowError.setTitle("Ladder Tracker v" + version);
	windowError.setIconImage(new ImageIcon(getClass().getResource("icon.png")).getImage());
	windowError.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	windowError.getContentPane().setLayout(null);
	
	// button retry
	buttonRetry = new JButton("Retry");
	buttonRetry.setBounds(10, 80, 274, 23);
	buttonRetry.addActionListener(buttonRetryListener);
	windowError.getContentPane().add(buttonRetry);
	
	// error text 
	JTextPane textError = new JTextPane();
	textError.setText(errorMessage);
	textError.setEditable(false);
	textError.setBackground(SystemColor.menu);
	textError.setBounds(10, 21, 274, 39);
	windowError.getContentPane().add(textError);
}
 
Example 5
Project: JavaClass   File: Interface_répétition.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	txtRepetitions.setBounds(192, 55, 61, 26);
	txtRepetitions.setColumns(10);
	txtTexte.setBounds(192, 17, 250, 26);
	txtTexte.setColumns(10);
	frame = new JFrame();
	frame.setResizable(false);
	frame.setBounds(100, 100, 485, 452);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);
	
	frame.getContentPane().add(txtTexte);
	
	frame.getContentPane().add(txtRepetitions);
	lblTexte.setBounds(145, 22, 61, 16);
	
	frame.getContentPane().add(lblTexte);
	lblNombreDeRptitions.setBounds(39, 60, 156, 16);
	
	frame.getContentPane().add(lblNombreDeRptitions);
	btnRpter.addActionListener(new BtnRpterActionListener());
	btnRpter.setBounds(260, 55, 177, 29);
	
	frame.getContentPane().add(btnRpter);
	txtrZoneDeTexte.setBounds(37, 103, 406, 291);
	
	frame.getContentPane().add(txtrZoneDeTexte);
}
 
Example 6
Project: openjdk-jdk10   File: bug4213634.java   View Source Code Vote up 5 votes
public  void createAndShowGUI() {
    frame = new JFrame("TEST");
    JMenuBar mb = new JMenuBar();
    menu = mb.add(createMenu("1 - First Menu", true));
    mb.add(createMenu("2 - Second Menu", false));
    frame.setJMenuBar(mb);
    JTextArea ta = new JTextArea("This test dedicated to Nancy and Kathleen, testers and bowlers extraordinaire\n\n\nNo exception means pass.");
    frame.getContentPane().add("Center", ta);
    JButton button = new JButton("Test");
    frame.getContentPane().add("South", button);
    frame.setBounds(100, 100, 400, 400);
    frame.setVisible(true);
    button.requestFocusInWindow();
}
 
Example 7
Project: sbc-qsystem   File: ABoardFX.java   View Source Code Vote up 5 votes
private void initAndShowGUI() {
    JFrame w = new JFrame();
    w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    if (!QConfig.cfg().isDebug()) {
        w.setUndecorated(true);
    }
    // Create JavaFX panel.
    /* todo
    javafxPanel = new JFXPanel();
    javafxPanel.setPreferredSize(new Dimension(win_w, win_h));
    w.getContentPane().add(javafxPanel, BorderLayout.CENTER);
     * 
     */

    initFXscene();

    // Show frame.
    w.pack();
    w.setLocationRelativeTo(null);
    w.setVisible(true);
    if (QConfig.cfg().isDebug()) {
        w.setBounds(100, 100, 1024, 768);
    } else {
        w.setBounds(win_x, win_y, win_w, win_h);
        w.setAlwaysOnTop(true);
    }
}
 
Example 8
Project: JavaClass   File: InterfaceConvertisseur.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	txtResultat.setBounds(242, 175, 181, 26);
	txtResultat.setColumns(10);
	txtEntrePoid.setBounds(242, 27, 181, 26);
	txtEntrePoid.setColumns(10);
	frame = new JFrame();
	frame.setBounds(100, 100, 450, 300);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);
	lblEntrezUnPoids.setBounds(6, 32, 224, 16);
	
	frame.getContentPane().add(lblEntrezUnPoids);
	
	frame.getContentPane().add(txtEntrePoid);
	lblChoisirLeType.setBounds(6, 73, 211, 16);
	
	frame.getContentPane().add(lblChoisirLeType);
	Choix.setModel(new DefaultComboBoxModel(new String[] {"Faites un choix...", "Kilogramme à Livres", "Kilogramme à Onces"}));
	Choix.setSelectedIndex(0);
	Choix.setBounds(242, 69, 181, 27);
	
	frame.getContentPane().add(Choix);
	btnConvertir.addActionListener(new BtnConvertirActionListener());
	btnConvertir.setBounds(47, 122, 117, 29);
	
	frame.getContentPane().add(btnConvertir);
	lblPoidsConvertis.setBounds(6, 180, 123, 16);
	
	frame.getContentPane().add(lblPoidsConvertis);
	
	frame.getContentPane().add(txtResultat);
}
 
Example 9
Project: sstore-soft   File: MarkovViewer.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    JFrame frame = (JFrame) cb.getParent().getParent().getParent().getParent();
    Pair<Procedure, Integer> proc = (Pair<Procedure, Integer>) cb.getSelectedItem();
    MarkovGraph g = partitionGraphs.get(proc);
    assert (g != null);
    GraphVisualizationPanel<MarkovVertex, MarkovEdge> graph_panel = MarkovViewer.getPanel(g);
    graph_panel.add(cb);
    frame.setContentPane(graph_panel);
    frame.setBounds(50, 50, 500, 500);
    frame.setVisible(true);

}
 
Example 10
Project: sstore-soft   File: MarkovViewer.java   View Source Code Vote up 5 votes
public static void launch(
        Map<Pair<Procedure, Integer>, MarkovGraph> partitionGraphs,
        Pair<Procedure,Integer> selection) {
    JFrame frame = new JFrame("Simple Graph View");
    JComboBox partcombo = MarkovViewer.makePartitionComboBox(partitionGraphs);
    MarkovGraph test_graph = partitionGraphs.get(selection);
    frame.setContentPane(MarkovViewer.getPanel(test_graph));
    frame.add(partcombo);
    partcombo.setSelectedItem(selection);
    frame.setBounds(50, 50, 2000, 500);
    frame.setVisible(true);
    
}
 
Example 11
Project: openjdk-jdk10   File: DrawBitmaskToSurfaceTest.java   View Source Code Vote up 5 votes
public static void main(final String[] args) throws Exception {
    final JFrame frame = new DrawBitmaskToSurfaceTest();
    frame.setBounds(10, 350, 200, 200);
    frame.setVisible(true);

    Thread.sleep(2000);

    System.err.println("Change frame bounds...");
    latch = new CountDownLatch(1);
    frame.setBounds(10, 350, 90, 90);
    frame.repaint();

    try {
        if (latch.getCount() > 0) {
            latch.await();
        }
    } catch (InterruptedException e) {
    }

    frame.dispose();

    if (theError != null) {
        throw new RuntimeException("Test failed.", theError);
    }

    System.err.println("Test passed");
}
 
Example 12
Project: javase   File: JProgressDemo.java   View Source Code Vote up 5 votes
public JProgressDemo() {
	frame = new JFrame("install");
	frame.setLayout(new BorderLayout());
	label = new JLabel("progress",SwingConstants.CENTER);
	progressbar = new JProgressBar();
	progressbar.setOrientation(JProgressBar.HORIZONTAL);
	progressbar.setMinimum(0);
	progressbar.setMaximum(100);
	progressbar.setValue(0);
	//progressbar.setStringPainted(true);
	progressbar.addChangeListener(this);
	progressbar.setPreferredSize(new Dimension(300, 10));
	progressbar.setBorderPainted(false);
	progressbar.setBackground(Color.pink);
	JPanel progressPane = new JPanel();
	progressPane.add(progressbar);
	progressPane.setPreferredSize(new Dimension(300, 10));
	JPanel panel = new JPanel();
	b = new JButton("install");
	stop = new JButton("pause");
	b.setForeground(Color.blue);
	b.addActionListener(this);
	stop.addActionListener(this);
	panel.add(b);
	panel.add(stop);
	// timer=new Timer(100,this);
	timer = new Timer(1000/10, this);
	frame.add(panel, BorderLayout.NORTH);
	frame.add(progressPane, BorderLayout.CENTER);
	frame.add(label, BorderLayout.SOUTH);
	// frame.pack();
	frame.setBounds(100, 100, 400, 130);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
}
 
Example 13
Project: s-store   File: MarkovViewer.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    JFrame frame = (JFrame) cb.getParent().getParent().getParent().getParent();
    Pair<Procedure, Integer> proc = (Pair<Procedure, Integer>) cb.getSelectedItem();
    MarkovGraph g = partitionGraphs.get(proc);
    assert (g != null);
    GraphVisualizationPanel<MarkovVertex, MarkovEdge> graph_panel = MarkovViewer.getPanel(g);
    graph_panel.add(cb);
    frame.setContentPane(graph_panel);
    frame.setBounds(50, 50, 500, 500);
    frame.setVisible(true);

}
 
Example 14
Project: JavaClass   File: Interface.java   View Source Code Vote up 4 votes
private void initialize() {
	textLettre.setBounds(143, 389, 38, 26);
	textLettre.setColumns(10);
	frame = new JFrame();
	frame.setResizable(false);
	frame.setBounds(100, 100, 450, 510);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);
	lblLeJeuDu.setFont(new Font("Lucida Grande", Font.PLAIN, 21));
	lblLeJeuDu.setBounds(143, 22, 165, 26);
	
	frame.getContentPane().add(lblLeJeuDu);
	lblLettresDjEssayes.setBounds(31, 447, 141, 16);
	
	frame.getContentPane().add(lblLettresDjEssayes);
	textLettresEssayes.setEditable(false);
	textLettresEssayes.setBounds(184, 446, 240, 19);
	
	frame.getContentPane().add(textLettresEssayes);
	lblLettreEssayer.setBounds(31, 394, 106, 16);
	
	frame.getContentPane().add(lblLettreEssayer);
	
	frame.getContentPane().add(textLettre);
	btnEssayerCeteLettre.addActionListener(new BtnEssayerCeteLettreActionListener());
	btnEssayerCeteLettre.setBounds(220, 383, 165, 41);
	
	frame.getContentPane().add(btnEssayerCeteLettre);
	lblAprsErreurs.setBounds(31, 350, 381, 16);
	
	frame.getContentPane().add(lblAprsErreurs);
	panel.setBackground(Color.WHITE);
	panel.setBounds(31, 69, 381, 231);
	
	frame.getContentPane().add(panel);
	panel.setLayout(null);
	lblNewLabel.setBounds(87, 6, 215, 219);
	
	panel.add(lblNewLabel);
	lblMotATrouve.setFont(new Font("Lucida Grande", Font.BOLD, 22));
	lblMotATrouve.setBounds(31, 312, 381, 26);
	
	frame.getContentPane().add(lblMotATrouve);
}
 
Example 15
Project: code-sentinel   File: ReplAgGUI.java   View Source Code Vote up 4 votes
void initGui() {
    Font font = new Font("Courier", Font.PLAIN, 14);
    command = new JTextField(40);
    command.setFont(font);
    command.setToolTipText("Type a Jason operation here.");
    command.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            execCmd(command.getText().trim());
        }
    });

    //mindPanel = new JTextPane();
    //mindPanel.setEditable(false);
    //mindPanel.setContentType("text/html");
    
    output = new JTextArea(5,50);
    output.setFont(font);
    output.setEditable(false);
    output.setText("Example of operations you can type:\n   +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n   .send(bob,tell,hello);\n");
    output.append("   ?bel(A); .findall(X,bel(X),L); \n");
    output.append("   .mi // to open mind inspector\n");
    output.append("   .verbose(2) // to show debug messages\n");
    output.append("   .clear // clean console\n");
    output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console.");
    
    output.append("\n");
    

    frame = new JFrame(".::  REPL Interface for "+getTS().getUserAgArch().getAgName()+"  ::.");
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(BorderLayout.NORTH,command);    
    //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel));
    frame.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output));

    frame.pack();
    int h = 200;
    int w = (int)(h*2*1.618);
    frame.setBounds((int)(h*0.618), 20, w, h);
    frame.setLocation(lastPos, 200+lastPos);
    lastPos += 50;
    frame.setVisible(true);
}
 
Example 16
Project: bbm487s2017g1   File: CustomerNotifications.java   View Source Code Vote up 4 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame("Library Book Loan System - Notifications");
    frame.setResizable(false);
    frame.setBounds(100, 100, 438, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(null);
    
    JLabel lblNotifications = new JLabel("Notifications");
    lblNotifications.setHorizontalAlignment(SwingConstants.CENTER);
    lblNotifications.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
    lblNotifications.setBounds(10, 40, 414, 22);
    panel.add(lblNotifications);
    
    JLabel label_1 = new JLabel("Library Book Loan System");
    label_1.setHorizontalAlignment(SwingConstants.CENTER);
    label_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
    label_1.setBounds(10, 11, 414, 25);
    panel.add(label_1);
    
    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Available Books", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
    panel_1.setBounds(10, 73, 414, 177);
    panel.add(panel_1);
    panel_1.setLayout(null);
    
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 22, 394, 144);
    panel_1.add(scrollPane);
    
    Object columnNames[] = { "No", "Message" };
    Object rowData[][] = getNotifications();
    
    table = new JTable(rowData, columnNames)
    {
        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    
    table.setBackground(Color.white);
    table.setOpaque(true);
    
    
    table.getTableHeader().setReorderingAllowed(false);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);

    List<RowSorter.SortKey> sortKeys = new ArrayList<>(25);
    sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    sorter.setSortKeys(sortKeys);
    
    table.getColumnModel().getColumn(0).setMaxWidth(40);
    scrollPane.setViewportView(table);
    
}
 
Example 17
Project: QN-ACTR-Release   File: ExactWizard.java   View Source Code Vote up 4 votes
private void createSolutionWindow() {
	JTabbedPane jtp = new JTabbedPane();
	JFrame solutionWindow = new JFrame("jMVA Solutions");
	solutionWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	solutionWindow.getContentPane().add(jtp);
	solutionWindow.setIconImage(this.getIconImage());
	IterationSelector selector = null;
	if (data.isWhatIf()) {
		// Graphic panel (Bertoli Marco)
		jtp.add(new GraphPanel(data));
		selector = new IterationSelector(data);
	}
	ThroughputPanel throughput = new ThroughputPanel(this);
	QueueLenPanel queuelength = new QueueLenPanel(this);
	ResTimePanel restimes = new ResTimePanel(this);
	UtilizationPanel utilizations = new UtilizationPanel(this);
	//Added by ASHANKA START
	//Introducing the new System Power Panel as a Tabbed Pane
	SysPowerPanel systemPower = new SysPowerPanel(this);
	//Added by ASHANKA STOP
	if (selector != null) {
		selector.addSolutionPanel(throughput);
		selector.addSolutionPanel(queuelength);
		selector.addSolutionPanel(restimes);
		selector.addSolutionPanel(utilizations);
		//Added by ASHANKA START
		// for System Power
		selector.addSolutionPanel(systemPower);
		//Added by ASHANKA STOP
		jtp.add(selector);
	} else {
		jtp.add(throughput);
		jtp.add(queuelength);
		jtp.add(restimes);
		jtp.add(utilizations);
		//Added by ASHANKA START
		//for System Power
		jtp.add(systemPower);
		//Added by ASHANKA STOP
	}
	//NEW Dall'Orso 5-5-2005
	SynopsisPanel synPane;
	if (tempFile != null) {
		synPane = new SynopsisPanel(this, tempFile);
	} else {
		synPane = new SynopsisPanel(this);
	}
	jtp.add(synPane);
	//END
	//BoundingBox of main window
	Rectangle rect = this.getBounds();
	solutionWindow.setBounds(rect.x + 20, rect.y + 20, rect.width, rect.height);
	solutionWindow.show();
}
 
Example 18
Project: GroupControlDroidClient   File: Entrance.java   View Source Code Vote up 4 votes
/**
 * 点击测试连接按钮
 * 
 * @param evt
 */
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
	// TODO add your handling code here:
	JFrame frame = new JFrame("设备连接测试");
	LayoutManager layout = new GridLayout(2, 2);
	frame.setLayout(layout);
	frame.setBounds(20, 20, 300, 100);
	frame.setVisible(true);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);

	TextField textFiled1 = new TextField("可用设备数");
	textFiled1.setEditable(false);
	connectedCountDeviceTextField.setEditable(false);
	frame.getContentPane().add(textFiled1);
	frame.getContentPane().add(connectedCountDeviceTextField);

	TextField textFiled2 = new TextField("总设备数");
	textFiled2.setEditable(false);
	totalCountDeviceTextField.setEnabled(false);
	frame.getContentPane().add(textFiled2);
	frame.getContentPane().add(totalCountDeviceTextField);

	// 设备数监听
	Thread countDeviceThread = new Thread(new Runnable() {
		@Override
		public void run() {
			int connected = 0, total = 0;// 已在线设备数,总设备数
			AndroidDebugBridge bridge = AdbUtil.getADBInstance();
			if (bridge != null) {
				try {
					while (!Thread.currentThread().isInterrupted()) {
						IDevice[] devices = bridge.getDevices();
						if (devices != null) {
							total = devices.length;
							connected = 0;
							for (IDevice device : devices) {
								if (device != null && device.isOnline()) {
									connected++;
								}
							}
						}
						connectedCountDeviceTextField.setText(String.format("%d", connected));
						totalCountDeviceTextField.setText(String.format("%d", total));

						Thread.sleep(500);

					}
				} catch (InterruptedException e) {
					logger.info("设备数目监听线程退出");
				}
			}
		}
	}, "CountDeviceThread");
	countDeviceThread.start();

	/* 窗口退出,退出线程 */
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent we) {
			countDeviceThread.interrupt();
		}
	});
}
 
Example 19
Project: Open_Source_ECOA_Toolset_AS5   File: ECOA_Monitor.java   View Source Code Vote up 4 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setBounds(100, 100, 800, 640);
	frame.setTitle("ECOA Monitor Panel");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	// Set the layout of the top-level frame to a 1x3 grid.
	frame.setLayout(new BorderLayout());

	lcpPanel = new LCPPanel(this);
	pdPanel = new PDPanel(this);
	serviceAvailPanel = new ServiceAvailPanel(this);

	// Create the menu bar.
	menuBar = new JMenuBar();
	// Build the first menu.
	fileMenu = new JMenu("File");
	menuBar.add(fileMenu);

	// Add menu items for reset and exit.
	resetMenuItem = new JMenuItem("Reset");
	exitMenuItem = new JMenuItem("Exit");

	// Add event listeners for each of the menu items.
	resetMenuItem.addActionListener(this);
	exitMenuItem.addActionListener(this);

	fileMenu.add(resetMenuItem);
	fileMenu.add(exitMenuItem);

	JPanel containingPanel = new JPanel();
	containingPanel.setLayout(new GridLayout(1, 2));
	containingPanel.add(pdPanel);
	containingPanel.add(serviceAvailPanel);

	// Add the panels to the frame container.
	frame.add(lcpPanel, BorderLayout.PAGE_START);
	frame.add(containingPanel, BorderLayout.CENTER);

	frame.setJMenuBar(menuBar);
}
 
Example 20
Project: MD5   File: MD5.java   View Source Code Vote up 4 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setTitle("MD5");
	frame.setResizable(false);
	frame.setBounds(100, 100, 450, 580);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);

	JLabel label = new JLabel("Please select your files:");
	label.setBounds(105, 32, 227, 16);
	frame.getContentPane().add(label);

	final JLabel error = new JLabel("");
	error.setForeground(new Color(255,0,0));
	error.setBounds(120, 52, 250, 16);
	frame.getContentPane().add(error);

	final JFileChooser filesChooser = new JFileChooser();
	filesChooser.setControlButtonsAreShown(false);
	filesChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	filesChooser.setMultiSelectionEnabled(true);
	filesChooser.setBounds(41, 62, 362, 400);
	frame.getContentPane().add(filesChooser);

	JButton btnStartMD5 = new JButton("Start MD5");
	btnStartMD5.setBounds(132, 490, 177, 29);
	frame.getContentPane().add(btnStartMD5);

	//listener to run the application launch when the button is pressed
	btnStartMD5.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e)  {
			// It recovers the files selected
			File[] files;
			try{
				files = filesChooser.getSelectedFiles();
			}catch(NullPointerException exc){
				error.setText("No selected file");
				throw new Md5Exception("No selected file : " + exc.getMessage());
			}
			for(int i = 0; i < files.length; i++){
				String fileName = files[i].getAbsolutePath()  ;
				//Creation du md5 en java
				String output;
				try{
					output = CreateMD5.getMD5(fileName);
				}catch(Md5Exception e1){
					error.setText("Error creating the MD5");
					throw new Md5Exception("Error creating the MD5 : " + e1.getMessage());
				}
				/*Writing the md5 file
				  remove the extension of the original file if there is*/
				String path;
				if(files[i].getAbsolutePath().lastIndexOf(".") == -1){
					path = files[i].getAbsolutePath() + ".md5";
				}else {
					String nomFichierSansExt = files[i].getAbsolutePath().substring(0, files[i].getAbsolutePath().lastIndexOf(".")) ;
					path = nomFichierSansExt + ".md5";
				}	
				File file = new File(path); 
				try {
					if (!file.exists()){
						// File Creation
						file.createNewFile();
					}
					FileWriter writer = new FileWriter(file, true);
					writer.write(output);
					writer.close();
				} catch (Exception ex) {
					error.setText("Impossible to create MD5");
					throw new Md5Exception("Impossible to create MD5 : " + ex.getMessage());
				}
			} 
		}
	});
}