- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要帮助导入此类信息(CSV 文件)。
Stanmore College,51.612767,-0.311072
按以下顺序排列:地点、经度、纬度。
如何使用上述数据从 CSV 文件导入数据?
我创建了一个 JFileChooser
和 ActionListener
供用户加载 CSV 文件...
//---- btnLoadCSV ----
btnLoadCSV.setText("Load from CSV");
btnLoadCSV.setHorizontalAlignment(SwingConstants.LEFT);
btnLoadCSV.setMnemonic('L');
btnLoadCSV.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jfc = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"CSV files (*csv)", "csv");
jfc.setFileFilter(filter);
int ret = jfc.showOpenDialog(GoogleApp.this);
if(ret == JFileChooser.APPROVE_OPTION)
{
File f = jfc.getSelectedFile();
String s = f.getAbsolutePath();
}
}
});
panel1.add(btnLoadCSV, new TableLayoutConstraints(5, 1, 5, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
当您导入时,它应该从文件中获取数据并将数据放入这些JLabels
(但我不知道从这里做什么......)
Place: label7
Longitude: ttfLon
Latitude: ttfLat
非常感谢!
完整代码/类(如果您需要):
import Task.*;
import Task.Manager.*;
import Task.ProgressMonitor.*;
import Task.Support.CoreSupport.*;
import Task.Support.GUISupport.*;
import com.jgoodies.forms.factories.*;
import info.clearthought.layout.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.beans.*;
import java.text.*;
import java.util.concurrent.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JFileChooser;
import java.awt.event.ActionListener;
import java.io.File;
import java.awt.event.ActionEvent;
public class GoogleApp extends JFrame {
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// data members
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/** reference to task */
private SimpleTask _task;
/** this might be null. holds the image to display in a popup */
private BufferedImage _img;
/** this might be null. holds the text in case image doesn't display */
private String _respStr;
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// main method...
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
public static void main(String[] args) {
Utils.createInEDT(GoogleApp.class);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// constructor
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
private void doInit() {
GUIUtils.setAppIcon(this, "burn.png");
GUIUtils.centerOnScreen(this);
setVisible(true);
int W = 28, H = W;
boolean blur = false;
float alpha = .7f;
try {
btnGetMap.setIcon(ImageUtils.loadScaledBufferedIcon("ok1.png", W, H, blur, alpha));
btnQuit.setIcon(ImageUtils.loadScaledBufferedIcon("charging.png", W, H, blur, alpha));
}
catch (Exception e) {
System.out.println(e);
}
_setupTask();
}
/** create a test task and wire it up with a task handler that dumps output to the textarea */
@SuppressWarnings("unchecked")
private void _setupTask() {
TaskExecutorIF<ByteBuffer> functor = new TaskExecutorAdapter<ByteBuffer>() {
public ByteBuffer doInBackground(Future<ByteBuffer> swingWorker,
SwingUIHookAdapter hook) throws Exception
{
_initHook(hook);
// get the uri for the static map
String uri = MapLookup.getMap(Double.parseDouble(ttfLat.getText()),
Double.parseDouble(ttfLon.getText()),
Integer.parseInt(ttfSizeW.getText()),
Integer.parseInt(ttfSizeH.getText()),
Integer.parseInt(ttfZoom.getText())
);
sout("Google Maps URI=" + uri);
// get the map from Google
GetMethod get = new GetMethod(uri);
new HttpClient().executeMethod(get);
ByteBuffer data = HttpUtils.getMonitoredResponse(hook, get);
try {
_img = ImageUtils.toCompatibleImage(ImageIO.read(data.getInputStream()));
sout("converted downloaded data to image...");
}
catch (Exception e) {
_img = null;
sout("The URI is not an image. Data is downloaded, can't display it as an image.");
_respStr = new String(data.getBytes());
}
return data;
}
@Override public String getName() {
return _task.getName();
}
};
_task = new SimpleTask(
new TaskManager(),
functor,
"HTTP GET Task",
"Download an image from a URL",
AutoShutdownSignals.Daemon
);
_task.addStatusListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
sout(":: task status change - " + ProgressMonitorUtils.parseStatusMessageFrom(evt));
lblProgressStatus.setText(ProgressMonitorUtils.parseStatusMessageFrom(evt));
}
});
_task.setTaskHandler(new
SimpleTaskHandler<ByteBuffer>() {
@Override public void beforeStart(AbstractTask task) {
sout(":: taskHandler - beforeStart");
}
@Override public void started(AbstractTask task) {
sout(":: taskHandler - started ");
}
/** {@link SampleApp#_initHook} adds the task status listener, which is removed here */
@Override public void stopped(long time, AbstractTask task) {
sout(":: taskHandler [" + task.getName() + "]- stopped");
sout(":: time = " + time / 1000f + "sec");
task.getUIHook().clearAllStatusListeners();
}
@Override public void interrupted(Throwable e, AbstractTask task) {
sout(":: taskHandler [" + task.getName() + "]- interrupted - " + e.toString());
}
@Override public void ok(ByteBuffer value, long time, AbstractTask task) {
sout(":: taskHandler [" + task.getName() + "]- ok - size=" + (value == null
? "null"
: value.toString()));
if (_img != null) {
_displayImgInFrame();
}
else _displayRespStrInFrame();
}
@Override public void error(Throwable e, long time, AbstractTask task) {
sout(":: taskHandler [" + task.getName() + "]- error - " + e.toString());
}
@Override public void cancelled(long time, AbstractTask task) {
sout(" :: taskHandler [" + task.getName() + "]- cancelled");
}
}
);
}
private SwingUIHookAdapter _initHook(SwingUIHookAdapter hook) {
hook.enableRecieveStatusNotification(checkboxRecvStatus.isSelected());
hook.enableSendStatusNotification(checkboxSendStatus.isSelected());
hook.setProgressMessage(ttfProgressMsg.getText());
PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
SwingUIHookAdapter.PropertyList type = ProgressMonitorUtils.parseTypeFrom(evt);
int progress = ProgressMonitorUtils.parsePercentFrom(evt);
String msg = ProgressMonitorUtils.parseMessageFrom(evt);
progressBar.setValue(progress);
progressBar.setString(type.toString());
sout(msg);
}
};
hook.addRecieveStatusListener(listener);
hook.addSendStatusListener(listener);
hook.addUnderlyingIOStreamInterruptedOrClosed(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
sout(evt.getPropertyName() + " fired!!!");
}
});
return hook;
}
private void _displayImgInFrame() {
final JFrame frame = new JFrame("Google Static Map");
GUIUtils.setAppIcon(frame, "71.png");
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JLabel imgLbl = new JLabel(new ImageIcon(_img));
imgLbl.setToolTipText(MessageFormat.format("<html>Image downloaded from URI<br>size: w={0}, h={1}</html>",
_img.getWidth(), _img.getHeight()));
imgLbl.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) { frame.dispose();}
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
});
frame.setContentPane(imgLbl);
frame.pack();
GUIUtils.centerOnScreen(frame);
frame.setVisible(true);
}
private void _displayRespStrInFrame() {
final JFrame frame = new JFrame("Google Static Map - Error");
GUIUtils.setAppIcon(frame, "69.png");
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JTextArea response = new JTextArea(_respStr, 25, 80);
response.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) { frame.dispose();}
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
});
frame.setContentPane(new JScrollPane(response));
frame.pack();
GUIUtils.centerOnScreen(frame);
frame.setVisible(true);
}
/** simply dump status info to the textarea */
private void sout(final String s) {
Runnable soutRunner = new Runnable() {
public void run() {
if (ttaStatus.getText().equals("")) {
ttaStatus.setText(s);
}
else {
ttaStatus.setText(ttaStatus.getText() + "\n" + s);
}
}
};
if (ThreadUtils.isInEDT()) {
soutRunner.run();
}
else {
SwingUtilities.invokeLater(soutRunner);
}
}
private void startTaskAction() {
try {
_task.execute();
}
catch (TaskException e) {
sout(e.getMessage());
}
}
public GoogleApp() {
initComponents();
doInit();
}
private void quitProgram() {
_task.shutdown();
System.exit(0);
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner non-commercial license
dialogPane = new JPanel();
contentPanel = new JPanel();
panel1 = new JPanel();
label2 = new JLabel();
ttfSizeW = new JTextField();
label4 = new JLabel();
ttfLat = new JTextField();
btnGetMap = new JButton();
btnLoadCSV = new JButton();
label3 = new JLabel();
ttfSizeH = new JTextField();
label5 = new JLabel();
ttfLon = new JTextField();
btnQuit = new JButton();
label1 = new JLabel();
label6 = new JLabel();
label7 = new JLabel();
ttfZoom = new JTextField();
scrollPane1 = new JScrollPane();
ttaStatus = new JTextArea();
panel2 = new JPanel();
panel3 = new JPanel();
checkboxRecvStatus = new JCheckBox();
checkboxSendStatus = new JCheckBox();
ttfProgressMsg = new JTextField();
progressBar = new JProgressBar();
lblProgressStatus = new JLabel();
//======== this ========
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("GMaps App Loader");
setIconImage(null);
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//======== dialogPane ========
{
dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
dialogPane.setOpaque(false);
dialogPane.setLayout(new BorderLayout());
//======== contentPanel ========
{
contentPanel.setOpaque(false);
contentPanel.setLayout(new TableLayout(new double[][] {
{TableLayout.FILL},
{TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED}}));
((TableLayout)contentPanel.getLayout()).setHGap(5);
((TableLayout)contentPanel.getLayout()).setVGap(5);
//======== panel1 ========
{
panel1.setOpaque(false);
panel1.setBorder(new CompoundBorder(
new TitledBorder("Configure the inputs or load from CSV..."),
Borders.DLU2_BORDER));
panel1.setLayout(new TableLayout(new double[][] {
{0.17, 0.17, 0.17, 0.17, 0.05, TableLayout.FILL},
{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}}));
((TableLayout)panel1.getLayout()).setHGap(5);
((TableLayout)panel1.getLayout()).setVGap(5);
//---- label2 ----
label2.setText("Size Width");
label2.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label2, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfSizeW ----
ttfSizeW.setText("512");
panel1.add(ttfSizeW, new TableLayoutConstraints(1, 0, 1, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- label4 ----
label4.setText("Latitude");
label4.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label4, new TableLayoutConstraints(2, 0, 2, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfLat ----
ttfLat.setText("52.95907");
panel1.add(ttfLat, new TableLayoutConstraints(3, 0, 3, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- btnGetMap ----
btnGetMap.setText("Get Map");
btnGetMap.setHorizontalAlignment(SwingConstants.LEFT);
btnGetMap.setMnemonic('G');
btnGetMap.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
startTaskAction();
}
});
panel1.add(btnGetMap, new TableLayoutConstraints(5, 0, 5, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- btnLoadCSV ----
btnLoadCSV.setText("Load from CSV");
btnLoadCSV.setHorizontalAlignment(SwingConstants.LEFT);
btnLoadCSV.setMnemonic('L');
btnLoadCSV.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jfc = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"CSV files (*csv)", "csv");
jfc.setFileFilter(filter);
int ret = jfc.showOpenDialog(GoogleApp.this);
if(ret == JFileChooser.APPROVE_OPTION)
{
File f = jfc.getSelectedFile();
String s = f.getAbsolutePath();
}
}
});
panel1.add(btnLoadCSV, new TableLayoutConstraints(5, 1, 5, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- label3 ----
label3.setText("Size Height");
label3.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label3, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfSizeH ----
ttfSizeH.setText("512");
panel1.add(ttfSizeH, new TableLayoutConstraints(1, 1, 1, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- label5 ----
label5.setText("Longitude");
label5.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label5, new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfLon ----
ttfLon.setText("-1.182468");
panel1.add(ttfLon, new TableLayoutConstraints(3, 1, 3, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- btnQuit ----
btnQuit.setText("Quit");
btnQuit.setMnemonic('Q');
btnQuit.setHorizontalAlignment(SwingConstants.LEFT);
btnQuit.setHorizontalTextPosition(SwingConstants.RIGHT);
btnQuit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
quitProgram();
}
});
panel1.add(btnQuit, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- label1 ----
label1.setText("Zoom");
label1.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label1, new TableLayoutConstraints(0, 2, 0, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfZoom ----
ttfZoom.setText("17");
ttfZoom.setToolTipText("Enter Zoom Number. Max 19.");
panel1.add(ttfZoom, new TableLayoutConstraints(1, 2, 1, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- Spare ----
label6.setText("Place");
label6.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label6, new TableLayoutConstraints(2, 2, 2, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- Sparetextbox ----
label7.setText("-- CSV Only --");
panel1.add(label7, new TableLayoutConstraints(3, 2, 3, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
}
contentPanel.add(panel1, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//======== scrollPane1 ========
{
scrollPane1.setBorder(new TitledBorder("System.out - displays all status and progress messages, etc."));
scrollPane1.setOpaque(false);
//---- ttaStatus ----
ttaStatus.setBorder(Borders.createEmptyBorder("1dlu, 1dlu, 1dlu, 1dlu"));
ttaStatus.setToolTipText("<html>Task progress updates (messages) are displayed here,<br>along with any other output generated by the Task.<html>");
scrollPane1.setViewportView(ttaStatus);
}
contentPanel.add(scrollPane1, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//======== panel2 ========
{
panel2.setOpaque(false);
panel2.setBorder(new CompoundBorder(
new TitledBorder("Status - control progress reporting"),
Borders.DLU2_BORDER));
panel2.setLayout(new TableLayout(new double[][] {
{0.45, TableLayout.FILL, 0.45},
{TableLayout.PREFERRED, TableLayout.PREFERRED}}));
((TableLayout)panel2.getLayout()).setHGap(5);
((TableLayout)panel2.getLayout()).setVGap(5);
//======== panel3 ========
{
panel3.setOpaque(false);
panel3.setLayout(new GridLayout(1, 2));
//---- checkboxRecvStatus ----
checkboxRecvStatus.setText("Enable \"Recieve\"");
checkboxRecvStatus.setOpaque(false);
checkboxRecvStatus.setToolTipText("Task will fire \"send\" status updates");
checkboxRecvStatus.setSelected(true);
panel3.add(checkboxRecvStatus);
//---- checkboxSendStatus ----
checkboxSendStatus.setText("Enable \"Send\"");
checkboxSendStatus.setOpaque(false);
checkboxSendStatus.setToolTipText("Task will fire \"recieve\" status updates");
panel3.add(checkboxSendStatus);
}
panel2.add(panel3, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- ttfProgressMsg ----
ttfProgressMsg.setText("Connecting to Google Maps...");
ttfProgressMsg.setToolTipText("Set the task progress message here");
panel2.add(ttfProgressMsg, new TableLayoutConstraints(2, 0, 2, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- progressBar ----
progressBar.setStringPainted(true);
progressBar.setString("progress %");
progressBar.setToolTipText("% progress is displayed here");
panel2.add(progressBar, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//---- lblProgressStatus ----
lblProgressStatus.setText("task status listener");
lblProgressStatus.setHorizontalTextPosition(SwingConstants.LEFT);
lblProgressStatus.setHorizontalAlignment(SwingConstants.LEFT);
lblProgressStatus.setToolTipText("Task status messages are displayed here when the task runs");
panel2.add(lblProgressStatus, new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
}
contentPanel.add(panel2, new TableLayoutConstraints(0, 2, 0, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
setSize(675, 485);
setLocationRelativeTo(null);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner non-commercial license
private JPanel dialogPane;
private JPanel contentPanel;
private JPanel panel1;
private JLabel label2;
private JTextField ttfSizeW;
private JLabel label4;
private JTextField ttfLat;
private JButton btnGetMap;
private JButton btnLoadCSV;
private JLabel label3;
private JTextField ttfSizeH;
private JLabel label5;
private JTextField ttfLon;
private JButton btnQuit;
private JLabel label1;
private JLabel label6;
private JLabel label7;
private JTextField ttfZoom;
private JScrollPane scrollPane1;
private JTextArea ttaStatus;
private JPanel panel2;
private JPanel panel3;
private JCheckBox checkboxRecvStatus;
private JCheckBox checkboxSendStatus;
private JTextField ttfProgressMsg;
private JFileChooser jfc;
private JProgressBar progressBar;
private JLabel lblProgressStatus;
}
最佳答案
您可以简单地将整个内容作为字符串读取并将其拆分。尝试下面的内容
import java.util.io
import java.util.scanner
File file = new File("file source");
Scanner fileScanner = new Scanner(file);
fileString = fileScanner.nextLine();
info = fileString.split(",");
关于java - 将 CSV 数据导入 JFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13553277/
我正在尝试将 JFrame (bar) 添加到 JFrame (foo),这会强制 bar 在之前关闭foo 可以再次集成。 例如,在我可以再次编写代码之前,必须关闭“About Eclipse”框架
我有一个名为 User 的 JFrame,在其中声明一个名为 id 的变量,并根据某些条件将其设置为特定值。 我需要在称为输出的第二个 JFrame 中使用此变量。 这是我的代码 class Inpu
我有这个问题:我有一个 ArrayList,其中包含一些我想在特定框架中使用的项目,问题是数组列表通过在主类中初始化而变满我的项目。在本类(class)中,我还启动了与其他框架链接的起始框架(登录框架
如何在隐藏一个 Swing 程序的同时将一个 javax.Swing 程序移动到另一个 Swing 程序,以及如何制作可滚动的 JFrame。请帮助我。 最佳答案 在这里你可以找到一个非常good e
所以基本上我有一个 2D 游戏(基本上是过去的仿制品的链接),当你按 e 键时,库存会打开,关闭时会隐藏。问题是,每次我按 e 键时,它都会打开一个包含所有初始值的新库存,我希望它在初始值之后打开一个
我有一个 JFrame(1,主框架),它延续了 JPanel 和 JTable 以及数据。用户可以编辑数据。因此,一个新的 JFrame (2) 打开,用户可以输入新数据。如果他们在第二帧中单击“确定
我有一个新的netbeans“Java应用程序”项目,我试图从主JFrame添加第二个JFrame,用户可以从中加载文件。 所以我有主要的 JFrame main 方法 public static v
我的程序应该在单击按钮时启动第二个 JFrame 并打印一条语句,但它总是启动三个 JFrame 并打印三个语句。我只需要它来打印出一份声明并启动一个 Jframe。这是代码: import java
我目前已经构建了一个使用多个框架的应用程序。但如果我能在 1 帧中使用所有我用过的帧,那就太好了。如下图所示。 因此,如果您按左侧按钮“Speler Overzicht”,它将在右侧面板中向用户显示,
我目前有一个按钮,单击该按钮时,会执行一种方法,该方法创建一个带有加载多个图像的面板的 jframe。如果多次单击此按钮,图像将继续添加到加载到 jframe 上的现有图像上。我应该使用什么代码,以便
为什么无法将JFrame添加到JFrame中?它只是将一个组件添加到容器中。 Java 如何禁止我这样做?是的,我知道这样做没有意义,但我的问题的重点是了解 Swing 机制 - 它在幕后是如何工作的
我创建了一个生成 StartUpWindow 对象的类。其中一个 JButton 组件关闭 JFrame,然后调用一种新类型的框架进行实例化,AdminMainWindow。但是,当 AdminMai
我试图在不显示 JFrame 本身的情况下将 JFrame 渲染为图像(类似于 this 问题所问的内容)。我试过使用这段代码: private static BufferedImage getScr
我正在使用 XFCE 4 桌面的 Debian 8 上编译并运行以下代码。 import javax.swing.JFrame; import javax.swing.JComponent; impo
我有 14 个 JFrame 类和一个 JFrame 类,其中包含一个充当日历的 JTable。我希望当用户从 JTable 日历中选择日期时,更改 14 个 JFrame 类中任何一个文本字段或任何
我有 3 个扩展 JFrame 的对象让我们调用他们 FrameA FrameB FrameC . FrameA是我的主应用程序窗口。来自 FrameA的构造函数如果应用程序未注册我创建 FrameB
我试图简单地创建四个 jtextfields 和一个 jbutton。按下按钮后,我希望输入到 jtextfields 的文本作为参数(p、var、s、f)传递到另一个窗口,该窗口使用给定的参数显示数
这个问题已经有答案了: Close one JFrame without closing another? (2 个回答) 已关闭 6 年前。 我制作了一个程序,其中存在三个jframe。但问题是,当
我正在用 java 构建一个桌面学生管理应用程序。所以我需要关闭当前的 JFRAME,同时另一个 JFRAME 可见(关闭新的 jframe 后,旧的 jframe 应该可见)。你能帮我一下吗? 最佳
我正在开发的应用程序包含一个主 JFrame,用户最终可能会从中打开另一个补充框架。我正在尝试实现应用程序的这种行为,其中一旦主框架最小化,补充框架就会最小化(图标化)。 我正在考虑重写主框架的 se
我是一名优秀的程序员,十分优秀!