Tag: macos

Java:如何检测(和更改?)System.console的编码?

我有一个程序在控制台上运行,它的变音符号和其他特殊字符在Mac上输出。 这是一个简单的测试程序: public static void main( String[] args ) { System.out.println(“höhößüä”); System.console().printf( “höhößüä” ); } 在默认的Mac控制台(使用默认的UTF-8编码)上,打印: h?h???? h?h???? 但手动将Mac终端的编码设置为“Mac OS Roman”后,它正确打印 höhößüä höhößüä 请注意,在使用System.console()的Windows系统上工作: h÷h÷▀³õ höhößüä 所以我如何制作我的节目…… rolleyes ……“到处跑”?

JDBC ODBC驱动程序连接

我正在为我的大学的一个class级做一个项目。 我正在学习连接和操作数据库,我们正在使用Microsoft .accdb文件。 这是我到目前为止所拥有的。 /* Perform database operations */ try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); System.out.println(“Driver loaded”); connection = DriverManager.getConnection(“jdbc:odbc:Lab3.accdb”); System.out.println(“Database connected”); statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(“”); while (resultSet.next()) { output.write(“” + resultSet.getString(1) + “\t” + resultSet.getString(2) + “\t” + resultSet.getString(3) + “”); } connection.close(); } catch (ClassNotFoundException|SQLException e) { System.out.println(“Database Access Error.”); e.printStackTrace(); } 在寻找“sun.jdbc.odbc.JdbcOdbcDriver”时,我得到以下输出。 […]

如何将JMenuBar移动到Mac OS X上的屏幕菜单栏?

当我将JMenuBar移动到Mac OS X上的屏幕菜单栏时,它会留下一些空白区域,菜单会出现在我的窗口中; 我需要删除那个空间。 我在用 System.setProperty(“apple.laf.useScreenMenuBar”, “true”) 将我的JMenuBar移动到屏幕菜单栏。 我的朋友使用Mac报告,如果我没有设置该属性,这将留下一些丑陋的垂直空间,菜单将驻留在该空间中。 解决此问题的最佳方法是什么? 编辑:这是我的来源的一个例子: public static void main(String[] args) { System.setProperty(“apple.laf.useScreenMenuBar”, “true”); System.setProperty(“com.apple.mrj.application.apple.menu.about.name”, “Name”); JFrame frame = new JFrame(“Gabby”); final DesktopMain dm = new DesktopMain(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(dm); frame.setSize(160, 144); frame.setLocationRelativeTo(null); frame.setIgnoreRepaint(true); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(“File”); menuBar.add(fileMenu); // Populating the menu bar code […]

在OSX上摇摆:如何捕获命令-Q?

在确信(“受过教育”)Mac上的Swing应用看起来本机之后 ,我试图让我的外观尽可能本地化。 一切看起来都很棒,但是当我点击命令 + Q或从菜单中执行时,我的windowStateChanged(WindowEvent e)没有在我的主JFrame上触发(如果我以任何其他方式退出,它会触发)。 我如何回应真正的Apple退出?

自定义按钮不能在mac上工作(ButtonUI)

我有一个应用程序,它使用遍布文本和图标的自定义按钮。 适用于Windows和Linux,但现在OSX用户抱怨。 文本不会显示在Mac上,只是’…’。 代码看起来很简单,但是对于mac来说我很无能为力。 我怎样才能解决这个问题? 测试用例: package example.swingx; import example.utils.ResourceLoader; import com.xduke.xlayouts.XTableLayout; import javax.swing.*; import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.event.ActionEvent; public class SmallButton extends JButton { private static ComponentUI ui = new SmallButtonUI(); public SmallButton() { super(); /* final RepaintManager repaintManager = RepaintManager.currentManager(this); repaintManager.setDoubleBufferingEnabled(false); setDebugGraphicsOptions(DebugGraphics.FLASH_OPTION);*/ } public SmallButton(AbstractAction action) { super(action); } public SmallButton(String text) […]