📄 consoleframe.java
字号:
if (result == JFileChooser.APPROVE_OPTION)
{
try
{
File f = fileDialog.getSelectedFile ();
String filename = f.getName ();
if (!(filename.endsWith (Messages.getString("Console.26")))) //$NON-NLS-1$
filename = filename + Messages.getString("Console.27"); //$NON-NLS-1$
f = new File (filename);
if (f.exists ()){
}
//JOptionPane.showMessageDialog (this, new String (filename), new String (Messages.getString("Console.INFO_ALREADY_EXISTS")), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
else
{
f.createNewFile ();
PrintWriter fout = new PrintWriter (new FileOutputStream (f));
fout.print (GarminGMLDoc.printDoc ());
fout.close ();
//JOptionPane.showMessageDialog (this, new String (Messages.getString("Console.INFO_SAVED_SUCCESSFUL")), new String (Messages.getString("Console.INFO_SAVED_TO") +filename+Messages.getString("Console.31")), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
catch (FileNotFoundException ex)
{
System.out.println (ex);
}
catch (IOException ex)
{
System.out.println (ex);
}
}
}
else if (arg.equals (Messages.getString("Console.MENU_SAVE_MAP_AS"))) //$NON-NLS-1$
{
JFileChooser fileDialog = new JFileChooser ();
fileDialog.setCurrentDirectory (new File (Messages.getString("Console.33"))); //$NON-NLS-1$
int result = fileDialog.showSaveDialog (this);
if (result == JFileChooser.APPROVE_OPTION)
{
try
{
File svgFile = fileDialog.getSelectedFile ();
String filename = svgFile.getName ();
if (!(filename.endsWith (Messages.getString("Console.34")))) //$NON-NLS-1$
filename = filename + Messages.getString("Console.35"); //$NON-NLS-1$
if (filename.endsWith (Messages.getString("Console.DEFAULT_BG_NAME"))) //$NON-NLS-1$
filename = filename + Messages.getString("Console.37"); //$NON-NLS-1$
svgFile = new File (filename);
BufferedReader bin = new BufferedReader(new FileReader (GarminConfiguration.getTmpFile ()));
PrintWriter fout = new PrintWriter (new FileOutputStream (svgFile));
String line = null;
for (line = bin.readLine (); line != null; line = bin.readLine ())
{
fout.println (line);
}
fout.close ();
}
catch (FileNotFoundException ex)
{
System.out.println (ex);
}
catch (IOException ex)
{
System.out.println (ex);
}
}
}
else if (arg.equals (Messages.getString("Console.38"))) //$NON-NLS-1$
{
JFrame optionsFrame = new ConsoleOptionsFrame ();
optionsFrame.show ();
}
else if (arg.equals (Messages.getString("Console.39"))) //$NON-NLS-1$
{
JFrame gps = new ConsoleGPSInfoFrame ();
gps.show ();
}
else if (arg.equals (Messages.getString("Console.40"))) //$NON-NLS-1$
{
JFrame about = new ConsoleAboutFrame ();
about.show ();
}
else if (arg.equals (Messages.getString("Console.41"))) //$NON-NLS-1$
{
WaypointCommand.getWaypoints ();
}
else if (arg.equals (Messages.getString("Console.42"))) //$NON-NLS-1$
{
TrackLogCommand.getTrackLogGML ();
}
else if (arg.equals (Messages.getString("Console.43"))) //$NON-NLS-1$
{
svgURI = GarminGMLDoc.updateSVGFile (svgURI);
svgCanvas.loadSVGDocument (svgURI);
ssave.setEnabled (true);
}
else if (arg.equals (Messages.getString("Console.44"))) //$NON-NLS-1$
{
GarminConfiguration.initReceiver();
dlTracks.setEnabled (true);
dlTracksToExcel.setEnabled(true);
dlWaypointToTracks.setEnabled(true);
dlWaypts.setEnabled (true);
dlTracksToDatabase.setEnabled(true);
dlTracksFromDatabase.setEnabled(true);
dlDrawLine.setEnabled(true);
dlPrintDoc.setEnabled(true);
setTitle (GarminConfiguration.getDesc ());
}
else if (arg.equals (Messages.getString("Console.45"))) //$NON-NLS-1$
{
setSize (548, 320);
svgCanvas.loadSVGDocument (svgURI);
}
else
{
//JOptionPane.showMessageDialog (this, new String (arg+Messages.getString("Console.46")), new String (arg+Messages.getString("Console.47")), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
class ConsoleAboutFrame extends JFrame implements ActionListener
{
public ConsoleAboutFrame ()
{
setTitle (Messages.getString("Console.48")); //$NON-NLS-1$
setSize (290, 270);
setIconImage (ConsoleFrame.icon);
getContentPane ().setLayout (new BorderLayout ());
JButton okButton = new JButton (Messages.getString("Console.49")); //$NON-NLS-1$
okButton.addActionListener (this);
Box bc = Box.createHorizontalBox ();
bc.add (Box.createHorizontalGlue ());
bc.add (new JLabel (Messages.getString("Console.50")), BorderLayout.CENTER); //$NON-NLS-1$
bc.add (Box.createHorizontalGlue ());
Box bb = Box.createVerticalBox ();
bb.add (new JSeparator ());
bb.add (addTextLine (Messages.getString("Console.51"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.52"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.53"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.54"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.55"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.56"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.57"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.58"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.59"))); //$NON-NLS-1$
bb.add (addTextLine (Messages.getString("Console.60"))); //$NON-NLS-1$
bc.add (Box.createVerticalGlue ());
bb.add (new JSeparator ());
Box bok = Box.createHorizontalBox ();
bok.add (Box.createHorizontalGlue ());
bok.add (okButton);
bok.add (Box.createHorizontalGlue ());
getContentPane ().add (Box.createHorizontalStrut (5), BorderLayout.EAST);
getContentPane ().add (bc, BorderLayout.NORTH);
getContentPane ().add (bb, BorderLayout.CENTER);
getContentPane ().add (bok, BorderLayout.SOUTH);
getContentPane ().add (Box.createHorizontalStrut (5), BorderLayout.WEST);
}
public Box addTextLine (String text)
{
Box textBox = Box.createHorizontalBox ();
textBox.add (new JLabel (text));
textBox.add (Box.createHorizontalGlue ());
return textBox;
}
public void actionPerformed (ActionEvent evt)
{
String arg = evt.getActionCommand ();
if (arg.equals (Messages.getString("Console.61"))) //$NON-NLS-1$
dispose ();
}
}
class ConsoleGPSInfoFrame extends JFrame implements ActionListener
{
public ConsoleGPSInfoFrame ()
{
ProductData pd = new ProductData();
DateTime dt = new DateTime ();
Box b0 = Box.createHorizontalBox ();
Box b1 = Box.createHorizontalBox ();
Box b8 = Box.createHorizontalBox ();
Box b3 = Box.createHorizontalBox ();
Box b4 = Box.createHorizontalBox ();
Box b5 = Box.createHorizontalBox ();
Box b6 = Box.createHorizontalBox ();
Box b7 = Box.createHorizontalBox ();
setTitle (Messages.getString("Console.62")); //$NON-NLS-1$
setSize (320,305);
setIconImage (ConsoleFrame.icon);
Box pb = Box.createVerticalBox ();
String[] pros = pd.getPhysicalProtocols ();
String phypro = new String (Messages.getString("Console.63")); //$NON-NLS-1$
for (int i = 0; i < pros.length; i++)
{
phypro = new String (phypro+pros[i]+Messages.getString("Console.64")); //$NON-NLS-1$
if (i % 4 == 3)
{
pb.add (new JLabel (phypro));
phypro = new String (Messages.getString("Console.65")); //$NON-NLS-1$
}
}
pb.add (new JLabel (phypro));
Box lb = Box.createVerticalBox ();
pros = pd.getLinkProtocols ();
String linkpro = new String (Messages.getString("Console.66")); //$NON-NLS-1$
for (int i = 0; i < pros.length; i++)
{
linkpro = new String (linkpro+pros[i]+Messages.getString("Console.67")); //$NON-NLS-1$
if (i % 4 == 3)
{
lb.add (new JLabel (linkpro));
linkpro = new String (Messages.getString("Console.68")); //$NON-NLS-1$
}
}
lb.add (new JLabel (linkpro));
Box ab = Box.createVerticalBox ();
pros = pd.getApplicationProtocols ();
String apppro = new String (Messages.getString("Console.69")); //$NON-NLS-1$
for (int i = 0; i < pros.length; i++)
{
apppro = new String (apppro+pros[i]+Messages.getString("Console.70")); //$NON-NLS-1$
if (i % 4 == 3)
{
ab.add (new JLabel (apppro));
apppro = new String (Messages.getString("Console.71")); //$NON-NLS-1$
}
}
ab.add (new JLabel (apppro));
Box db = Box.createVerticalBox ();
pros = pd.getDataFormats ();
String datapro = new String (Messages.getString("Console.72")); //$NON-NLS-1$
for (int i = 0; i < pros.length; i++)
{
datapro = datapro + pros[i] + Messages.getString("Console.73"); //$NON-NLS-1$
if (i % 4 == 3)
{
db.add (new JLabel (datapro));
datapro = new String (Messages.getString("Console.74")); //$NON-NLS-1$
}
}
db.add (new JLabel (datapro));
b0.add (new JLabel (Messages.getString("Console.75"))); //$NON-NLS-1$
b0.add (Box.createGlue ());
b0.add (new JLabel (Messages.getString("Console.76")+pd.getProductID ())); //$NON-NLS-1$
b1.add (new JLabel (Messages.getString("Console.77"))); //$NON-NLS-1$
b1.add (Box.createGlue ());
b1.add (new JLabel (Messages.getString("Console.78")+pd.getSoftwareVersion ())); //$NON-NLS-1$
b3.add (new JLabel (Messages.getString("Console.79"))); //$NON-NLS-1$
b3.add (Box.createGlue ());
b3.add (new JLabel (pd.getProductDescription ()));
b4.add (new JLabel (Messages.getString("Console.80"))); //$NON-NLS-1$
b4.add (Box.createGlue ());
b4.add (pb);
b5.add (new JLabel (Messages.getString("Console.81"))); //$NON-NLS-1$
b5.add (Box.createGlue ());
b5.add (lb);
b6.add (new JLabel (Messages.getString("Console.82"))); //$NON-NLS-1$
b6.add (Box.createGlue ());
b6.add (ab);
b7.add (new JLabel (Messages.getString("Console.83"))); //$NON-NLS-1$
b7.add (Box.createGlue ());
b7.add (db);
b8.add (new JLabel (Messages.getString("Console.84"))); //$NON-NLS-1$
b8.add (Box.createGlue ());
b8.add (new JLabel (dt.printDate ()));
Box p = Box.createVerticalBox ();
p.add (b0);
p.add (Box.createVerticalStrut (5));
p.add (b1);
p.add (Box.createVerticalStrut (5));
p.add (b3);
p.add (Box.createVerticalStrut (5));
p.add (b4);
p.add (Box.createVerticalStrut (5));
p.add (b5);
p.add (Box.createVerticalStrut (5));
p.add (b6);
p.add (Box.createVerticalStrut (5));
p.add (b7);
p.add (Box.createVerticalStrut (5));
p.add (b8);
p.add (Box.createVerticalStrut (5));
JButton okButton = new JButton (Messages.getString("Console.85")); //$NON-NLS-1$
okButton.addActionListener (this);
Box okBox = Box.createHorizontalBox ();
okBox.add (Box.createHorizontalGlue ());
okBox.add (okButton);
okBox.add (Box.createHorizontalGlue ());
getContentPane ().setLayout (new BorderLayout());
getContentPane ().add (Box.createRigidArea (new Dimension (5, 5)), BorderLayout.NORTH);
getContentPane ().add (Box.createRigidArea (new Dimension (5, 5)), BorderLayout.EAST);
getContentPane ().add (p, BorderLayout.CENTER);
getContentPane ().add (Box.createRigidArea (new Dimension (5, 5)), BorderLayout.WEST);
getContentPane ().add (okBox, BorderLayout.SOUTH);
}
public void actionPerformed (ActionEvent evt)
{
String arg = evt.getActionCommand ();
if (arg.equals (Messages.getString("Console.86"))) //$NON-NLS-1$
dispose ();
}
}
class Console
{
public static void main (String[] args)
{
JFrame frame = new ConsoleFrame ();
frame.setTitle("GPS");
frame.show ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -