com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel这个缺少

evenlyu 2019-08-02 11:52:47
java.lang.ClassNotFoundException: com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:415)
at java.desktop/javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:2036)
at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:632)
at test.One.<init>(One.java:17)
at test.One.main(One.java:10)

新安装的jdk12,想试试换个皮肤,提示以上错误

附上代码:
public class One extends JFrame{

public static void main(String[] args)
{
new One();

}

One(){
try {
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
this.setSize(1320, 750);
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
...全文
566 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Franky ? 2020-02-29
  • 打赏
  • 举报
回复
没导入这个jar包,建议设置idea自动下载jar包
evenlyu 2019-08-02
  • 打赏
  • 举报
回复
想知道是什么错误,该如何修改,麻烦各位大神了
Java Platform Standard Edition 7 Documentation What's New Documentation Release Notes Tutorials and Training The Java Tutorials Java Training More Information Java SE 7 Names and Versions Java SE White Papers Documentation Accessibility Specifications Installation Instructions Supported Systems Configurations Java SE 7 and JDK 7 Compatibility JDK 7 Adoption Guide Troubleshooting Java SE About Test / Sample Applications and Code Resources Oracle Java SE Advanced and Oracle Java SE Suite Open JDK Bugs Database Downloads Java SE Downloads Community Forums Blogs User Groups Wikis Newsletters Events Other Technologies Java EE Java ME Java FX GlassFish NetBeans Oracle has two products that implement Java Platform Standard Edition (Java SE) 7: Java SE Development Kit (JDK) 7 and Java SE Runtime Environment (JRE) 7. JDK 7 is a superset of JRE 7, and contains everything that is in JRE 7, plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE 7 provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language. The following conceptual diagram illustrates Java component technologies: JDK Java Language Java Language ` Tools & Tool APIs java javac javadoc jar javap JPDA JConsole Java VisualVM Java DB Security Int'l RMI IDL Deploy Monitoring Troubleshoot Scripting JVM TI JRE RIAs Java Web Start Applet / Java Plug-in User Interface Toolkits AWT Swing Java 2D Accessibility Drag n Drop Input Methods Image I/O Print Service Sound Java SE API Integration Libraries IDL JDBC JNDI RMI RMI-IIOP Scripting Other Base Libraries Beans Int'l Support Input/Output JMX JNI Math Networking Override Mechanism Security Serialization Extension Mechanism XML JAXP lang and util Base Libraries lang and util Collections Concurrency Utilities JAR Logging Management Preferences API Ref Objects Reflection Regular Expressions Versioning Zip Instrumentation Java Virtual Machine Java HotSpot Client and Server VM Description of Java Conceptual Diagram What's New in Documentation Documentation is regularly updated to provide developers with in-depth information about new features in the Java platform. Some recent updates include: Swing The JLayer class has been added, which is a flexible and powerful decorator for Swing components; see How to Decorate Components with JLayer. The Nimbus Look and Feel has been moved from the com.sun.java.swing package to the javax.swing package; see the javax.swing.plaf.nimbus package. Mixing Heavyweight and Lightweight Components is easier to accomplish. Windows with transparency and non-rectangular shape are supported; see How to Create Translucent and Shaped Windows An HSV tab has been added to the JColorChooser class. Java I/O The java.nio.file package and its related package, java.nio.file.attribute, provide comprehensive support for file I/O and for accessing the file system; see File I/O (featuring NIO.2). NIO stands for non-blocking I/O. The directory <Java home>/sample/nio/chatserver/ contains samples that demonstrate the new APIs contained in the java.nio.file package. The directory <Java home>/demo/nio/zipfs/ contains samples that demonstrate the NIO.2 NFS (Network File System) file system. Networking The URLClassLoader.close method has been added; see Closing a URLClassLoader. The Sockets Direct Protocol (SDP) provides access to high performance network connections; see Understanding the Sockets Direct Protocol. Security A new native provider has been added that provides several ECC-based algorithms (ECDSA/ECDH); see Sun PKCS#11 Provider's Supported Algorithms in Java PKCS#11 Reference Guide. Weak cryptographic algorithms can now be disabled; see Appendix D: Disabling Cryptographic Algorithms in Java PKI Programmer's Guide and Disabled Cryptographic Algorithms in Java Secure Socket Extension (JSSE) Reference Guide. Various enhancements related to SSL/TLS have been added to Java Secure Socket Extension. Collections The TransferQueue interface has been added, which is a refinement of the BlockingQueue interface. The class LinkedTransferQueue implements the TransferQueue interface. Concurrency The fork/join framework, which is based on the ForkJoinPool class, is an implementation of the Executor interface. It is designed to efficiently run a large number of tasks using a pool of worker threads. A work-stealing technique is used to keep all the worker threads busy, to take full advantage of multiple processors. See Fork/Join in The Java Tutorials. The directory <Java home>/sample/forkjoin/ contains samples that demonstrate the fork/join framework. The ThreadLocalRandom class eliminates contention among threads using pseudo-random numbers; see Concurrent Random Numbers. The Phaser class is a new synchronization barrier, similar to CyclicBarrier. Rich Internet Applications (RIA) and Deployment The window of a dragged applet can be decorated with a default or custom title; see Requesting and Customizing Applet Decoration in Draggable Applets. The following enhancements have been made to the syntax of JNLP files; see JNLP File Syntax: The os attribute in the information and resources elements can now contain specific versions of Windows, such as Windows Vista or Windows 7. Applications can use the install attribute in the shortcut element to specify their desire to be installed. Installed applications are not removed when the Java Web Start cache is cleared, but can be explicitly removed using the Java Control Panel. Java Web Start applications can be deployed without specifying the codebase attribute; see Deploying Without Codebase A JNLP file can be embedded into an HTML page; see Embedding JNLP File in Applet Tag. You can check the status variable of the applet while it is loading to determine if the applet is ready to handle requests from JavaScript code; see Handling Initialization Status With Event Handlers. You now have control of the window decoration style and title of an applet launched from a shortcut or dragged out of the browser; see Requesting and Customizing Applet Decoration in Developing Draggable Applets. Java 2D A new XRender-based Java 2D rendering pipeline is supported for modern X11-based desktops, offering improved graphics performance; see the xrender flag in System Properties for Java 2D Technology. The JDK now enumerates and displays installed OpenType/CFF fonts through methods such as GraphicsEnvironment.getAvailableFontFamilyNames; these fonts are also recognized by the Font.createFont method. See Selecting a Font. The TextLayout class supports Tibetan script. libfontconfig, a font configuration API, is used to select fonts to use for the logical fonts for some implementations of Linux; see Fontconfig. Java XML This release contains Java API for XML Processing (JAXP) 1.4.5, supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports Java API for XML Web Services (JAX-WS) 2.2.4. Internationalization Unicode 6.0.0 is supported; see Unicode in The Java Tutorials. The directory <Java home>/demo/jfc/Font2DTest/ contains samples that demonstrate Java support for Unicode 6.0. Java SE 7 can accommodate new currencies that are identified by their ISO 4217 codes; see the Currency class. java.lang Package Potential deadlocks were eliminated for multithreaded, non-hierarchically delegating custom class loaders; see Multithreaded Custom Class Loaders in Java SE 7. Java Programming Language The following enhancements have been added to the Java language: Binary Literals Underscores in Numeric Literals Strings in switch Statements Type Inference for Generic Instance Creation Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs Methods The try-with-resources Statement Catching Multiple Exception Types and Rethrowing Exceptions with Improved Type Checking Java Virtual Machine Java Virtual Machine Support for Non-Java Languages: Java SE 7 introduces a new JVM instruction that simplifies the implementation of dynamically typed programming languages on the JVM. Garbage-First Collector is a server-style garbage collector that replaces the Concurrent Mark-Sweep Collector (CMS). Java HotSpot Virtual Machine Performance Enhancements JDBC 4.1 JDBC 4.1 introduces the following features: The ability to use a try-with-resources statement to automatically close resources of type Connection, ResultSet, and Statement; see Closing Connections in Processing SQL Statements. RowSet 1.1: The introduction of the RowSetFactory interface and the RowSetProvider class, which enable you to create all types of row sets supported by your JDBC driver; see Using the RowSetFactory Interface in Using JdbcRowSet Objects.
package com.Login; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.GridLayout; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.UIManager; import com.jdbc.DB; import com.window.Main; public class Login extends JFrame { private JPanel contentPane; private Point pressedPoint; /*private final class LoginActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { // 显示窗体的登录进度面板 getGlassPane().setVisible(true); } }*/ public static void main(String[] args) { try { UIManager .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Throwable e) { e.printStackTrace(); } EventQueue.invokeLater(new Runnable() { public void run() { try { Login frame = new Login (); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public Login(){ super("登录"); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { do_this_windowOpened(e); } }); setUndecorated(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(380,280); setIconImage(new ImageIcon("image\\tubiao.png").getImage()); Dimension displaySize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize=this.getSize(); setLocation((displaySize.width - frameSize.width) / 2+(frameSize.width)/2,(displaySize.height - frameSize.height) / 2); contentPane=new JPanel(); contentPane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); //设置边框为无 contentPane.setLayout(new BorderLayout(0,0));//设置contentPane的布局 setContentPane(contentPane);// JPanel topPanel = new JPanel(){ public void paintComponent(Graphics g) { g.drawImage(new ImageIcon("image\\logintop1.jpg").getImage(), 0, 0,500,48, null); super.paintComponent(g); } };//标题栏panel topPanel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { do_topPanel_mouseDragged(e); } }); topPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { do_topPanel_mousePressed(e); } }); topPanel.setOpaque(false);//设置背景透明 topPanel.setPreferredSize(new Dimension(500,30)); topPanel.setLayout(null); JPanel panel = new JPanel(); panel.setBounds(312, 0, 66, 15); panel.setOpaque(false); topPanel.add(panel); panel.setLayout(new GridLayout(1, 0, 0, 0)); JButton button = new JButton(""); button.setRolloverIcon(new ImageIcon("image\\button4.png")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { do_button_itemStateChanged(e); } }); button.setFocusPainted(false);// 取消焦点绘制 button.setBorderPainted(false);// 取消边框绘制 button.setContentAreaFilled(false);// 取消内容绘制 button.setIcon(new ImageIcon("image\\button4-1.png")); panel.add(button); JButton button_2 = new JButton(""); button_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { do_button_2_actionPerformed(e); } }); button_2.setRolloverIcon(new ImageIcon("image\\button3.png")); button_2.setFocusPainted(false); button_2.setContentAreaFilled(false); button_2.setBorderPainted(false); button_2.setIcon(new ImageIcon("image\\button3-1.png")); panel.add(button_2); contentPane.add(topPanel, BorderLayout.NORTH); JPanel backgroundPanel = new JPanel(){ public void paintComponent(Graphics g) { g.drawImage(new ImageIcon("image\\loginframe1.jpg").getImage(), 0, 0,500,300, null); super.paintComponent(g); } };//panel backgroundPanel.setLayout(new GridLayout(1,1)); backgroundPanel.setOpaque(false); JPanel panel1 = new JPanel() { public void paintComponent(Graphics g) { g.drawImage(new ImageIcon("image\\4.png").getImage(), 0, 0,420,200, null); super.paintComponent(g); } }; panel1.setLayout(null); panel1.setOpaque(false); JLabel label1=new JLabel("用户名:"); JLabel label2=new JLabel("密 码:"); final JTextField text1=new JTextField(15); final JPasswordField text2=new JPasswordField(15); label1.setBounds(80,60,60,30); text1.setBounds(160, 60, 150,30); label2.setBounds(80,120,60,30); text2.setBounds( 160, 120, 150, 30); panel1.add(label1); panel1.add(text1); panel1.add(label2); panel1.add(text2); backgroundPanel.add(panel1); contentPane.add(backgroundPanel, BorderLayout.CENTER); JPanel panel2 =new JPanel(); //panel2.setPreferredSize(new Dimension(380,40)); panel2.setLayout(null); panel2.setOpaque(false); JButton button1=new JButton("登录"); JButton button2=new JButton("取消"); MouseAdapter mouseAdapter = new MouseAdapter() {// 创建鼠标事件监听器 private Rectangle sourceRec;// 创建矩形对象 @Override public void mouseEntered(MouseEvent e) { JButton button = (JButton) e.getSource();// 获取事件源按钮 sourceRec = button.getBounds();// 保存按钮大小 button.setBounds(sourceRec.x-5, sourceRec.y-5, sourceRec.width + 10, sourceRec.height + 10);// 把按钮放大 super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { JButton button = (JButton) e.getSource();// 获取事件源按钮 if (sourceRec != null) {// 如果有备份矩形则用它恢复按钮大小 button.setBounds(sourceRec);// 设置按钮大小 } super.mouseExited(e); } }; button1.addMouseListener(mouseAdapter); button2.addMouseListener(mouseAdapter); button1.setBackground(new Color(154,216,230)); button2.setBackground(new Color(154,216,230)); //button1.setBorder(BorderFactory.createLineBorder(Color.blue) ); //button1.setBorder(new EmptyBorder(10, 0, 0, 0));// 顶部留白:40pix //button2.setBorder(new EmptyBorder(10, 0, 0, 0));// 顶部留白:40pix button1.setBounds(190, 9,70, 30); button2.setBounds(280, 9,70, 30); panel2.add(button1); panel2.add(button2); panel2.setBounds(0, 200, 380, 50); panel1.add(panel2); //button1.addActionListener( new LoginActionListener()); button1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Connection con = null; PreparedStatement pstmt = null; ResultSet rs=null; Statement stmt=null; try{ con=DB.getConnection(); pstmt = con.prepareStatement("select *from tb_manager where id=? and password=?"); pstmt.setString(1, text1.getText()); pstmt.setString(2, text2.getText()); rs=pstmt.executeQuery(); JOptionPane pane=new JOptionPane(); if(rs.next()) { // new LoginActionListener(); pane.showMessageDialog(null, "登录成功!"); // new Main(); new Main(); dispose();// 销毁窗体 con.close(); } else if(text1.getText().equals("")||text2.getText().equals("")) { pane.showMessageDialog(null, " 登录失败!用户名或密码不能为空,请重新输入!"); text1.setText(""); text2.setText(""); } else { pane.showMessageDialog(null, "登录失败,你输入的用户名或密码错误,请重新输入!"); text1.setText(""); text2.setText(""); } }catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { DB.close(pstmt); DB.close(pstmt); } } } ); button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } } ); } protected void do_button_itemStateChanged(ActionEvent e) { setExtendedState(JFrame.ICONIFIED);// 窗体最小化 } protected void do_button_2_actionPerformed(ActionEvent e) { dispose();// 销毁窗体 } protected void do_topPanel_mousePressed(MouseEvent e) { pressedPoint = e.getPoint();// 记录鼠标坐标 } protected void do_topPanel_mouseDragged(MouseEvent e) { Point point = e.getPoint();// 获取当前坐标 Point locationPoint = getLocation();// 获取窗体坐标 int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标 int y = locationPoint.y + point.y - pressedPoint.y; setLocation(x, y);// 改变窗体位置 } protected void do_this_windowOpened(WindowEvent e) { final int height = getHeight();// 记录窗体高度 new Thread() {// 创建新线程 public void run() { Rectangle rec = getBounds(); for (int i = 0; i < 385; i += 10) {// 循环拉伸窗体 setBounds(rec.x - i / 2, rec.y, i, height);// 不断设置窗体大小与位置 try { Thread.sleep(15);// 线程休眠10毫秒 } catch (InterruptedException e1) { e1.printStackTrace(); } } } }.start();// 启动线程 } }

58,453

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧