我正在使用swing编写应用程序.我需要通过单击JButton可以使用的for System.exit()或者我应该使用其他方法退出应用程序,这是最佳实践.如果调用System.exit()不是最佳实践,那么告诉原因并告诉退出应用程序的替代方法.
我们如何设置JFileChooser窗口的位置,我试过setLocation()和setBounds() 方法,但它不起作用.
最近我参加了一个访谈,他们要我写一个C程序连接两个字符串不使用strcat(),strlen()并且strcmp()和功能不应超过两(2)线.
我知道如何在不使用的情况下连接两个字符串strcat().但我的方法有近15行.我不知道怎么写两行.
我正在使用Nimbus外观和感觉.我需要在JTabbedPane中更改选项卡的背景颜色和前景色,但是在JTabbedPane中没有设置颜色.我尝试了setForeground(),setForegroundAt(),setBackground()和setBackgroundAt()方法,但它不起作用.这是我的代码
public class TabbedPaneDemo extends JFrame
{
TabbedPaneDemo()
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch(Exception ex) {}
setLayout(new BorderLayout());
setBounds(100, 100, 800, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane jt = new JTabbedPane();
jt.addTab("Tab1", new JPanel());
jt.addTab("Tab2", new JPanel());
jt.addTab("Tab3", new JPanel());
jt.addTab("Tab4", new JPanel());
for( int i = 0; i < jt.getComponentCount(); i++)
{
jt.setForegroundAt(i, Color.RED);
jt.setBackgroundAt(i, Color.BLACK);
}
add(jt);
setVisible(true);
}
public static void main(String args[])
{
new TabbedPaneDemo();
}
Run Code Online (Sandbox Code Playgroud)
}