Добавлена форма для открытия лабораторных работ
This commit is contained in:
parent
58365241b3
commit
733e6e19e8
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
nbproject/private/
|
||||
build/
|
||||
dist/
|
@ -53,7 +53,7 @@ javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=com.nummethods.lr4.LR_4
|
||||
main.class=Main
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
|
80
src/Main.java
Normal file
80
src/Main.java
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
/**
|
||||
* Êëàññ ìåíþ, çàïóñêàþùèé ëàáîðàòîðíûå ðàáîòû.
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Main extends JFrame {
|
||||
|
||||
private static final int NUM_OF_LABS = 4;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) { }
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new Main().setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public Main() {
|
||||
setTitle("×èñëåííûå ìåòîäû");
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
initPanel(panel);
|
||||
|
||||
getContentPane().add(panel);
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
private void initPanel(JPanel panel) {
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
||||
for (int i = 1; i <= NUM_OF_LABS; i++) {
|
||||
panel.add(createButton("Ëàáîðàòîðíàÿ ðàáîòà ¹"+i, i));
|
||||
}
|
||||
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
}
|
||||
|
||||
private JButton createButton(final String text, final int num) {
|
||||
JButton button = new JButton();
|
||||
button.setText(text);
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
// Âûçîâ ìåòîäà main äèíàìè÷åñêè.
|
||||
Class<?> cls = Class.forName("com.nummethods.lr"+num+".LR_"+num);
|
||||
Method meth = cls.getMethod("main", String[].class);
|
||||
meth.invoke(null, (Object) null);
|
||||
} catch (Exception cne) {}
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.nummethods.lr3;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.geom.Point2D;
|
||||
import javax.swing.JFrame;
|
||||
import static javax.swing.JFrame.EXIT_ON_CLOSE;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
@ -17,7 +16,7 @@ public class LR_3 extends JFrame {
|
||||
public LR_3() {
|
||||
super("LR_3");
|
||||
setBounds(300, 120, 0, 0);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
Point2D[] input = new Point2D[] {
|
||||
new Point2D.Double(1, 2.0),
|
||||
|
@ -44,7 +44,7 @@ public class LR_4 extends JFrame {
|
||||
public LR_4() {
|
||||
super("LR_4");
|
||||
setBounds(300, 120, 0, 0);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
SimpsonIntegrate simpson = new SimpsonIntegrate(var10);
|
||||
System.out.println( simpson.calculate(6) );
|
||||
|
Loading…
Reference in New Issue
Block a user