我从事Web开发已经有一段时间了,现在我想学习android。我懂java,那很好。我感兴趣的是如何设计我的应用程序。例如,如果我想在按钮上添加一些边框,或添加阴影。如果它是一个网站,我会使用 css,但是我在 android 中使用什么?
我说的是原生 Android 应用程序,我不想使用像 ionic 或类似的框架。
我想知道如何在不让用户离开甚至关闭窗口的情况下改变我的java应用程序的外观.我知道这是可能的,正如我已经看到的那样.我尝试实现它,下面显示的代码,但它只有在我setLookAndFeel()显示窗口之前调用我的方法时才有效.
我究竟做错了什么?
package lookandfeeltester;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class MainJFrame extends javax.swing.JFrame
{
public MainJFrame()
{
setDefaultLookAndFeelDecorated(true);
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup = new javax.swing.ButtonGroup();
metalRadioButton = new javax.swing.JRadioButton();
nimbusRadioButton = new javax.swing.JRadioButton();
motifRadioButton = new javax.swing.JRadioButton();
windowsRadioButton = new javax.swing.JRadioButton();
windowsClassicRadioButton = new javax.swing.JRadioButton();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
exitMenuItem = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.GridBagLayout());
buttonGroup.add(metalRadioButton);
metalRadioButton.setText("Metal");
metalRadioButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { …Run Code Online (Sandbox Code Playgroud) 我需要创建一些JSpinner控件,我可以检测按钮按下,同时使用当前的外观.我发现我可以轻松地做到这一点,如下所示:
class CustomSpinnerUI extends BasicSpinnerUI {
@Override
protected Component createNextButton() {
// Add custom ActionListener.
}
@Override
protected Component createPreviousButton() {
// Add custom ActionListener.
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,通过这样做,我最终得到一个看起来很讨厌的微调器,它不会像我的UI的其余部分那样使用相同的外观和感觉.我目前正在使用,Nimbus但我需要支持不同的L&F配置.
我想过可能会设置某种动态代理,但找不到任何合适的Spinner接口来让我这样做.
任何人都可以想到解决这个问题的方法吗?我想我要么在ActionListeners没有子类化的情况下得到按钮BasicSpinnerUI,要么想办法让我CustomSpinnerUI使用正确的L&F.
编辑:"默认外观" - >"当前外观".
我有一个基本的GUI(带按钮的普通Jframe),我使用Nimrod改变了外观.新的l&f是一个黑暗的主题,我在运行时更改.
然而,当GUI运行时,在非常短的时间内,GUI具有明亮的背景,然后应用新的黑暗l&f.
我认为造成这种短暂亮度闪现的原因是,在运行时,默认的l&f会在新应用之前暂时显示.
它只有几分之一秒,但它显而易见且非常烦人,因为它看起来不整洁.
如果我在运行时使用按钮更改l&f,似乎不会发生这种情况.
那么,有没有其他人有这方面的经验?这有可能的解决方法吗?隐藏JFrame直到应用新的l&f?
如果有帮助,这是我的代码:
public static void main(String[] args)
{
setTheme();
NewJFrame njf = new NewJFrame();
njf.setLocationRelativeTo(null);
njf.setTitle("My First Swing Application");
njf.pack();
njf.setVisible(true);
}
static void setTheme()
{
NimRODTheme nt = new NimRODTheme();
nt.setPrimary1( new Color(0,51,153));
nt.setPrimary2( new Color(0,92,143));
nt.setPrimary3( new Color(0,102,153));
nt.setSecondary1( new Color(31,31,31));
nt.setSecondary2( new Color(41,41,41));
nt.setSecondary3( new Color(51,51,51));
nt.setWhite( new Color(0,0,0));
nt.setBlack( new Color(255,255,255));
nt.setMenuOpacity(195);
nt.setFrameOpacity(180);
NimRODLookAndFeel NimRODLF = new NimRODLookAndFeel();
NimRODLF.setCurrentTheme (nt);
try
{
UIManager.setLookAndFeel(NimRODLF);
}
catch(Exception e)
{
}
}
Run Code Online (Sandbox Code Playgroud)
此外,如果需要nimrod,您可以在此处获取:http …
是的一些问题接近:)
Java中存在一个Bug(自2011年以来一直存在并报告,似乎没有努力修复它 - 应该在VM的本机端处理)
也就是说,当你最大化一个"未修饰"的窗口,或者一个带有PLAF外观和感觉的窗口时,它将覆盖windows任务栏.很好 - 当你想要它时,你需要它,但当你想要任务栏最大化的窗口覆盖它时.设置"永远在最顶层"的权利没有任何区别.
是的,可以调整窗口大小但是必须知道任务栏的位置,或者屏幕大小减去任务栏 - 知道如何做到这一点?
并且如果要完成,则需要知道您在没有任务栏的屏幕上最大化.如果在多监视器虚拟桌面上......
有任何想法吗 :)

我非常清楚如何使用a JTabbedPane但它看起来不像你在MS Word的功能区中获得的标签.我想知道是否有办法让它JTabbedPane看起来像MS Word中的功能区(或任何其他方式来改变它的外观)
嘿伙计们,所以我能够设置弹出窗口的默认框架,该窗口是从一个单独的类调用的.你可能会说我是java的极端菜鸟.任何帮助,将不胜感激.
这是调用第二个类来运行的代码.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
class Login extends JFrame implements ActionListener
{
JButton SUBMIT;
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
Login()
{
label1 = new JLabel();
label1.setText(" Enter Username:");
label1.setForeground(Color.green);
text1 = new JTextField(10);
label2 = new JLabel();
label2.setText(" Enter Password:");
label2.setForeground(Color.green);
text2 = new JPasswordField(10);
SUBMIT=new JButton("SUBMIT");
SUBMIT.setOpaque(true);
SUBMIT.setBackground(Color.BLACK);
SUBMIT.setForeground(Color.green);
panel=new JPanel(new GridLayout(4,1));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(SUBMIT);
add(panel,BorderLayout.CENTER);
SUBMIT.addActionListener(this);
setTitle("LOGIN or DIE!!!!!");
panel.setBackground(Color.black);
setDefaultLookAndFeelDecorated(true);
setLocationRelativeTo(null);
}
public void actionPerformed(ActionEvent ae)
{
String …Run Code Online (Sandbox Code Playgroud) 有没有像Intelij Dracula这样的免费酷黑 LookAndFeel可以在 Windows 和 Linux 上完美运行?
我是一名学生,我正在为我的应用程序使用想法。我正在研究摇摆形式,我已经做了所有事情,但无法改变我的应用程序的外观和感觉。
我正在使用 intellij idea 社区版,谁能告诉我如何更改我的 Swing 应用程序的外观和感觉?